本文整理匯總了Java中org.w3c.dom.Document.setDocumentURI方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.setDocumentURI方法的具體用法?Java Document.setDocumentURI怎麽用?Java Document.setDocumentURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Document
的用法示例。
在下文中一共展示了Document.setDocumentURI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.w3c.dom.Document; //導入方法依賴的package包/類
/**
* Parses the given document and add it to the DOM forest.
*
* @return null if there was a parse error. otherwise non-null.
*/
private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{
Document dom = documentBuilder.newDocument();
systemId = normalizeSystemId(systemId);
// put into the map before growing a tree, to
// prevent recursive reference from causing infinite loop.
core.put(systemId, dom);
dom.setDocumentURI(systemId);
if (root)
rootDocuments.add(systemId);
try {
XMLReader reader = createReader(dom);
InputStream is = null;
if(inputSource.getByteStream() == null){
inputSource = entityResolver.resolveEntity(null, systemId);
}
reader.parse(inputSource);
Element doc = dom.getDocumentElement();
if (doc == null) {
return null;
}
NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema");
for (int i = 0; i < schemas.getLength(); i++) {
inlinedSchemaElements.add((Element) schemas.item(i));
}
} catch (ParserConfigurationException e) {
errorReceiver.error(e);
throw new SAXException(e.getMessage());
}
resolvedCache.put(systemId, dom.getDocumentURI());
return dom;
}