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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just a quick newbie question, plz help me out!

Status
Not open for further replies.

virg

IS-IT--Management
Oct 1, 2002
3
US
here is the source of my test.xml

<?xml version=&quot;1.0&quot;?>
<!DOCTYPE cars [
<!ELEMENT car (brand, type) >
<!ELEMENT brand (#PCDATA) >
<!ELEMENT type (#PCDATA) >
]>

<car>
<brand>sad</brand>
<brand>asd</brand>
</car>

shouldnt i get an error because the brand is put in twice now? same goes for when i use #REQUIRED, when
i leave it empty, it still wont show any errors
 
OK I just ran your code through XML SPY and get an error as your DOCTYPE was &quot;cars&quot; and not &quot;car&quot;

here is the code now
(this works)
<?xml version=&quot;1.0&quot;?>
<!DOCTYPE car [
<!ELEMENT car (brand,type)>
<!ELEMENT brand (#PCDATA)>
<!ELEMENT type (#PCDATA)>
]>
<car>
<brand>t</brand>
<type>t</type>
</car>

(this does NOT)
<?xml version=&quot;1.0&quot;?>
<!DOCTYPE car [
<!ELEMENT car (brand,type)>
<!ELEMENT brand (#PCDATA)>
<!ELEMENT type (#PCDATA)>
]>
<car>
<brand>t</brand>
<brand>ty</brand>
<type>t</type>
</car>

Hope this helps, I am pretty new to XML so I hope I am right (maybe one of the more exprienced people will correct me though)

Tom Crosswell

 
ah thanks, just a stupid typo, but it still leaves my last question unanswered, i can still put in two brands..

<?xml version=&quot;1.0&quot;?>
<!DOCTYPE car [
<!ELEMENT car (brand,type)>
<!ELEMENT brand (#PCDATA)>
<!ELEMENT type (#PCDATA)>
]>
<car>
<brand>t</brand>
<brand>t</brand>
<type>t</type>
</car>

no error, shouldnt it give an error? like brand can only be used once?
 
I tried it out in XML spy and it game me an error. So I am not sure why you don't get it!
I then tried:
<?xml version=&quot;1.0&quot;?>
<!DOCTYPE car [
<!ELEMENT car (brand+,type)>
<!ELEMENT brand (#PCDATA)>
<!ELEMENT type (#PCDATA)>
]>
<car>
<brand>t</brand>
<brand>t</brand>
<type>t</type>
</car>

And that let it throught OK (as it should) no idea why it is not working correctly for you as it is for me!

Tom Crosswell
 
but i mean, shouldnt it give an error? cuz brand can only be used once right??
 
No, because you basically make XML up as you go along, you can use it as many times as you want. Its in your dtd or schema where you will say if it can be used more than once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top