XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Alexander BecherSubject: XSD: Structure definition depending on element or attribute value
Author: Alexander Becher
Date: 18 Nov 2011 11:52 AM
Originally Posted: 18 Nov 2011 11:50 AM
Dear support,

i want to define a structure depending on element or attribute value. F.i. following structures should be valid.

<Reply>
<RC>0</RC>
</Reply>
or
<Reply>
<RC>1</RC>
<Exception>
<ExceptioID>123</ExceptioID>
<ExceptioText>blah</ExceptionText>
</Exception>
</Reply>

It means the Substructure Exception should be only valid if the value of the Element (or alternatively Attribute) RC is "0".

I try to enable it with following.
<xs:assert test="if (@RC eq 0) then Exception else false()"/> but ASSERT isn't recognized by Stylus Studio 2011 as a valid option. Can you help me?

Thanks
StylusUser

Posttop
Ivan PedruzziSubject: XSD: Structure definition depending on element or attribute value
Author: Ivan Pedruzzi
Date: 18 Nov 2011 05:44 PM
Hi Alexander,

The Saxon schema processor is capable to validate a schema like the following, but unfortunately Stylus Studio does not enable XSD 1.1 validation. If you own a license of Saxon Enterprise Edition you will be able to use it.

As alternative you may consider to design a program in XSLT or XQuery to assert your rules.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Reply">
<xs:complexType>
<xs:sequence>
<xs:element ref="RC"/>
<xs:element ref="Exception" minOccurs="0"/>
</xs:sequence>
<xs:assert test="( RC eq '1' and count(./Exception) gt 0 ) or ( RC eq '0' and count(./Exception) = 0)"/>
</xs:complexType>
</xs:element>
<xs:element name="RC" type="xs:integer"/>
<xs:element name="Exception">
<xs:complexType>
<xs:sequence>
<xs:element ref="ExceptioID"/>
<xs:element ref="ExceptionText"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ExceptioID" type="xs:integer"/>
<xs:element name="ExceptionText" type="xs:NCName"/>
</xs:schema>

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

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