Generate xsd from two xml events with different children
This should cover W3C XML Schema, Relax NG and DTD related problems.
Generate xsd from two xml events with different children
I have the following two different xml events that I get:
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipCreate device="24"/>
</ip>
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipDelete device="24"/>
</ip>
The <ip> element can have either <ipCreate> or <ipDelete> sub element, but not both. I've tried to combine both xml events into one file and tried to generate an xsd for them, but I get an error that is not mell-formed. Is there a way to generate one xsd file for both events?
Thanks,
tsbasha
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipCreate device="24"/>
</ip>
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipDelete device="24"/>
</ip>
The <ip> element can have either <ipCreate> or <ipDelete> sub element, but not both. I've tried to combine both xml events into one file and tried to generate an xsd for them, but I get an error that is not mell-formed. Is there a way to generate one xsd file for both events?
Thanks,
tsbasha
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Generate xsd from two xml events with different children
Post by sorin_ristache »
Hello,
Create a file on disk event1.xml with the content:
and a file event2.xml with the content:
Go to menu Tools -> Trang Converter, select XML Documents in the Input panel, press the Add button and add the files event1.xml and event2.xml to the file list, select W3C XML Schema in the Output panel, select the output file name, press the Convert button. The result XML Schema will define a root element ip with a choice content model like the following which means that an element ip can contain either an element ipCreate or an element ipDelete:
Regards,
Sorin
Create a file on disk event1.xml with the content:
Code: Select all
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipCreate device="24"/>
</ip>
Code: Select all
<ip ipAddress="1.1.1.1" timestamp="2008/05/13 16:57:13.870197">
<ipDelete device="24"/>
</ip>
Code: Select all
<xs:element name="ip">
<xs:complexType>
<xs:choice>
<xs:element ref="ipCreate"/>
<xs:element ref="ipDelete"/>
</xs:choice>
<xs:attribute name="ipAddress" use="required" type="xs:NMTOKEN"/>
<xs:attribute name="timestamp" use="required"/>
</xs:complexType>
</xs:element>
Sorin
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