While it is obvious that it is possible to construct a W3C Schema design file that uses other schemata within it to specify child elements, I am curious if anyone might know how to perform the following task. (While this may not be good software design, I have been asked to use this architecture anyway.) I would like to create a schema that will, in an instance document, allow for the arbitrary specification of child elements (in certain locations of the Schema doc, e.g. specified by <xsd:any/>) based on arbitrary Schema files. A code snippet of such an implementation might look like this in the the highest Schema document. ************ ... <xs:complexType> <xs:sequence> <xs:element ref="MethodDef"/> <xs:any namespace="##any" processContents="strict" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> ... ************ highest.xsd One of many possible lower level .xsd's might look like this: ************ ... <xs:element name="Document'sRootElement"> <xs:complexType> <xs:sequence> <xs:element ref="SubElement1" /> <xs:element ref="SubElement2"/> </xs:sequence> <xs:attribute ref="OptionalAttrb"/> </xs:complexType> </xs:element> ... ************** arbitrarySchema.xsd The xml code then, hopefully, would look something like this. It would be very convenient if all that was required in the instance document was an in-element reference to arbitrarySchema.xsd, whose children didn't require qualification. *************** ... <MethodDef> org.w3c.xml.SomeMethod() </MethodDef> <Document'sRootElement [some type of reference here to arbitrarySchema.xsd (xmlns? namespace?) Would correspond to org.w3c.xml.SomeMethod()] > <SubElement1> ... </SubElement1> <SubElement2> ... </SubElement2> </Document'sRootElement> ***************** As you can tell, the usefulnes of this would be to create XML files that could work in conjunction with particular classes specified in the XML document, and the arbitrarySchema would outline the settings unique to the specified class. Thus, after production of a product, functionality could be easily added while only editing the instance .xml document, adding new arbitrarySchema.xsd type documents, and tacking on a package to the product that has the corresponding method within it (in this case org.w3c.xml.SomeMethod()). That's all to say: is there a simple way of calling on arbitrary .xsd documents within .xml files (<Element xmlns="myChildSchema.xsd">...</Element>)? Again, avoiding defining the namespace at the top of the .xml document would be useful. Thanks in advance, Leo Trottier
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format