org.apache.ws.commons.schema.docpath
Class XmlSchemaStateMachineGenerator

java.lang.Object
  extended by org.apache.ws.commons.schema.docpath.XmlSchemaStateMachineGenerator
All Implemented Interfaces:
XmlSchemaVisitor

public final class XmlSchemaStateMachineGenerator
extends Object
implements XmlSchemaVisitor

Builds a state machine from an XmlSchema representing how to walk through the schema when parsing an XML document.


Constructor Summary
XmlSchemaStateMachineGenerator()
          Constructs a new XmlSchemaStateMachineGenerator, ready to start walking XmlSchemas.
 
Method Summary
 XmlSchemaStateMachineNode getStartNode()
          Retrieves the start node of the state machine representing the most-recently walked XmlSchema.
 Map<QName,XmlSchemaStateMachineNode> getStateMachineNodesByQName()
          Retrieves the XmlSchemaStateMachineNodes representing each XmlSchemaElement in the walked XmlSchema.
 void onEndAttributes(XmlSchemaElement element, XmlSchemaTypeInfo elemTypeInfo)
          This method is called when all of the attributes have been processed (provided the element has a type defined).
 void onEnterAllGroup(XmlSchemaAll all)
          Called when an all group is entered.
 void onEnterChoiceGroup(XmlSchemaChoice choice)
          Called when a choice group is entered.
 void onEnterElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited)
          A notification that an XmlSchemaElement has been entered.
 void onEnterSequenceGroup(XmlSchemaSequence seq)
          Called when a sequence is entered.
 void onEnterSubstitutionGroup(XmlSchemaElement base)
          This method is called when the walker enters a substitution group.
 void onExitAllGroup(XmlSchemaAll all)
          Called when an all group is exited.
 void onExitChoiceGroup(XmlSchemaChoice choice)
          Called when a choice group is exited.
 void onExitElement(XmlSchemaElement element, XmlSchemaTypeInfo typeInfo, boolean previouslyVisited)
          Signifies the end of the element that was previously entered.
 void onExitSequenceGroup(XmlSchemaSequence seq)
          Called when a sequence is exited.
 void onExitSubstitutionGroup(XmlSchemaElement base)
          Called when the end of the substitution group is reached.
 void onVisitAny(XmlSchemaAny any)
          Called when a wildcard element is entered.
 void onVisitAnyAttribute(XmlSchemaElement element, XmlSchemaAnyAttribute anyAttr)
          Called when a wildcard attribute is visited.
 void onVisitAttribute(XmlSchemaElement element, XmlSchemaAttrInfo attrInfo)
          This method is called for each attribute associated with the element, providing the XmlSchemaAttrInfo representing that attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlSchemaStateMachineGenerator

public XmlSchemaStateMachineGenerator()
Constructs a new XmlSchemaStateMachineGenerator, ready to start walking XmlSchemas.

Method Detail

getStartNode

public XmlSchemaStateMachineNode getStartNode()
Retrieves the start node of the state machine representing the most-recently walked XmlSchema.


getStateMachineNodesByQName

public Map<QName,XmlSchemaStateMachineNode> getStateMachineNodesByQName()
Retrieves the XmlSchemaStateMachineNodes representing each XmlSchemaElement in the walked XmlSchema.

Only top-level XmlSchemaElements can be retrieved by calling XmlSchema.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: XmlSchemaVisitor
A notification that an XmlSchemaElement has 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 to XmlSchemaVisitor.onExitElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean).

On all subsequent visits to this element, previouslyVisited will be set to true and the attributes will not be revisited. The next call will be to XmlSchemaVisitor.onExitElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean), as all of the element's attributes and children have already been provided.

Specified by:
onEnterElement in interface XmlSchemaVisitor
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:
XmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)

onExitElement

public void onExitElement(XmlSchemaElement element,
                          XmlSchemaTypeInfo typeInfo,
                          boolean previouslyVisited)
Description copied from interface: XmlSchemaVisitor
Signifies the end of the element that was previously entered. Provides the same information about the element as was provided in XmlSchemaVisitor.onEnterElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean) in the event it is easier to process on exit.

Specified by:
onExitElement in interface XmlSchemaVisitor
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:
XmlSchemaVisitor.onExitElement(XmlSchemaElement, XmlSchemaTypeInfo, boolean)

onVisitAttribute

public void onVisitAttribute(XmlSchemaElement element,
                             XmlSchemaAttrInfo attrInfo)
Description copied from interface: XmlSchemaVisitor
This method is called for each attribute associated with the element, providing the XmlSchemaAttrInfo representing that attribute.

Specified by:
onVisitAttribute in interface XmlSchemaVisitor
Parameters:
element - The element owing the attribute.
attrInfo - The attribute information.
See Also:
XmlSchemaVisitor.onVisitAttribute(XmlSchemaElement, XmlSchemaAttrInfo)

onEndAttributes

public void onEndAttributes(XmlSchemaElement element,
                            XmlSchemaTypeInfo elemTypeInfo)
Description copied from interface: XmlSchemaVisitor
This 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:
onEndAttributes in interface XmlSchemaVisitor
Parameters:
element - The element the walker is traversing.
elemTypeInfo - Type information about the element, if it is easier to process here.
See Also:
XmlSchemaVisitor.onEndAttributes(XmlSchemaElement, XmlSchemaTypeInfo)

onEnterSubstitutionGroup

public void onEnterSubstitutionGroup(XmlSchemaElement base)
Description copied from interface: XmlSchemaVisitor
This method is called when the walker enters a substitution group. This method is called providing the base type, and then XmlSchemaVisitor.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() returns true ). 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:
onEnterSubstitutionGroup in interface XmlSchemaVisitor
Parameters:
base - The XmlSchemaElement representing the base of the substitution group.
See Also:
XmlSchemaVisitor.onEnterSubstitutionGroup(XmlSchemaElement)

onExitSubstitutionGroup

public void onExitSubstitutionGroup(XmlSchemaElement base)
Description copied from interface: XmlSchemaVisitor
Called when the end of the substitution group is reached. The base element of the substitution group is provided for convenience.

Specified by:
onExitSubstitutionGroup in interface XmlSchemaVisitor
Parameters:
base - The base element of the subtitution group.
See Also:
XmlSchemaVisitor.onExitSubstitutionGroup(XmlSchemaElement)

onEnterAllGroup

public void onEnterAllGroup(XmlSchemaAll all)
Description copied from interface: XmlSchemaVisitor
Called when an all group is entered.

Specified by:
onEnterAllGroup in interface XmlSchemaVisitor
Parameters:
all - The XmlSchemaAll representing the all group.
See Also:
XmlSchemaVisitor.onEnterAllGroup(XmlSchemaAll)

onExitAllGroup

public void onExitAllGroup(XmlSchemaAll all)
Description copied from interface: XmlSchemaVisitor
Called when an all group is exited.

Specified by:
onExitAllGroup in interface XmlSchemaVisitor
Parameters:
all - The XmlSchemaAll representing the all group.
See Also:
XmlSchemaVisitor.onExitAllGroup(XmlSchemaAll)

onEnterChoiceGroup

public void onEnterChoiceGroup(XmlSchemaChoice choice)
Description copied from interface: XmlSchemaVisitor
Called when a choice group is entered.

Specified by:
onEnterChoiceGroup in interface XmlSchemaVisitor
See Also:
XmlSchemaVisitor.onEnterChoiceGroup(XmlSchemaChoice)

onExitChoiceGroup

public void onExitChoiceGroup(XmlSchemaChoice choice)
Description copied from interface: XmlSchemaVisitor
Called when a choice group is exited.

Specified by:
onExitChoiceGroup in interface XmlSchemaVisitor
See Also:
XmlSchemaVisitor.onExitChoiceGroup(XmlSchemaChoice)

onEnterSequenceGroup

public void onEnterSequenceGroup(XmlSchemaSequence seq)
Description copied from interface: XmlSchemaVisitor
Called when a sequence is entered.

Specified by:
onEnterSequenceGroup in interface XmlSchemaVisitor
Parameters:
seq - The XmlSchemaSequence representing the sequence.
See Also:
XmlSchemaVisitor.onEnterSequenceGroup(XmlSchemaSequence)

onExitSequenceGroup

public void onExitSequenceGroup(XmlSchemaSequence seq)
Description copied from interface: XmlSchemaVisitor
Called when a sequence is exited.

Specified by:
onExitSequenceGroup in interface XmlSchemaVisitor
Parameters:
seq - The XmlSchemaSequence representing the sequence.
See Also:
XmlSchemaVisitor.onExitSequenceGroup(XmlSchemaSequence)

onVisitAny

public void onVisitAny(XmlSchemaAny any)
Description copied from interface: XmlSchemaVisitor
Called when a wildcard element is entered.

Specified by:
onVisitAny in interface XmlSchemaVisitor
Parameters:
any - The XmlSchemaAny representing the wildcard element.
See Also:
XmlSchemaVisitor.onVisitAny(XmlSchemaAny)

onVisitAnyAttribute

public void onVisitAnyAttribute(XmlSchemaElement element,
                                XmlSchemaAnyAttribute anyAttr)
Description copied from interface: XmlSchemaVisitor
Called 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 to XmlSchemaVisitor.onEndAttributes(XmlSchemaElement, XmlSchemaTypeInfo).

Specified by:
onVisitAnyAttribute in interface XmlSchemaVisitor
Parameters:
element - The owning element.
anyAttr - The XmlSchemaAnyAttribute representing the wildcard attribute.
See Also:
XmlSchemaVisitor.onVisitAnyAttribute(XmlSchemaElement, XmlSchemaAnyAttribute)


Copyright © 2004-2015 The Apache Software Foundation. All Rights Reserved.