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

XSD 1.1 assertions are a great mistery for me

  • From: cmarchand@oxiane.com
  • To: xml-dev@lists.xml.org
  • Date: Wed, 29 Mar 2017 15:20:45 +0200

XSD 1.1 assertions are a great mistery for me
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:element name="data">
<xs:sequence maxOccurs="unbounded">
<xs:element name="param" type="TParam"/>

<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"/>

And this file :

<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<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 -->

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 !


[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.