Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Validation against DTD problem!

Status
Not open for further replies.

abc73

Programmer
Joined
Apr 28, 2004
Messages
89
Location
US
Please look at the following xml and the corrosponding DTD
Using XML Spy: My XML file is well formed but when I validate it against it's corrosponding DTD it gives an error saying: file is not valid Unexpected child element '2'. I don't know what's wrong, is there a problem in the DTD. <0> contains zero or more <1> <2> and <3>. Any help is appreciated. The structure is like:

0
|
--- 1 can repeat
--- 2 can repeat
--- 3 can repeat
|
4
|
9

Thanks

*************** XML file ************
Code:
<A>
<0>
<1>1</1>
<1>1</1>
<2>2</2>
<1>1</1>
<1>1</1>
<1>1</1>
<2>2</2>
<1>1</1>
<2>2</2>
<1>1</1>
<1>1</1>
<1>1</1>
<2>2</2>
<3>3</3>
<1>1</1>
<1>1</1>
<2>2</2>
<3>3</3>
</0>
<4>4</4>
<9>9</9>
</A>

************** Corrosponding DTD ****************
Code:
<!ELEMENT A (0?,4?,9?)>
<!ELEMENT 0 (1*)>
<!ELEMENT 1 (TEXT?,2*,3*)>
<!ELEMENT 2 (TEXT?)>
<!ELEMENT 3 (TEXT?)>
<!ELEMENT 4 (TEXT?)>
<!ELEMENT 9 (TEXT?)>
<!ELEMENT TEXT (#PCDATA)>
 
Your dtd

<!ELEMENT 0 (1*)>
<!ELEMENT 1 (TEXT?,2*,3*)>
<!ELEMENT 2 (TEXT?)>

Is saying that 0 contains 1s and 1 contains 2s. 0 does not have a child of 2, it only has a child of 1

Your 0 Element should be something like.

<!ELEMENT 0 (1*,2*,3*)>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top