Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XML-Schema: Problems with Restricted XPath in Selector of Unique

From: "Torsten Munkelt" <gttDelete_This@----------.-->
To: NULL
Date: 1/4/2007 12:09:00 PM

Hi,

I want to write an XML-schema saying that this document [1]

<root>
    <edge type="special">
        <target type="one"/>
    </edge>
    <edge type="special">
        <target type="one"/>
    </edge>
</root>

is not valid
because there must not be more than one edge-element
- with a type 'special' and
- with a target of the same type (in that case 'one').

This document [2]

<root>
    <edge type="special">
        <target type="one"/>
    </edge>
    <edge type="normal">
        <target type="one"/>
    </edge>
</root>

should be valid because there is only one edge with type special
and a target of type one.

This document [3]

<root>
    <edge type="special">
        <target type="one"/>
    </edge>
    <edge type="special">
        <target type="two"/>
    </edge>
</root>

should also be valid because there are two special edges
but they have different target types.

I try validation using this xml-schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:element name="root">
        <xs:complexType>
            <xs:sequence maxOccurs="unbounded">
                <xs:element name="edge" type="edge"/>
            </xs:sequence>
        </xs:complexType>

        <!-- WHY DOESN'T WORK THE FOLLOWING -->
        <xs:unique name="special-uniqueness">
            <xs:selector xpath="edge[@type='special']/target"/>
            <xs:field xpath="@type"/>
        </xs:unique>

    </xs:element>
    <xs:complexType name="edge">
        <xs:sequence>
            <xs:element name="target" type="target"
                minOccurs="1" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="type" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:complexType name="target">
        <xs:attribute name="type" type="xs:string" use="required"/>
    </xs:complexType>
</xs:schema>

but I do not succeed: The XPath-expression in the selector of the
unique-element below the XML-comment is not allowed in restricted
XPath syntax.

Does anybody has an idea how to write an XML-schema saying the
document one is not valid but the documents two and three are
valid (given the above criteria)?

Thank you very much for your answers in advance.

Best regards - Torsten 




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