Class XmlSchemaStateMachineGenerator
- All Implemented Interfaces:
XmlSchemaVisitor
XmlSchema
representing how to walk through the schema when parsing an XML document.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<XmlSchemaStateMachineNode> private XmlSchemaStateMachineNode -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newXmlSchemaStateMachineGenerator, ready to start walkingXmlSchemas. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the start node of the state machine representing the most-recently walkedXmlSchema.Retrieves theXmlSchemaStateMachineNodes representing eachXmlSchemaElementin the walkedXmlSchema.voidonEndAttributes(XmlSchemaElement element, XmlSchemaTypeInfo elemTypeInfo) This method is called when all of the attributes have been processed (provided the element has a type defined).voidCalled when an all group is entered.voidonEnterChoiceGroup(XmlSchemaChoice choice) Called when a choice group is entered.voidonEnterElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited) A notification that anXmlSchemaElementhas been entered.voidCalled when a sequence is entered.voidThis method is called when the walker enters a substitution group.voidCalled when an all group is exited.voidonExitChoiceGroup(XmlSchemaChoice choice) Called when a choice group is exited.voidonExitElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited) Signifies the end of the element that was previously entered.voidCalled when a sequence is exited.voidCalled when the end of the substitution group is reached.voidonVisitAny(XmlSchemaAny any) Called when a wildcard element is entered.voidonVisitAnyAttribute(XmlSchemaElement element, XmlSchemaAnyAttribute anyAttr) Called when a wildcard attribute is visited.voidonVisitAttribute(XmlSchemaElement element, XmlSchemaAttrInfo attrInfo) This method is called for each attribute associated with the element, providing theXmlSchemaAttrInforepresenting that attribute.private voidpopGroup(XmlSchemaStateMachineNode.Type groupType) private voidpushGroup(XmlSchemaStateMachineNode.Type groupType, long minOccurs, long maxOccurs)
-
Field Details
-
stack
-
startNode
-
elementInfoByQName
-
-
Constructor Details
-
XmlSchemaStateMachineGenerator
public XmlSchemaStateMachineGenerator()Constructs a newXmlSchemaStateMachineGenerator, ready to start walkingXmlSchemas.
-
-
Method Details
-
getStartNode
Retrieves the start node of the state machine representing the most-recently walkedXmlSchema. -
getStateMachineNodesByQName
Retrieves theXmlSchemaStateMachineNodes representing eachXmlSchemaElementin the walkedXmlSchema.Only top-level
XmlSchemaElements can be retrieved by callingXmlSchema.getElementByName(QName); this allows all elements to be retrieved without walking the schema again. -
onEnterElement
public void onEnterElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited) Description copied from interface:XmlSchemaVisitorA notification that anXmlSchemaElementhas been entered. The element returned will be a true representation of the element at that point in the schema: if the schema defines a reference, the reference is followed and merged with its global definition.The first time this element is reached, all of its attributes will be visited (if any). Once the attributes have been visited,
XmlSchemaVisitor.onEndAttributes(XmlSchemaElement, XmlSchemaTypeInfo)will be called. The only exception is when the element has no type information, at which point the next call will be toXmlSchemaVisitor.onExitElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean).On all subsequent visits to this element,
previouslyVisitedwill be set totrueand the attributes will not be revisited. The next call will be toXmlSchemaVisitor.onExitElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean), as all of the element's attributes and children have already been provided.- Specified by:
onEnterElementin interfaceXmlSchemaVisitor- Parameters:
element- The element the walker is currently entering.typeInfo- The type information of that element.previouslyVisited- Whether the element was previously visited.- See Also:
-
onExitElement
public void onExitElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited) Description copied from interface:XmlSchemaVisitorSignifies the end of the element that was previously entered. Provides the same information about the element as was provided inXmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)in the event it is easier to process on exit.- Specified by:
onExitElementin interfaceXmlSchemaVisitor- Parameters:
element- The element the walker is currently exiting.typeInfo- The type information of that element.previouslyVisited- Whether the element was previously visited.- See Also:
-
onVisitAttribute
Description copied from interface:XmlSchemaVisitorThis method is called for each attribute associated with the element, providing theXmlSchemaAttrInforepresenting that attribute.- Specified by:
onVisitAttributein interfaceXmlSchemaVisitor- Parameters:
element- The element owing the attribute.attrInfo- The attribute information.- See Also:
-
onEndAttributes
Description copied from interface:XmlSchemaVisitorThis method is called when all of the attributes have been processed (provided the element has a type defined). This is a convenience method to allow the visitor to be notified when no more attributes are coming, and the walker will be traversing the element's children.- Specified by:
onEndAttributesin interfaceXmlSchemaVisitor- Parameters:
element- The element the walker is traversing.elemTypeInfo- Type information about the element, if it is easier to process here.- See Also:
-
onEnterSubstitutionGroup
Description copied from interface:XmlSchemaVisitorThis method is called when the walker enters a substitution group. This method is called providing the base type, and thenXmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)is called for all types in the substitution group, starting with the base type.The only exception is when the base type of the substitution group is abstract (
XmlSchemaElement.isAbstract()returnstrue). When this happens,XmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)is not called with the abstract type, as there is no information to provide.If the root element is the base of a substitution group, this method will be the first one called. Otherwise,
XmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)will be called with the root element.- Specified by:
onEnterSubstitutionGroupin interfaceXmlSchemaVisitor- Parameters:
base- TheXmlSchemaElementrepresenting the base of the substitution group.- See Also:
-
onExitSubstitutionGroup
Description copied from interface:XmlSchemaVisitorCalled when the end of the substitution group is reached. The base element of the substitution group is provided for convenience.- Specified by:
onExitSubstitutionGroupin interfaceXmlSchemaVisitor- Parameters:
base- The base element of the subtitution group.- See Also:
-
onEnterAllGroup
Description copied from interface:XmlSchemaVisitorCalled when an all group is entered.- Specified by:
onEnterAllGroupin interfaceXmlSchemaVisitor- Parameters:
all- TheXmlSchemaAllrepresenting the all group.- See Also:
-
onExitAllGroup
Description copied from interface:XmlSchemaVisitorCalled when an all group is exited.- Specified by:
onExitAllGroupin interfaceXmlSchemaVisitor- Parameters:
all- TheXmlSchemaAllrepresenting the all group.- See Also:
-
onEnterChoiceGroup
Description copied from interface:XmlSchemaVisitorCalled when a choice group is entered.- Specified by:
onEnterChoiceGroupin interfaceXmlSchemaVisitor- Parameters:
choice- TheXmlSchemaChoicerepresenting the choice group.- See Also:
-
onExitChoiceGroup
Description copied from interface:XmlSchemaVisitorCalled when a choice group is exited.- Specified by:
onExitChoiceGroupin interfaceXmlSchemaVisitor- Parameters:
choice- TheXmlSchemaChoicerepresenting the choice group.- See Also:
-
onEnterSequenceGroup
Description copied from interface:XmlSchemaVisitorCalled when a sequence is entered.- Specified by:
onEnterSequenceGroupin interfaceXmlSchemaVisitor- Parameters:
seq- TheXmlSchemaSequencerepresenting the sequence.- See Also:
-
onExitSequenceGroup
Description copied from interface:XmlSchemaVisitorCalled when a sequence is exited.- Specified by:
onExitSequenceGroupin interfaceXmlSchemaVisitor- Parameters:
seq- TheXmlSchemaSequencerepresenting the sequence.- See Also:
-
onVisitAny
Description copied from interface:XmlSchemaVisitorCalled when a wildcard element is entered.- Specified by:
onVisitAnyin interfaceXmlSchemaVisitor- Parameters:
any- TheXmlSchemaAnyrepresenting the wildcard element.- See Also:
-
onVisitAnyAttribute
Description copied from interface:XmlSchemaVisitorCalled when a wildcard attribute is visited. If an element has a wildcard element, this will be called after all other attributes have been visited, and before the call toXmlSchemaVisitor.onEndAttributes(XmlSchemaElement, XmlSchemaTypeInfo).- Specified by:
onVisitAnyAttributein interfaceXmlSchemaVisitor- Parameters:
element- The owning element.anyAttr- TheXmlSchemaAnyAttributerepresenting the wildcard attribute.- See Also:
-
pushGroup
-
popGroup
-