• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DTD...declaring an element which has child elements and PCDATA

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is my xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE person SYSTEM "test.dtd">
<?xml-stylesheet type="text/xsl" href="test1.xsl"?>
<person>
<id number="33432">
<name>shoba</name>
<address>
<street>nowhere</street>
<city>nocity</city>
<zip>77056</zip>
</address>
<address>
<street>nostreet</street>
<city>nocity</city>
</address>
</id>
<id number="766665" dept="ee" perid="890">
<name>shoba1</name>
<address>
<street>nostreet1</street>
<city>nocity1</city>
<zip>889909</zip>
</address>
<address>
<street>nostreet1</street>
<city>nocity1</city>
</address>
</id>
</person>
and this is my dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY manager "Shoba">
<!ELEMENT person (id+)>
<!ELEMENT id (name, address+)>
<!ATTLIST id
number CDATA #IMPLIED
dept (2it | ec | ee) #IMPLIED
hod ENTITY #IMPLIED
perid CDATA #FIXED "890"
>
<!ELEMENT name (#PCDATA)>
<!ELEMENT address (street, city, zip?)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
If I want to make the <id> element node to have both child element nodes and text node, how do i declare that in dtd.
If I change in DTD as follows...throws error.
<!ELEMENT id (name, address+)> to
<!ELEMENT id (name, address+)(#PCDATA)>
How do I do this kind of stuff?
Thanks
Shoba
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this will work for Mixed content
<!ELEMENT id (#PCDATA|name| address)*>
 
Shoba Ramachandran
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But Gopiraj, then it would allow zero or more number of names and addresses. I don't want that..I need that <id> has one <name> and one or more <address> and a text. How to do this?
Thanks
Shoba
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shoba,
I don't think u can do that with DTD. That is one of the disadvantage of DTD over Schemas.
Thanks,-PC RE
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link should clear things up:
http://www.w3.org/TR/2000/REC-xml-20001006#NT-Mixed
In cases of Mixed content, child elements may be constrained but not their order or number of occurances....
That's why we like schemas!
Dan'l
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic