| Modifier and Type | Field | Description |
|---|---|---|
private List<ReferenceBase> |
parseElements |
A
List which contains all the top elements parsed by this class. |
private static Map<String,BiFunction<XsdParser,Node,ReferenceBase>> |
parseMappers |
A
Map object that contains a parse function to each XsdAbstractElement concrete
type supported by this mapper, this way based on the concrete XsdAbstractElement tag the according parse
method can be invoked. |
private List<UnsolvedReferenceItem> |
parserUnsolvedElementsMap |
A
List containing all the elements that even after parsing all the elements on the file, don't have a
suitable object to replace the reference. |
private List<String> |
schemaLocations |
A
List containing the paths of files that were present in either XsdInclude or XsdImport
objects that are present in the original or subsequent files. |
private List<UnsolvedReference> |
unsolvedElements |
A
List of UnsolvedReference elements that weren't solved. |
private static Map<String,String> |
xsdTypesToJava |
A
Map object that contains the all the XSD types and their respective types in the Java
language. |
| Constructor | Description |
|---|---|
XsdParser(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. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addFileToParse(String schemaLocation) |
Adds a new file to the parsing queue.
|
void |
addParsedElement(ReferenceBase wrappedElement) |
|
void |
addUnsolvedReference(UnsolvedReference unsolvedReference) |
Adds an
UnsolvedReference object to the unsolvedElements list which should be solved
at a later time in the parsing process. |
static Map<String,BiFunction<XsdParser,Node,ReferenceBase>> |
getParseMappers() |
|
Stream<XsdElement> |
getResultXsdElements() |
|
Stream<XsdSchema> |
getResultXsdSchemas() |
|
private Node |
getSchemaNode(String filePath) |
This function uses DOM to obtain a list of nodes from a XSD file.
|
List<UnsolvedReferenceItem> |
getUnsolvedReferences() |
|
static Map<String,String> |
getXsdTypesToJava() |
|
private boolean |
isXsdSchema(Node node) |
Verifies if a given
Node object, i.e. |
private void |
parseFile(String filePath) |
Parses a XSD file and all its containing XSD elements.
|
private void |
replaceUnsolvedReference(Map<String,List<NamedConcreteElement>> concreteElementsMap,
UnsolvedReference unsolvedReference) |
Replaces a single
UnsolvedReference object, with the respective NamedConcreteElement object. |
private void |
resolveRefs() |
This method resolves all the remaining
UnsolvedReference objects present after all the elements are parsed. |
private void |
storeUnsolvedItem(UnsolvedReference unsolvedReference) |
Saves an occurrence of an element which couldn't be resolved in the
replaceUnsolvedReference(java.util.Map<java.lang.String, java.util.List<org.xmlet.xsdparser.xsdelements.elementswrapper.NamedConcreteElement>>, org.xmlet.xsdparser.xsdelements.elementswrapper.UnsolvedReference)
method, which can be accessed at the end of the parsing process in order to verify if were there were any
references that couldn't be solved. |
private static final Map<String,BiFunction<XsdParser,Node,ReferenceBase>> parseMappers
Map object that contains a parse function to each XsdAbstractElement concrete
type supported by this mapper, this way based on the concrete XsdAbstractElement tag the according parse
method can be invoked.private static final Map<String,String> xsdTypesToJava
Map object that contains the all the XSD types and their respective types in the Java
language.private List<ReferenceBase> parseElements
List which contains all the top elements parsed by this class.private List<UnsolvedReference> unsolvedElements
List of UnsolvedReference elements that weren't solved. This list is consulted after all the
elements are parsed in order to find if there is any suitable parsed element to replace the unsolved element.private List<UnsolvedReferenceItem> parserUnsolvedElementsMap
List containing all the elements that even after parsing all the elements on the file, don't have a
suitable object to replace the reference. This list can be consulted after the parsing process to assert if there
is any missing information in the XSD file.private List<String> schemaLocations
List containing the paths of files that were present in either XsdInclude or XsdImport
objects that are present in the original or subsequent files. These paths are stored to be parsed as well, the
parsing process only ends when all the files present in this List are parsed.public XsdParser(String filePath)
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 getResultXsdSchemas(),
getResultXsdElements() and getUnsolvedReferences().filePath - States the path of the XSD file to be parsed.private void parseFile(String filePath)
parseMappers
field.filePath - The path to the XSD file.private boolean isXsdSchema(Node node)
Node object, i.e. node is a xsd:schema node.node - The node to verify.private Node getSchemaNode(String filePath) throws IOException, SAXException, ParserConfigurationException
filePath - The path to the XSD file.IOException - If the file parsing throws IOException.SAXException - if the file parsing throws SAXException.ParserConfigurationException - If the DocumentBuilderFactory.newDocumentBuilder() throws
ParserConfigurationException.private void resolveRefs()
UnsolvedReference objects present after all the elements are parsed.
It starts by iterating all parseElements and inserting all the parsed elements with a name
attribute in the concreteElementsMap variable. After that it iterates on the unsolvedElements
list in order to find if any of the unsolvedReferences can be solved by replacing the unsolvedElement by its
matching NamedConcreteElement object, present in the concreteElementsMap. The UnsolvedReference
objects matches a NamedConcreteElement object by having its ref attribute with the same value as the
name attribute of the NamedConcreteElement.private void replaceUnsolvedReference(Map<String,List<NamedConcreteElement>> concreteElementsMap, UnsolvedReference unsolvedReference)
UnsolvedReference object, with the respective NamedConcreteElement object. If
there isn't a NamedConcreteElement object to replace the UnsolvedReference object, information
is stored informing the user of this Project of the occurrence.concreteElementsMap - The map containing all named concreteElements.unsolvedReference - The unsolved reference to solve.private void storeUnsolvedItem(UnsolvedReference unsolvedReference)
replaceUnsolvedReference(java.util.Map<java.lang.String, java.util.List<org.xmlet.xsdparser.xsdelements.elementswrapper.NamedConcreteElement>>, org.xmlet.xsdparser.xsdelements.elementswrapper.UnsolvedReference)
method, which can be accessed at the end of the parsing process in order to verify if were there were any
references that couldn't be solved.unsolvedReference - The unsolved reference which couldn't be resolved.public List<UnsolvedReferenceItem> getUnsolvedReferences()
List of UnsolvedReferenceItem that represent all the objects with a reference that couldn't
be solved.public Stream<XsdElement> getResultXsdElements()
getResultXsdSchemas()public void addUnsolvedReference(UnsolvedReference unsolvedReference)
UnsolvedReference object to the unsolvedElements list which should be solved
at a later time in the parsing process.unsolvedReference - The unsolvedReference to add to the unsolvedElements list.public void addFileToParse(String schemaLocation)
schemaLocation - A new file path of another XSD file to parse.public static Map<String,BiFunction<XsdParser,Node,ReferenceBase>> getParseMappers()
public void addParsedElement(ReferenceBase wrappedElement)
Copyright © 2018. All rights reserved.