java - XML Schema for collection or array containing basic parameters along with other collections or arrays -
i need write xml schema allow production of xml file needs in specific format. hope use , xml schema along jaxb create data object, write data object, , marshal data object correctly formed xml.
unfortunately, there not exist schema xml document, being read legacy code in manual way. goal create xml schema allow jaxb marshal in specific way.
i having problem named collections or arrays. have few variation on , complicated version below.
note have no control on target desired format of xml, need discover how dictate schema produce this. , suggestions very, helpful , promise, xml schema experts, if helps me absolute favorite person of week!
here target format this:
<betainfo name="beta id" value="1"> <simplebetainfo> <param name="simple beta a" value="beta id 1, param data"/> <param name="simple beta b" value="beta id 1, param b data"/> </simplebetainfo> <listbetainfo name="list id" value="1"> <param name="item 1" value="beta id 1, list index 1, item 1 data"/> <param name="item 2" value="beta id 1, list index 1, item 2 data"/> </listbetainfo> <listbetainfo name="list id" value="2"> <param name="item 1" value="beta id 1, list index 2, item 1 data"/> <param name="item 2" value="beta id 1, list index 2, item 2 data"/> </listbetainfo> </betainfo>
this might starting point. describes structure of instance provided, , can adjust support occurrences of child elements.
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified"> <xs:attributegroup name="commonattributes"> <xs:attribute name="name" type="xs:string"/> <xs:attribute name="value" type="xs:string"/> </xs:attributegroup> <xs:element name="betainfo"> <xs:complextype> <xs:sequence> <xs:element name="simplebetainfo" type="betainfotype" minoccurs="1" maxoccurs="1" /> <xs:element name="listbetainfo" type="betainfotype" minoccurs="1" maxoccurs="unbounded"/> </xs:sequence> <xs:attributegroup ref="commonattributes"/> </xs:complextype> </xs:element> <xs:complextype name="betainfotype"> <xs:sequence> <xs:element name="param" minoccurs="2" maxoccurs="2"> <xs:complextype> <xs:attributegroup ref="commonattributes"/> </xs:complextype> </xs:element> </xs:sequence> <xs:attributegroup ref="commonattributes"/> </xs:complextype> </xs:schema>
the above schema not, however, restrict structure of contents of attributes done using regular expressions, nor relationships between data in different fields (which require xsd 1.1 not supported in jaxb).
Comments
Post a Comment