XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Quiz: what's the value space of the <Publisher> element?

> 
> Consider this element declaration:
> 
>     <xs:element name="Publisher" type="xs:string"/>
> 
> What is Publisher's value space? 

Technically, an element does not have a value space. Only a type has a value
space. The value space here is clearly the set of all (legal XML) strings.
> 
> 
> The Publisher element is being used by Book:
> 
> 
>     <xs:element name="Book">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="Title" type="xs:string"/>
>                 <xs:element name="Author" type="xs:string"/>
>                 <xs:element name="Date" type="xs:gYear"/>
>                 <xs:element name="ISBN" type="xs:string"/>
>                 <xs:element ref="Publisher" />
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
> 
> 
> Okay, what is Publisher's value space?

Again, wrong terminology. But the set of things that can appear within a
Publisher that appears within a Book is potentially constrained both by the
type of the Book element and by the type of the Publisher element.

> 
> XML Schema 1.1 has a new element, the <assert> element. It 
> can impose additional constraints on the Publisher element. 
> For example, the <Book> element is nested within a 
> <BarnesAndNoble> element, which has an <assert> element that 
> constrains the Publisher element to a maximum string length 
> of 140 characters:
> 
> 
>     <xs:element name="BarnesAndNoble">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element ref="Book" maxOccurs="unbounded" />
>             </xs:sequence>
>             <xs:assert 
> test="not(Book[string-length(Publisher) gt 140])" />
>         </xs:complexType>
>     </xs:element>
>

Nothing new here: you could also use key/keyref at the level of a Book to
constrain what can appear in the Publisher element.
> 
> What this means is that an element declaration cannot be 
> understood on its own, in isolation. 
> 
> To understand an element you must understand all possible 
> ancestors of the element. 
> 

Not really. The system is designed so that the set of valid Publisher
elements is determined by the type of the Publisher element; but if you want
to say that not all valid values of Publisher are allowed when the Publisher
is a book publisher, then you can do so. For example, you might have some
way of excluding magazine publishers.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS