xs:key effective across xi:includes?

Discussion in 'XML' started by daldridge@gmail.com, Apr 18, 2007.

  1. Guest

    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 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
     
    , Apr 18, 2007
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Bongiorno

    custom key and hasmap using a ranged key

    Christian Bongiorno, Jun 15, 2004, in forum: Java
    Replies:
    1
    Views:
    562
    Roedy Green
    Jun 15, 2004
  2. Patrick Guio
    Replies:
    6
    Views:
    3,531
    chris
    Oct 20, 2004
  3. shyam
    Replies:
    8
    Views:
    662
    Priscilla Walmsley
    Jun 21, 2006
  4. Florian Lindner

    key - key pairs

    Florian Lindner, Jun 23, 2005, in forum: Python
    Replies:
    8
    Views:
    800
    Paul McGuire
    Jun 24, 2005
  5. Anon
    Replies:
    0
    Views:
    1,548
  6. Mize-ze
    Replies:
    4
    Views:
    725
    Robert Klemme
    Jan 1, 2007
  7. Markus Dehmann

    key-value pairs: key consists of 3 ints

    Markus Dehmann, Jan 15, 2006, in forum: C++
    Replies:
    13
    Views:
    827
    Richard Herring
    Jan 23, 2006
  8. M P
    Replies:
    1
    Views:
    828
Loading...