W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2015

Xpath result vs. xs:assert result

From: Timothy W. Cook <tim@mlhim.org>
Date: Thu, 19 Mar 2015 14:15:55 -0300
Message-ID: <CA+=OU3VjaOvwV7GHNrk2tWCz8=hbLS_KftLEN0STtNDnafaPjA@mail.gmail.com>
To: XMLSchema-dev <xmlschema-dev@w3.org>
I am using oXygen XML Editor 16.1 using SaxonEE set for XML Schema 1.1 for
these tests.


I want to insure that elements in a complexType that is a restriction of a
base complexType, have the same number of enumerations. (Code below)

The sample complexType (bottom of email) should fail this assert:

<xs:assert test="count(//xs:element[@name='id-name']//xs:enumeration) eq
count(//xs:element[@name='issuer']//xs:enumeration)
and
count(//xs:element[@name='issuer']//xs:enumeration) eq
count(//xs:element[@name='assignor']//xs:enumeration)"></xs:assert>

because assignor has three enumerations and the other elements have two.
Whether I put this in the base complexType or the restricted complexType it
still shows the restriction as a valid schema.

If I execute this

count(//xs:element[@name='id-name']//xs:enumeration) eq
count(//xs:element[@name='issuer']//xs:enumeration) and
count(//xs:element[@name='issuer']//xs:enumeration) eq
count(//xs:element[@name='assignor']//xs:enumeration)

in the XPath editor it fails
​ (returns false)​
as expected as well as passes
​(returns true) ​
when all three have two enumerations.


Sample restriction:

 <xs:complexType name='mytype' xml:lang='en-US'>
    <xs:complexContent>
      <xs:restriction base='myBaseType'>
        <xs:sequence>
            <xs:element maxOccurs='1' minOccurs='1' name='id-name'>
              <xs:simpleType>
                <xs:restriction base='xs:string'>
                  <xs:enumeration value='URI'></xs:enumeration>
                  <xs:enumeration value='ID Number'></xs:enumeration>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
            <xs:element maxOccurs='1' minOccurs='1' name='issuer'>
              <xs:simpleType>
                <xs:restriction base='xs:string'>
                  <xs:enumeration value='Owner'/>
                  <xs:enumeration value='Owner'/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
            <xs:element maxOccurs='1' minOccurs='1' name='assignor'>
              <xs:simpleType>
                <xs:restriction base='xs:string'>
                  <xs:enumeration value='Owner'/>
                  <xs:enumeration value='Owner'/>
                  <xs:enumeration value='Owner'/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
          </xs:sequence>
        </xs:restriction>
      </xs:complexContent>
    </xs:complexType>

What am I missing? Can't I establish asserts on a restriction complexType
or do asserts only get evaluated for instance data?

Thanks,
Tim





============================================
Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org
Received on Thursday, 19 March 2015 17:16:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:08 UTC