Mar 032015

Parsing XML is a fairly common task and it is relativily easy because you can use quite a lot of parsers. However, parsing a XSD Schema file is not an easy task. You can parse it as a regular XML, but transform all elements and attributes into java objects are rather difficult. You can use tools, such as XSOM, but it doesn’t seem to be maintained anymore.

As a consequence of that, I decided to develop a proof-of-concept solution using Xerces2. My only goal was to develop a solution that transforms xs:element into XSDElement java objects and xs:attribute into objects XSDAttribute.

In the XSDElements we will save the following data:

and in the XSDAttributtes we will save the following data:

To parse a XSD Schema file using Xerces2 you need to do:

I developed a very simple solution in which I was able to parse only a few elements or only one element and its children. You can find the complete code in GitHub XSDParser repository. With XSDParserTest you can parse an example of XSD Schema file.

Sorry, the comment form is closed at this time.