I am looking for the Philosopher's stone turning XSDs in XQuery mapping . I want to invent a tool to generate for me XQuery Mapping code in an intelligent, introspective, rule-driven way.
This is emp.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:com.testws.data" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Employee">
<xs:sequence>
<xs:element minOccurs="1" name="Age" nillable="false" type="xs:int"/>
<xs:element minOccurs="1" name="Name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
this is my code
XmlObject xmlObject = XmlObject.Factory.parse(new File("emp.xsd"));
xmlObject.dump();
This is what I get:
ROOT (USER) *:R:<cur>[0] <mark>[0] (DocumentXobj)
ELEM xs:schema@http://www.w3.org/2001/XMLSchema (ElementXobj)
ATTR attributeFormDefault Value( "unqualified" ) (AttrXobj)
ATTR elementFormDefault Value( "qualified" ) (AttrXobj)
ATTR targetNamespace Value( "java:com.testws.data" ) (AttrXobj)
ATTR xmlns:xs@http://www.w3.org/2000/xmlns/ Value( "http://www.w3.org/2001/XMLSchema" ) After( "\n " ) (AttrXobj)
ELEM xs:complexType@http://www.w3.org/2001/XMLSchema After( "\n " ) (ElementXobj)
ATTR name Value( "Employee" ) After( "\n " ) (AttrXobj)
ELEM xs:sequence@http://www.w3.org/2001/XMLSchema Value( "\n " ) After( "\n " ) (ElementXobj)
ELEM xs:element@http://www.w3.org/2001/XMLSchema After( "\n " ) (ElementXobj)
ATTR minOccurs Value( "1" ) (AttrXobj)
ATTR name Value( "Age" ) (AttrXobj)
ATTR nillable Value( "false" ) (AttrXobj)
ATTR type Value( "xs:int" ) (AttrXobj)
ELEM xs:element@http://www.w3.org/2001/XMLSchema After( "\n " ) (ElementXobj)
ATTR minOccurs Value( "1" ) (AttrXobj)
ATTR name Value( "Name" ) (AttrXobj)
ATTR nillable Value( "true" ) (AttrXobj)
ATTR type Value( "xs:string" ) (AttrXobj)
to be continued.... I suspect Groovy has a far better support for XML parsing than native Java...
Tuesday, May 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment