Pregunta

<!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>

¿Tiene jdom tiene capacidad para hacer algo como:

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
*/

O cualquier otra instalación relacionada con la identificación y IDREF ??

¿Fue útil?

Solución

Aquí he encontrado algo para responder a su pregunta. Por lo que yo entiendo, jdom no tiene un apoyo directo pero no el paquete que org.jdom.contrib.ids

  

Proporciona soporte para documentos   lo que permite levantar los elementos utilizando el   valor de su atributo ID

he encontrado la biblioteca aquí (que no es el lugar principal, tal vez alguien más sabe la URL del repositorio para esa biblioteca)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top