This is more of question of technique or tools to use rather than a how-to.
I have an XML Schema that is used by the development team for parsing input and output and automatic code generation.
The schema is designed for developers. However there are other uses for this schema that have different needs. For example the developer schema is strongly typed, however the user schema will need to be weakly typed to allow wildcard replacement. Another example are the appinfo annotations that are used by the developer tools. These would be stripped out of the user schema.
For example, this:
<xs:complexType name="ModelA"> <xs:annotation id="ModelA" > <xs:appinfo> <dev_type>AObject</dev_type> <function id="AFunction"> <parameters> <parameter>P1</parameter> <parameter>P2</parameter> </parameters> </function> </xs:appinfo> <xs:documentation> <description>A model. Used by A in Camelot.</description> </xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="dbs:Models"> <xs:sequence> <xs:element name="RoundTables" type="xs:decimal"/> <xs:element name="ClarkGable" type="xs:boolean"/> <xs:element name="SequinVests" type="xs:decimal"/> <xs:element name="Opera" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> Would become this:
<xs:complexType name="ModelA"> <xs:annotation id="ModelA" > <xs:documentation> <description>A model. Used by A in Camelot.</description> </xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="dbs:Models"> <xs:sequence> <xs:element name="RoundTables" type="xs:string"/> <xs:element name="ClarkGable" type="xs:string"/> <xs:element name="SequinVests" type="xs:string"/> <xs:element name="Opera" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> Would XLST be useful here? Or could I load the schema as XML and use XPath to find and delete/modify tags and attributes?
Cheers
No comments:
Post a Comment