Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

schema validation

 
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.
 
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
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic