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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2016)
-> + XQUF usage (3)
-> - xquery rule execution (1)
-> + Loving XQuery (3)
-> + Cross Referencing Country Name... (4)
-> + Creating a Pivot Table with xQ... (2)
-> + Error Please Help (3)
-> - Error Please Help (1)
-> + XPath descendant question (2)
-> + java/lang/OutOfMemoryError Run... (2)
-> + Xquery key value lookup (8)
-> + Improve xQuery Performance (3)
-> + MS SQL Server - Disable order ... (10)
-> + proper use of fn:distinct-valu... (2)
-> + Ignore DTD (7)
-> - Thanks Ivan (1)
-> + Trying to get 2nd value of nod... (5)
-> + Outer joins (4)
-> + Figured Out Issues From Last P... (2)
-> + Best Way To Generate Complex X... (3)
-> + count in xquery (4)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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>

   
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.