XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XSD 1.1 assertions are a great mistery for me

I suspect you have overlooked that the data model supplied as input to the assertions is in effect the result of applying validation using everything in the schema except the assertions. In consequence, the fixed value of the @abstract attribute will be expanded, so tests like exists(@abstract) will always be true.

Michael Kay
Saxonica

> On 29 Mar 2017, at 14:20, cmarchand@oxiane.com wrote:
> 
> Hello !
> 
> I want to define a complex type that represents a parameter.
> A parameter MUST have a @name
> A parameter MAY have a @as
> A parameter has either a @value, or a @abstract
> A parameter that has a @abstract MUST have @as
> 
> I've defined this :
> 
> <xs:schema
>  xmlns:xs="http://www.w3.org/2001/XMLSchema";
>  xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning";
>  elementFormDefault="qualified"
>  attributeFormDefault="unqualified"
>  vc:minVersion="1.1">
> 
>  <xs:element name="data">
>    <xs:complexType>
>      <xs:sequence maxOccurs="unbounded">
>        <xs:element name="param" type="TParam"/>
>      </xs:sequence>
>    </xs:complexType>
>  </xs:element>
> 
>  <xs:complexType name="TParam">
>    <xs:attribute name="name" type="xs:string" use="required"/>
>    <xs:attribute name="as" type="xs:string" use="optional"/>
>    <xs:attribute name="value" type="xs:string" use="optional"/>
>    <xs:attribute name="abstract" fixed="true" use="optional" />
>    <xs:assert test="count(@value | @abstract) eq 1" id="assert1"/>
>    <xs:assert test="if(exists(@abstract)) then exists(@as) else true()" id="assert2"/>
>  </xs:complexType>
> </xs:schema>
> 
> And this file :
> 
> <data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:noNamespaceSchemaLocation="param.xsd">
>  <param name="p1" />                               <!-- should fail assert1 -->
>  <param name="p2" value="v2"/>                     <!-- should be valid -->
>  <param name="p3" value="v3" as="xs:string"/>      <!-- should be valid -->
>  <param name="p4" as="xs:string" abstract="true"/> <!-- should be valid -->
>  <param name="p5" abstract="true"/>                <!-- should fail assert2 -->
>  <param name="p6" abstract="true" value="v6"/>     <!-- should fail assert2 -->
> </data>
> 
> All param except p4 are invalid.
> p1 fails assert2
> p2 fails assert1 & assert2
> p3 fails assert2
> p4 is valid
> p5 fails assert2
> p6 fails assert1 & assert2
> 
> I do not know what I miss... Any help will be much appreciated !
> 
> Best,
> Christophe
> 
> _______________________________________________________________________
> 
> 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@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> 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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS