Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
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
 
Old April 26th, 2006, 04:08 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsd question

hello

I have a few Questions:

1. is there a way to make element optional?

2. I am writing this line:
     <xs:element name="etd">
and I want to give an option that the element will be ok either in the xml file it will be written "etd" or "ETD". how can I do it?

thank you
kfir

 
Old April 26th, 2006, 05:01 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

1. Use minOccurs="0"

2. Use
   <xs:choice>
     <xs:element name="etd"/>
     <xs:element name="ETD"/>
   </xs:choice>

but this seems like a very poor design - XML is case-sensitive, and by allowing both you are making extra work for everyone who has to process the XML document.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 4th, 2006, 12:30 AM
Authorized User
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kfir
Default

how do I make complex type optional?

kfir
 
Old May 4th, 2006, 03:14 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The elements and attributes within a complex type can be optional, but the type itself can't (it doesn't make sense). To make an element optional, use minOccurs="0". To make an attribute optional, write use="optional".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD.EXE Gen’d C# Deserializing w/ .xsd Subst Group greenstone XML 0 November 9th, 2007 09:27 PM
XSD JonDeNoitaly BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 May 7th, 2007 08:32 AM
Help in .XSD format .... software_developer_kk XML 3 May 31st, 2006 02:54 PM
Merging XSD files in one XSD file by using what? haoxuqian XML 1 November 4th, 2005 01:42 PM
xsd error tkr XML 0 July 8th, 2003 04:03 PM





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