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 August 28th, 2006, 07:31 PM
Registered User
Join Date: Aug 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default making records optional in an XSD

I am building a schema that has the following format:

unique Row 1
Optional (repeating) Row 2
Optional (repeating) Row 3
Optional (repeating) Row 4
Optional (repeating) Row 5
Optional (repeating) Row 6

I need to setup my XSD so that if Rows 2, 3 and 5 have values and 4 doesn't, the XML file will only show the following:


I have set the minOccurs to 0 for Row 4 but when the the schema runs and the XML file gets rendered with no value for row 4 it looks like the following:


Row 4 should be out of the of the XML and row 5 and 6 should have the correct values.

Does anyone have any ideas on how to solve this issue?

I can post the XSD if necessary. Thanks.

  #2 (permalink)  
Old August 29th, 2006, 06:02 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

You've missed something out. You talk about how the XML file "will show" or how it "gets rendered". But that doesn't depend on the schema. The schema can define an element as optional, but whether it's actually present in an XML instance or not depends on the software that creates the instance.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
  #3 (permalink)  
Old August 29th, 2006, 08:56 AM
Registered User
Join Date: Aug 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for the response. Sorry I wasn't more clear in my original post.

I was able to find the issue and fix it. I was able to change my incoming files that would be transformed by the schema to have the proper formatting.

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
Optional prameters and C#? NewTitle2007 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 August 5th, 2007 12:17 PM
Argument not Optional aziaraphale Excel VBA 5 August 1st, 2007 02:53 AM
Merging XSD files in one XSD file by using what? haoxuqian XML 1 November 4th, 2005 01:42 PM
Optional WHERE clause in sproc KYC SQL Language 2 February 17th, 2004 03:40 PM

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