cant get DTD to work

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dummy

    #1

    cant get DTD to work

    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>sunn y</weather>
    <food>I had some fish. Yummmmmmy.</food>
    <photos>http://www.floridaflor ida.org/Beach1.jpg</photos>
    </entry_date>
    <entry_date>
    <activities>Ski ing in the alps with Tilly and Minny.</activities>
    <purchases>Ne w ski goggles.</purchases>
    <weather>snow y</weather>
    <food>We ate crips and drank pop.</food>
    <photos>http://www.lasource.f9 .co.uk/images/Michael%20skiin g%201.jpg</
    photos>
    </entry_date>
    </holiday>
  • Martin Honnen

    #2
    Re: cant get DTD to work

    Dummy wrote:
    <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
    <weather>sunn y</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/

    Comment

    • Martin Honnen

      #3
      Re: cant get DTD to work

      Martin Honnen wrote:
      Dummy wrote:
      >
      > <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
      >
      >
      > <weather>sunn y</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:simpleTyp e>
      <xs:restricti on base="xs:string ">
      <xs:enumerati on value="sunny"/>
      <xs:enumerati on value="rainy"/>
      <xs:enumerati on value="cloudy"/>
      <xs:enumerati on value="snowy"/>
      </xs:restriction>
      </xs:simpleType>
      </xs:element>



      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • charlieo0@comcast.net

        #4
        Re: cant get DTD to work

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

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



        On Feb 13, 11:13 am, Martin Honnen <mahotr...@yaho o.dewrote:
        Dummy wrote:
        <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
        <weather>sunn y</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/

        Comment

        • Richard Tobin

          #5
          Re: cant get DTD to work

          In article <9691e3cc-6a45-49eb-a8b7-d9784defd646@e2 5g2000prg.googl egroups.com>,
          Dummy <liam.jmoore@gm ail.comwrote:
          > <!ATTLIST weather (sunny | rainy | cloudy | snowy) "sunny">
          ....
          > <weather>snow y</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

          Comment

          Working...