Sample XML from XSD - bind elements between namespaces?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Tue Jan 27, 2015 5:31 pm
Sample XML from XSD - bind elements between namespaces?
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:
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!
Code: Select all
<ns1:element1>
<ns2:element1>
<ns2:element2>
<ns1:element2>
...
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!
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Sample XML from XSD - bind elements between namespaces?
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
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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Tue Jan 27, 2015 5:31 pm
Re: Sample XML from XSD - bind elements between namespaces?
Thanks for replying Adrian! Answers to your suggestions/questions: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
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>
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">
3. Super! I'll send what you requested.
Thanks again! Suggestions from others are welcome as well!
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service