views:

33

answers:

0

I need to be able to take an XML file and corresponding XSD at runtime and derive an array of elements and associated attributes.

I've seen a few posts e.g.:

http://www.java2s.com/Code/Java/XML/ProvidesatraceoftheschematypeinformationforelementsandattributesinanXMLdocument.htm

that suggest using a sax parser to iterate through the document and pull out TypeInfo. This seems to work to some extent so that given the following schema:

<?xml version="1.0" encoding="UTF-8"?>  
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;  
    <xs:element name="example">  
        <xs:complexType>  
            <xs:sequence>      
                <xs:element name="element1" type="xs:string" minOccurs="0"/>    
            </xs:sequence>  
        </xs:complexType>  
    </xs:element>  
</xs:schema>` 

I can get the element name (element1) and the type "string".

But how do I get the MinOccurs attribute?