Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > cant get DTD to work

Reply
Thread Tools

cant get DTD to work

 
 
Dummy
Guest
Posts: n/a
 
      02-13-2008
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>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-13-2008
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/
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-13-2008
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/
 
Reply With Quote
 
charlieo0@comcast.net
Guest
Posts: n/a
 
      02-13-2008
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 <(E-Mail Removed)> 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/

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      02-13-2008
In article <(E-Mail Removed)>,
Dummy <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
XML file from one DTD to another DTD test Java 2 07-28-2006 08:48 PM
How to specify DTD to DTD.getDTD for DocumentParser? Ronald Fischer Java 4 03-17-2005 09:37 AM
Removing the dtd name when using print(...) on the dtd generated class Joseph Tilian Java 0 12-21-2004 02:58 PM
Including a dtd into another dtd... possible? Asfand Yar Qazi XML 1 09-19-2003 12:10 PM



Advertisments