Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 10th, 2013, 04:07 AM
Authorized User
Points: 108, Level: 2
Points: 108, Level: 2 Points: 108, Level: 2 Points: 108, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2006
Location: , , United Kingdom.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSD Optional Attributes

I've had a look around but can't find anything positive, so assuming it can't be done, but just in case!

I need an XSD to have pairs of attributes that one needs to be specified. For example the XML has to contain either a code or a name (or both), i.e. either DeptCode="HR" or DeptName="Human Resources"

Any help (positive or negative) appreciated
Nigel
  #2 (permalink)  
Old September 10th, 2013, 04:17 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Can't be done in XSD 1.0. Can be done in XSD 1.1, e.g. through Conditional Type Assignment or through assertions. XSD 1.1 is currently implemented only in Saxon and Xerces.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
  #3 (permalink)  
Old September 10th, 2013, 06:26 AM
Authorized User
Points: 108, Level: 2
Points: 108, Level: 2 Points: 108, Level: 2 Points: 108, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2006
Location: , , United Kingdom.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers Michael - stuck with 1.0 unfortunately.


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to declare some elements as optional in xsd. pavanibiji XML 3 January 4th, 2012 06:21 PM
How do we include the namespace and xsd as attributes to the tag anarleti XSLT 5 July 8th, 2010 08:14 AM
XSD.EXE Gen’d C# Deserializing w/ .xsd Subst Group greenstone XML 0 November 9th, 2007 09:27 PM
how to control optional elements and attributes NEO1976 XSLT 5 September 4th, 2006 02:58 AM
making records optional in an XSD cmiller66 XML 2 August 29th, 2006 08:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.