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 (1188)
- Stylus Studio Technical Forum (14588)
-> + Text symbols in SS not same as... (4)
-> + Exposing xquery as webservice ... (2)
-> + Syntax Identifier (2)
-> + Saving a Converted XML as an X... (5)
-> + Output document cannot be pars... (4)
-> - Archiving output from conversi... (1)
-> + EDIFACT guideline from Stylus ... (3)
-> + CSV file putting all the data ... (5)
-> + Can't install Home version 64b... (5)
-> + presale - Can I covers this sc... (5)
-> + Problem with UNB (5)
-> + Splitting EDIFACT files pipeli... (4)
-> + Problem with SAXO processor - ... (5)
-> + PDF Format Help (4)
-> + License check unreliable (2)
-> - XML related issue (1)
-> + Need help regarding pipeline o... (2)
-> + Error converting XML to EDIFAC... (4)
-> + XSLT Profiling for XSLT 1.0 s... (2)
-> + Grouping (2)
-- [1-20] [21-40] [41-60] Next
+ Website Feedback (247)
+ XSLT Help and Discussion (7617)
+ XQuery Help and Discussion (1971)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
lucrecia chiartanoSubject: XMLSchema - optional attributeGroup definition
Author: lucrecia chiartano
Date: 20 Jan 2005 06:53 AM


Can anyone help me to find a way to reference a group of attributes as optional?
Here I describe my problem,
thanks a lot,

Lucrecia Chiartano


I must define within a schema a rule that allows an xml leaf-node to carry with it two attributes.
Both of them may be present or not, but if only one exists it must be a precise one (attribute1 within next examples).

(Ex1 :--> allowed <node attribute1="attr1" attribute2="attr2">nodetext</node>)
(Ex2 :--> allowed <node>nodetext</node>)
(Ex3 :--> allowed <node attribute1="attr1">nodetext</node>)
(Ex4 :--> NOT allowed <node attribute2="attr2">nodetext</node>)

If 'attribute1' and 'attribute2' where just tags instead of attributes I could bound the rule defining an optional group with a required tag ('attribute1') and an optional one ('attribute2').
But they must be attributes, and I found that they can be grouped only using the xsd:attributeGroup tag that admits not a 'minOccurs' or a 'use' attribute (and then cannot be referenced as optional).

Here's the code I'm using

<xsd:element name="tagName">
<xsd:extension base="xsd:string">
<xsd:attributeGroup ref="attrGroupName"/>


<xsd:attributeGroup name="attrGroupName">
<xsd:attribute name="attr1" type="xsd:string"/>
<xsd:attribute name="attr2" type="xsd:string" use="optional"/>


Ivan PedruzziSubject: XMLSchema - optional attributeGroup definition
Author: Ivan Pedruzzi
Date: 25 Jan 2005 12:49 AM

As far as i know XML Schema is not capable to express the attribute
presence conditionalized on another attribute.

You need to use a different schema language like Schematron to do it.


siddharth srivastavSubject: XMLSchema - optional attributeGroup definition
Author: siddharth srivastav
Date: 08 May 2011 11:09 PM

Can anyone help me with the below problem:

I have to define a attribute group for 2 mutually inclusive data elements. In the below example if TO_DT is present FROM_DT has to be present and TO_DT is not present then FROM_DT is not present.

I thought of creating these as mandatory attributes and define attributegroup as optional but its not working:

<xs:attributeGroup name="DateRangeAttributes" id="Element_Common_545">
<xs:attribute name="TO_DT" type="xs:date" use="required" id="Element_Common_547"/>
<xs:attribute name="FROM_DT" type="xs:date" use="required" id="Element_Common_546"/>

Can anyone suggest a way to handle this using attributes


siddharth srivastavSubject: Advantages of using attributes over data elements
Author: siddharth srivastav
Date: 08 May 2011 11:21 PM

I am new to XML schema and currently looking for some guideline on attributes or data elements.

Please help


Ivan PedruzziSubject: Advantages of using attributes over data elements
Author: Ivan Pedruzzi
Date: 18 May 2011 02:45 AM

Attributes should be used to hold small amount of data like IDs or short strings and when the order on which they appear is not relevant.

For everything else elements are more flexible.

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.