[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSD 1.1 assertions are a great mistery for me

  • From: Michael Kay <mike@saxonica.com>
  • To: cmarchand@oxiane.com
  • Date: Wed, 29 Mar 2017 14:36:22 +0100

Re:  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

> 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]


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.