📄 e528. getting the notations in a dom document.txt
字号:
The notations declared in the DTD of an XML document are available in the DocumentType object of a DOM document.
// Obtain a document; the following method is implemented in
// e510 The Quintessential Program to Create a DOM Document from an XML File
Document doc = parseXmlFile("infilename.xml", false);
// Get list of notations
NamedNodeMap notations = doc.getDoctype().getNotations();
for (int i=0; i<notations.getLength(); i++) {
// Get notation node
Notation notation = (Notation)notations.item(i);
// Get details in notation node
String notationName = notation.getNodeName();
String notationPublicId = notation.getPublicId();
String notationSystemId = notation.getSystemId();
}
This is the sample input for the example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!NOTATION not1 PUBLIC "publicId" "systemId1">
<!NOTATION not2 SYSTEM "systemId2">
<!NOTATION not3 SYSTEM "http://hostname.com/systemid">
<!NOTATION not4 SYSTEM "">
]>
<root>
</root>
This is the data in the Notation nodes from the above input file. Note that the system ids are converted to absolute URIs.
Name, PublicId, SystemId
not1, publicId, file:D:/almanac/1.4/egs/org.w3c.dom/systemId1
not2, null, file:D:/almanac/1.4/egs/org.w3c.dom/systemId2
not3, null, http://hostname.com/systemid
not4, null, file:D:/almanac/1.4/egs/org.w3c.dom/.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -