Class XsdParser


  • public class XsdParser
    extends XsdParserCore
    XsdParser in the core class of the XsdParser project. It functions as a one shot class, receiving the name of the file to parse in its constructor and storing the parse results in its multiple fields, which can be consulted after the instance is created.
    • Constructor Detail

      • XsdParser

        public XsdParser​(java.lang.String filePath)
        The XsdParser constructor will parse the XSD file with the filepath and will also parse all the subsequent XSD files with their path present in xsd:import and xsd:include tags. After parsing all the XSD files present it resolves the references existent in the XSD language, represented by the ref attribute. When this method finishes the parse results and remaining unsolved references are accessible by the XsdParserCore.getResultXsdSchemas(), XsdParserCore.getResultXsdElements() and XsdParserCore.getUnsolvedReferences().
        Parameters:
        filePath - States the path of the XSD file to be parsed.
      • XsdParser

        public XsdParser​(java.lang.String filePath,
                         ParserConfig config)
        The XsdParser constructor will parse the XSD file with the filepath and will also parse all the subsequent XSD files with their path present in xsd:import and xsd:include tags. After parsing all the XSD files present it resolves the references existent in the XSD language, represented by the ref attribute. When this method finishes the parse results and remaining unsolved references are accessible by the XsdParserCore.getResultXsdSchemas(), XsdParserCore.getResultXsdElements() and XsdParserCore.getUnsolvedReferences().
        Parameters:
        filePath - States the path of the XSD file to be parsed.
        config - Config for the parser.
    • Method Detail

      • parse

        private void parse​(java.lang.String filePath)
      • parseFile

        private void parseFile​(java.lang.String filePath)
        Parses a XSD file and all its containing XSD elements. This code iterates on the nodes and parses the supported ones. The supported types are all the XSD types that have their tag present in the XsdParserCore.parseMappers field.
        Parameters:
        filePath - The path to the XSD file.
      • getSchemaNode

        private org.w3c.dom.Node getSchemaNode​(java.lang.String filePath)
                                        throws java.io.IOException,
                                               org.xml.sax.SAXException,
                                               javax.xml.parsers.ParserConfigurationException
        This function uses DOM to obtain a list of nodes from a XSD file.
        Parameters:
        filePath - The path to the XSD file.
        Returns:
        A list of nodes that represent the node tree of the XSD file with the path received.
        Throws:
        java.io.IOException - If the file parsing throws IOException.
        org.xml.sax.SAXException - if the file parsing throws SAXException.
        javax.xml.parsers.ParserConfigurationException - If the DocumentBuilderFactory.newDocumentBuilder() throws ParserConfigurationException.