Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is this not valid ?

    Here's an excerpt from the DTD

    Code:
    <!DOCTYPE kar_trends [
    
    <!ELEMENT kar_trends (subject)*>
    <!ELEMENT subject (about,study)>
    <!ELEMENT about (#PCDATA)>
    <!ELEMENT study (#PCDATA)>
    
    <!ENTITY coi "Captains of Industry">
    
    <!ATTLIST study year CDATA #REQUIRED>
    <!ATTLIST study season CDATA #REQUIRED>
    
    ]>

    And here's a sample of the XML

    Code:
    <kar_trends>
    
    	<subject>
    		<about>3com</about>
    		<study year="1998" season="w">&coi;</study>
    	</subject>
    
    </kar_trends>

    But when I validate it I get any error message, that the STUDY element has invalid content. Huh??

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Newcastle, England
    Posts
    178
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what happens if you put #&coi; ?

    patrick

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    same thing - invalid element content

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found it! I was assuming, since the error pointed the line with that entity on it, that the entity was the issue. But no. In fact it was my fault - the DTD specifies only a single instance of <study> in each <subject>. It should have been:

    Code:
    <!ELEMENT subject (about,study+)>

    I should have posted a more complete code sample - the sample I posted actually is valid by that DTD, but what I'm actually using, which produced the error, is like this:

    Code:
    	<subject>
    		<about>3com</about>
    		<study year="1998" season="w">&coi;</study>
    		<study year="1999" season="w">&coi;</study>
    		<study year="2000" season="w">&coi;</study>
    		<study year="2000" season="w">&itp;</study>
    	</subject>
    doh thanks for the help though
    Last edited by brothercake; 11-29-2002 at 05:45 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •