[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xs:key effective across xi:includes?

  • From: "Michael Kay" <mike@s...>
  • To: "'David Aldridge'" <david@t...>,<xml-dev@l...>
  • Date: Wed, 25 Apr 2007 17:39:38 +0100

RE:  xs:key effective across xi:includes?
Yes, this is possible provided you arrange your processing pipeline to do
XInclude processing before you do schema validation. How you achieve that
depends on your tools and APIs.

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

> -----Original Message-----
> From: David Aldridge [mailto:david@t...] 
> Sent: 25 April 2007 17:06
> To: xml-dev@l...
> Subject:  xs:key effective across xi:includes?
> 
> I don't know if what I want to do is possible or not, but I'd 
> like to have an xs:key in my schema that constrains 
> attributes both directly in a document, as well as those in 
> another document included in the first.
> Here's an example of what I'm trying to say:
> 
> FooList.xsd: 
> ================
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>   xmlns:xi="http://www.w3.org/2001/XInclude" 
>   xmlns:FooList="http://www.somecompany.com/FooList" 
>   targetNamespace="http://www.somecompany.com/FooList" 
>   xmlns="http://www.trionworld.com" elementFormDefault="qualified">
>   <xs:import namespace="http://www.w3.org/2001/XInclude" 
>     schemaLocation="http://www.w3.org/2001/XInclude.xsd"/>
>   <!--
>     Range-limited data type for 'Bar' attributes on 'Foo's.  
> An xs:key will
>     constrain the value to be unique (can you extend/restrict xs:ID to
>     specify both min and max? ...).
>   -->
>   <xs:simpleType name="BarAttr">
>     <xs:restriction base="xs:nonNegativeInteger">
>       <xs:minExclusive value="0"/>
>       <xs:maxInclusive value="65535"/>
>     </xs:restriction>
>   </xs:simpleType>
>   <xs:complexType name="Foo">
>     <xs:attribute name="Bar" type="FooList:BarAttr" use="required"/>
>   </xs:complexType>
>   <xs:element name="FooList">
>     <xs:complexType>
>       <xs:sequence minOccurs="0">
>         <xs:element ref="xi:include" minOccurs="0" 
> maxOccurs="unbounded"/>
>         <xs:element name="Foo" type="FooList:Foo" minOccurs="0"
> maxOccurs="unbounded"/>
>       </xs:sequence>
>     </xs:complexType>
>     <xs:key name="PK_FooBar">
>       <xs:selector xpath="FooList:Foo"/>
>       <xs:field xpath="@Bar"/>
>     </xs:key>
>   </xs:element>
> </xs:schema> 
> 
> FooListA.xml
> ==========
> <?xml version="1.0" encoding="UTF-8"?>
> <FooList xmlns="http://www.somecompany.com/FooList" 
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>   xsi:schemaLocation="http://www.somecompany.com/FooList FooList.xsd">
>   <Foo Bar="1"/>
>   <Foo Bar="2"/>
> </FooList> 
> 
> FooListB.xml
> ==========
> <?xml version="1.0" encoding="UTF-8"?>
> <FooList xmlns="http://www.somecompany.com/FooList" 
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>   xsi:schemaLocation="http://www.somecompany.com/FooList FooList.xsd">
>   <include xmlns="http://www.w3.org/2001/XInclude" href="FooListA.xml"
> xpointer="FooList:FooList"/>
>   <Foo Bar="1"/>
>   <Foo Bar="2"/>
> </FooList> 
> 
> 
> Essentially, I would like validation of FooListB.xml to fail, 
> given that it has 'Bar' attribute values which conflict with 
> those in FooListA.xml (assuming my include directive is 
> correct...?).  I'm basically trying to "merge" document 
> fragments into a master document and have the key constraint 
> be useful.
> 
> Is this possible?
>  
> Cheers,
> -David 
> 
> 
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l...
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 



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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.