Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xs:key effective across xi:includes?

From: "David Aldridge" <david@----------.--->
To: <xml-dev@-----.---.--->
Date: 4/25/2007 4:06:00 PM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent