cant get DTD to work

Discussion in 'XML' started by Dummy, Feb 13, 2008.

  1. Dummy

    Dummy Guest

    Hey there, I'm trying to get my DTD to work with some content, just
    wondering if someone could take a look at it for me and see where im
    going wrong. Thanks,

    <?xml version="1.0"?>
    <!DOCTYPE holiday [
    <!ELEMENT holiday (entry_date+)>
    <!ELEMENT entry_date (activities?, purchases, weather, food?,
    photos*)>
    <!ELEMENT activities (#PCDATA)>
    <!ELEMENT purchases (#PCDATA)>
    <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
    <!ELEMENT photos (#PCDATA)>
    <!ELEMENT food (#PCDATA)>
    ]>

    <holiday>
    <entry_date>
    <activities>I went to the beech. It was super fun.</activities>
    <purchases>I bought some new clothes at a stall.</purchases>
    <weather>sunny</weather>
    <food>I had some fish. Yummmmmmy.</food>
    <photos>http://www.floridaflorida.org/Beach1.jpg</photos>
    </entry_date>
    <entry_date>
    <activities>Skiing in the alps with Tilly and Minny.</activities>
    <purchases>New ski goggles.</purchases>
    <weather>snowy</weather>
    <food>We ate crips and drank pop.</food>
    <photos>http://www.lasource.f9.co.uk/images/Michael%20skiing%201.jpg</
    photos>
    </entry_date>
    </holiday>
     
    Dummy, Feb 13, 2008
    #1
    1. Advertising

  2. Dummy wrote:

    > <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">



    > <weather>sunny</weather>


    I think you want
    <!ATTLIST weather
    type (sunny | rainy | cloudy | snowy) "sunny")>

    <wheather type="sunny"/>

    Or give the entry-date element an attribute named wheather-type.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 13, 2008
    #2
    1. Advertising

  3. Martin Honnen wrote:
    > Dummy wrote:
    >
    >> <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">

    >
    >
    >> <weather>sunny</weather>


    You might also want to switch the W3C XSD schemas instead of DTDs as the
    schema language allows you to enumerate the possible values of
    attributes as well as of elements
    <xs:element name="wheather">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:enumeration value="sunny"/>
    <xs:enumeration value="rainy"/>
    <xs:enumeration value="cloudy"/>
    <xs:enumeration value="snowy"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 13, 2008
    #3
  4. Dummy

    Guest

    Your problem is that you never declared the "weather" element.

    You have <!ATTLIST weather> but nowhere do you have <!ELEMENT weather>



    On Feb 13, 11:13 am, Martin Honnen <> wrote:
    > Dummy wrote:
    > > <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
    > > <weather>sunny</weather>

    >
    > I think you want
    > <!ATTLIST weather
    > type (sunny | rainy | cloudy | snowy) "sunny")>
    >
    > <wheather type="sunny"/>
    >
    > Or give the entry-date element an attribute named wheather-type.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    , Feb 13, 2008
    #4
  5. In article <>,
    Dummy <> wrote:

    > <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">

    ....
    > <weather>snowy</weather>


    ATTLIST is for declaring attributes, not elements. DTDs don't have
    any way of listing the possible values for the text content of an
    element.

    -- Richard
    --
    :wq
     
    Richard Tobin, Feb 13, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Schafer
    Replies:
    1
    Views:
    551
    Joe Smith
    Apr 23, 2004
  2. Joseph Tilian
    Replies:
    0
    Views:
    379
    Joseph Tilian
    Dec 21, 2004
  3. Ronald Fischer
    Replies:
    4
    Views:
    1,806
    Ronald Fischer
    Mar 17, 2005
  4. test
    Replies:
    2
    Views:
    2,181
    Oliver Wong
    Jul 28, 2006
  5. Nagaraj
    Replies:
    1
    Views:
    917
    Lionel B
    Mar 1, 2007
Loading...

Share This Page