|
next
|
 Subject: XML Schema to XML producing invalid document Author: Patterson Waltz Date: 17 Jun 2008 02:56 PM Originally Posted: 17 Jun 2008 02:55 PM
|
Hello,
I'm using Stylus Studio to generate sample XML files based on an XSD I've created, and the files it produces then fail to validate against the same XSD. Thus far, I can't determine if it's my XSD which is misusing some portion of the Schema specification or if it's due to a Stylus bug.
The section of the XSD which proves problematic is structured like this:
<xs:complexType name="Drawing">
<xs:sequence>
<xs:element name="drawingType" type="xs:string"/>
<xs:choice maxOccurs="1">
<xs:sequence>
<xs:element name="drawingFirstDrawingDate" type="xs:date"/>
<xs:element name="drawingFrequency" type="xs:string"/>
<xs:element name="drawingCount" type="xs:int"/>
<xs:element name="drawingEndDate" type="xs:date"/>
</xs:sequence>
<xs:element name="drawingSchedule" type="AmountScheduleElement" maxOccurs="unbounded" />
</xs:choice>
<xs:element name="drawingInterest" type="Interest" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="drawingTenor" type="Tenor"/>
</xs:sequence>
</xs:complexType>
For choices and substitution groups, I have configured Stylus to "Generate all; all except first instance are commented"
In the resulting XML file, I get:
<facilityDrawingParameters>
<drawingType>string</drawingType><!--
<drawingFirstDrawingDate>1999-01-21</drawingFirstDrawingDate>
<drawingFrequency>string</drawingFrequency>
<drawingCount>-2147483648</drawingCount>
<drawingEndDate>1999-01-21</drawingEndDate>--><!--
<!--Element drawingSchedule, maxOccurs=unbounded-->
<drawingSchedule date="1999-01-21">
<value>
<amount>
<nominal>1.23</nominal>
<currency>string</currency>
</amount><!--
<rate>0</rate>-->
</value>
</drawingSchedule>
...-->
<!--Element drawingInterest is optional, maxOccurs=unbounded-->
<drawingInterest>
...
</drawingInterest>
<drawingInterest>
...
</drawingInterest>
<drawingInterest>
...
</drawingInterest>
<drawingTenor>
...
</drawingTenor>
</facilityDrawingParameters>
(ellipses ... used to remove content not pertinent to this question)
Stylus complains appropriately, upon validation of this XML, that:
Element 'drawingInterest' is not valid for content model: '((drawingType,(((drawingFirstDrawingDate,drawingFrequency,drawingCount),drawingEndDate)|drawingSchedule),drawingInterest),drawingTenor)'
Shouldn't Stylus be omitting the comment marks which enclose the first sequence of four elements generated after the drawingType element, based on my settings? If I manually remove the comment marks, the document validates properly.
Thanks in advance for any assistance you can provide.
Patterson
|
|
|
|