JDOM 对 ID 和 IDREF 有支持吗?
<!DOCTYPE inventory [
<!ELEMENT book (title,author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST book year CDATA #IMPLIED>
<!ATTLIST book myId ID #REQUIRED>
<!ATTLIST book myIdRef IDREF #IMPLIED>
]>
<inventory>
<book year="2000" myId="1">
<title>Snow Crash</title>
<author>Neal Stephenson</author>
</book>
<book myId="3" myIdRef="1"/>
</inventory>
JDom 是否有能力执行以下操作:
Element root = doc.getRootElement();
List children = root.getChildren();
for(Object node:children){
Element book = (Element) node;
System.out.println(book.getAttributeValue("year"));
}
/*
So print:
2000
2000
*/
或任何其他与 ID 和 IDREF 相关的设施?
<!DOCTYPE inventory [
<!ELEMENT book (title,author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST book year CDATA #IMPLIED>
<!ATTLIST book myId ID #REQUIRED>
<!ATTLIST book myIdRef IDREF #IMPLIED>
]>
<inventory>
<book year="2000" myId="1">
<title>Snow Crash</title>
<author>Neal Stephenson</author>
</book>
<book myId="3" myIdRef="1"/>
</inventory>
Does JDom has ability to do something like:
Element root = doc.getRootElement();
List children = root.getChildren();
for(Object node:children){
Element book = (Element) node;
System.out.println(book.getAttributeValue("year"));
}
/*
So print:
2000
2000
*/
Or any other facility related to ID and IDREF??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里我找到了一些可以回答您问题的内容。 据我了解,jDom 没有直接支持,但有 org.jdom.contrib.ids 包
我找到了库 这里(这不是主要位置,也许其他人知道该库的存储库 URL)
Here I found something to answer your question. As far as I understand, jDom does not have a direct support but there's the
org.jdom.contrib.ids
package thatI found the library here (it's not the main location, maybe somebody else knows the repository URL for that library)