This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

schema validation

 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using this e.g. from Roger L. Costello ppt presentation:

I have a dtd as below:

<!ELEMENT life ((work, eat)*, (work|play), sleep)*>
<!ELEMENT work (#PCDATA)>
<!ELEMENT eat (#PCDATA)>
<!ELEMENT play (#PCDATA)>
<!ELEMENT sleep (#PCDATA)>

The corresonding XSD is

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.life.org"
xmlns="http://www.life.org"
elementFormDefault="qualified">
<xsd:element name="life">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="work" type="xsd:string"/>
<xsd:element name="eat" type="xsd:string"/>
</xsd:sequence>
<xsd:choice>
<xsd:element name="work" type="xsd:string"/>
<xsd:element name="play" type="xsd:string"/>
</xsd:choice>
<xsd:element name="sleep" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


I tried to validate this using XML Spy. I get an error:

" The schema doesn't appear valid...
<xsd:element name="work"/> makes content model non-determinstic..."
Any idea why this is invalid.
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vasim Patel:
I am using this e.g. from Roger L. Costello ppt presentation:

I have a dtd as below:

<!ELEMENT life ((work, eat)*, (work|play), sleep)*>


Dosent make any sense

(work, eat)* --> says that life can contain work and eat definitions 0 or more times


(work|play) --> says that life can contain either work or play element !! and they can occur ony once

If you are using "|", it indicates that you want only EITHER of the element to be present under the parent element. But you have also said that one of this elemnt can be present 0..multiple times already in the data model !

A bad data model as they both contradict each other or overlap each other!!

If u said that you wanted either work or play to occur multiple times, the dat model should be

life ((work|play), eat)*, sleep)*



But waht if the requirement is : either work or play can occur. but if work occurs it should be able to occur multiple times, but if play occurs it should occur only once ?

mabe this will satiusfy that ?

<!ELEMENT life (((work*|play), eat*), sleep)*>

And i am sure taht you can write teh schema for this now here is my shot at it !



please check the solution and let me know if something is wrong

HTH

hari
 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hari
Thanks for clarification. I agree there is a contradiction

Lets remove sleep for convenience..the DTD is
<!ELEMENT life ((work, eat)*, (work|play))*>

According to this DTD, the following combination shld be possible

<life>
<work> i am at work2</work>
<eat> i am at eat</eat>
<work> i am at work2</work>
</life>

this is not possible because the (work, eat) should be in sequence.
Thanks again.
Currently I am using Whizlab sim , i must say it is good.
 
Hari Vignesh Padmanaban
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vasim Patel:
Hi Hari
Thanks for clarification. I agree there is a contradiction

Lets remove sleep for convenience..the DTD is
<!ELEMENT life ((work, eat)*, (work|play))*>



Hey vasim, its teh same problem again

You are trying to define the same work element twice as part of a life element.

Originally posted by hari:

If you are using "|", it indicates that you want only EITHER of the element to be present under the parent element. But you have also said that one of this elemnt can be present 0..multiple times already in the data model !


hth
hari
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic