Page 1 of 1

Sample XML from XSD - bind elements between namespaces?

Posted: Tue Jan 27, 2015 11:21 pm
by DaveTM
Good day! Fairly new to Oxygen and looking for a bit of help. I'm attempting to generate sample XML from a schema XSD file using the "Generate Sample XML File.." tool. The sample XML correctly nests an element from one namespace under an element from the default. It then nests the next element under that namespace. However, the generator won't nest an element from the default namespace under that element from this other namespace. For example, I'd like the sample XML to do this:

Code: Select all

<ns1:element1>
<ns2:element1>
<ns2:element2>
<ns1:element2>
...
Instead, the generator stops at <ns2:element2></ns2:element2> even though I've indicated in the generator Options to generate XML for ANY ns1 element.

I can fill in the content manually with the editor in the generated XML that stops where I indicated and it will validate just fine. But there are a good number of further nestings under ns1:element2 that I don't want to fill in manually. If I declare what amounts to a copy of ns2:element1 as an element under ns1 within the XSD, the generator works just fine as well but this isn't how the data is supposed to be modeled. So, I'm not positive what I have to do in the XSD to bind element2 in ns1 to element2 in ns2 so the sample XML will generate the nesting properly.

Thanks for any suggestions!

Re: Sample XML from XSD - bind elements between namespaces?

Posted: Wed Jan 28, 2015 5:58 pm
by adrian
Hi,

Check in the Generate Sample XML Files dialog in the Options tab if you have enabled the "Generate optional elements" option. If there's a recursivity of the nested elements you should also increase the "Maximum recursivity level" to 2 or 3.

This can also depend on how the namespaces are connected in the schema. In ns2:element2 do you mention explicitly ns1:element1, or do you simply allow any element?
Could you please provide the snippets of the schema with the elements that connect the namespaces (ns1 -> ns2 and ns2 -> ns1).

If possible, please send your XML schemas and the exported settings from the Generate Sample XML Files dialog to support@oxygenxml.com.

Regards,
Adrian

Re: Sample XML from XSD - bind elements between namespaces?

Posted: Wed Jan 28, 2015 8:15 pm
by DaveTM
adrian wrote:Hi,

Check in the Generate Sample XML Files dialog in the Options tab if you have enabled the "Generate optional elements" option. If there's a recursivity of the nested elements you should also increase the "Maximum recursivity level" to 2 or 3.

This can also depend on how the namespaces are connected in the schema. In ns2:element2 do you mention explicitly ns1:element1, or do you simply allow any element?
Could you please provide the snippets of the schema with the elements that connect the namespaces (ns1 -> ns2 and ns2 -> ns1).

If possible, please send your XML schemas and the exported settings from the Generate Sample XML Files dialog to support@oxygenxml.com.

Regards,
Adrian
Thanks for replying Adrian! Answers to your suggestions/questions:

1. I have the recursivity set to 15 in some cases which is probably more than is needed, but wanted to ensure the Generator drilled down enough

2. This is the area I'm unsure about. Here's a snippet from the schema:

Code: Select all

<xs:element name="aircraftMeteorologicalObservation" type="wxxm:aircraftMeteorologicalObservationType" substitutionGroup="om:OM_Observation"/>
<xs:complexType name="aircraftMeteorologicalObservationType">
<xs:complexContent>
<xs:extension base="om:OM_ObservationType">
<xs:sequence>
<xs:element name="result" type="wxxm:aircraftMeteorlogicalObservationRecordPropertyType"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
So, here I'm attempting to extend the om:OM_Observation and it has a global element called "result". So when sample XML is generated, the desired outcome is to have the wxxm:aircraftMeteorlogicalObservationRecord nested under om:result. However, what's happening is that the "result" above is really wxxm:result inherited by wxxm:aircraftMeteorologicalObservation from OM_Observation:

Code: Select all

<observation>
<aircraftMeteorologicalObservation gml:id="ID003">
<om:phenomenonTime/>
<om:resultTime/>
<om:procedure xsi:nil="true"/>
<om:observedProperty/>
<om:featureOfInterest xsi:nil="true"/>
<om:result>
</om:result>
<result>
<aircraftMeteorlogicalObservationRecord gml:id="ID005">
So, not sure how to point the parent result to the child record within the schema and probably my UML as well which is where the schema is generated from. And I've tried a few different ways, with my last attempt being to include a copy of the parent and point it to the child instead of having the aircraftMeteorologicalObservation after observation. But, the generator just gave me the <om:result></om:result> instead and no aircraftMeteorlogicalObservationRecord. I just don't have it connected properly and hence my question.

3. Super! I'll send what you requested.

Thanks again! Suggestions from others are welcome as well!