gpt4 book ai didi

java - JDOM 对 ID 和 IDREF 有支持吗?

转载 作者:行者123 更新时间:2023-11-30 05:16:25 25 4
gpt4 key购买 nike

<!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 相关的工具?

最佳答案

Here我找到了一些东西来回答你的问题。据我了解,jDom 没有直接支持,但有 org.jdom.contrib.ids 包

Provides support for Documents allowing looking up elements using the value of their ID attribute

我找到了图书馆here (这不是主要位置,也许其他人知道该库的存储库 URL)

关于java - JDOM 对 ID 和 IDREF 有支持吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/965754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com