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)
-> - Issue with Processing Instruct... (1)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [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.