|
Subject:
|
making records optional in an XSD
|
|
Posted By:
|
cmiller66
|
Post Date:
|
8/28/2006 7:31:16 PM
|
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:
<root> <Row1/> <Row2/> <Row3/> <Row5/> <Row6/> </root>
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:
<root> <Row1>Value1</Row1> <Row2>Value2</Row2> <Row3>Value3</Row3> <Row4>Value5</Row4> <Row5>Value6</Row5> </root>
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.
|
|
Reply By:
|
mhkay
|
Reply Date:
|
8/29/2006 6:02:07 AM
|
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 http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
cmiller66
|
Reply Date:
|
8/29/2006 8:56:51 AM
|
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.
|