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 (2017)
-> + left/right presentation (3)
-> + new to stylus - connecting to ... (2)
-> + XQuery problem with namespaces (4)
-> + .conv and xquery problem (3)
-> + Can pass text into CONV file (2)
-> + doc-available not working as e... (4)
-> + ddtekjava write to file only e... (5)
-> + arrayindexoutofbounds with ddt... (7)
-> - XSD: Structure definition depe... (2)
-> ->XSD: Structure definition...
-> + Fatal Error whitespace expecte... (3)
-> + Executing a pipeline sequence ... (2)
-> - Data Transfer (1)
-> + Specifying the SEF File Locati... (4)
-> + Multiply numbers... (2)
-> + Using Generated Java-Code... (5)
-> + Mapper does not show all nodes... (5)
-> - Xul tree search using XQuery X... (1)
-> + converting XML to CSV (2)
-> - datadirect licenses (1)
-> + generate a uuid (2)
-- Previous [61-80] [81-100] [101-120] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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.


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?


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:element ref="RC"/>
<xs:element ref="Exception" minOccurs="0"/>
<xs:assert test="( RC eq '1' and count(./Exception) gt 0 ) or ( RC eq '0' and count(./Exception) = 0)"/>
<xs:element name="RC" type="xs:integer"/>
<xs:element name="Exception">
<xs:element ref="ExceptioID"/>
<xs:element ref="ExceptionText"/>
<xs:element name="ExceptioID" type="xs:integer"/>
<xs:element name="ExceptionText" type="xs:NCName"/>

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!  

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.