XML : java DocumentBuilder with DTD validation validates invalid XML

I was given a simple XML document under DTD validation with the following structure:

people.xml

  <?xml version='1.0' encoding='ISO-8859-15' ?>    <!DOCTYPE people SYSTEM "people.dtd">    <people>      <person dni="1234345F" >          <name>pepe</name>          Description for pepe          <age>12</age>          <subject>maths</subject>          <subject>history</subject>      </person>      <person dni="12343sdfF" >          Description for marcos          <name>marcos</name>          <age>12</age>          <subject>music</subject>          <subject>Spanish</subject>      </person>      <person dni="345634345F" >          <name>JL</name>          <age>25</age>          <subject>science</subject>          <subject>maths</subject>          Description for JL      </person>  </people>    

As you can see, the location of the description text node for every person is unknown in the moment of valitation. I have written this DTD:

people.dtd

  <!ELEMENT people (person+)>  <!ELEMENT person (name|age|subject+|#PCDATA)>  <!ELEMENT name (#PCDATA)>  <!ELEMENT age (#PCDATA)>  <!ELEMENT subject (#PCDATA)>  <!ATTLIST person dni CDATA #REQUIRED>    

I have tried almost every combination for this line (name|age|subject+|#PCDATA) but I am still unable to have it matching with the xml document.

No comments:

Post a Comment