Class XmlSchemaWalker
java.lang.Object
org.apache.ws.commons.schema.walker.XmlSchemaWalker
Walks an
XmlSchema from a starting XmlSchemaElement,
notifying attached visitors as it descends.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<QName, List<XmlSchemaElement>> private final XmlSchemaCollectionprivate final SchemasByNamespaceprivate final Map<QName, XmlSchemaScope> private final IdentityHashMap<XmlSchemaType, XmlSchemaType> private final List<XmlSchemaVisitor> -
Constructor Summary
ConstructorsConstructorDescriptionXmlSchemaWalker(XmlSchemaCollection xmlSchemas) Initializes theXmlSchemaWalkerwith theXmlSchemaCollectionto reference when following anXmlSchemaElement.XmlSchemaWalker(XmlSchemaCollection xmlSchemas, XmlSchemaVisitor visitor) Initializes theXmlSchemaWalkerwith anXmlSchemaVisitorto notify as the schema is walked. -
Method Summary
Modifier and TypeMethodDescriptionaddVisitor(XmlSchemaVisitor visitor) Adds a new visitor to be notified as the XML Schemas are walked.voidclear()Clears the internal state in preparation for another walk through the schema.private XmlSchemaElementgetElement(XmlSchemaElement element, boolean isSubstitutionGroup) If the providedXmlSchemaElementis a reference, track down the original and add the minimum and maximum occurrence fields.private static QNamegetElementQName(XmlSchemaElement element) The user-defined types set with the call tosetUserRecognizedTypes(Set), ornullif none.removeVisitor(XmlSchemaVisitor visitor) Removes the visitor to be notified as the XML Schemas are walked.voidsetUserRecognizedTypes(Set<QName> userRecognizedTypes) Defines the set of types the calling code recognizes.voidwalk(XmlSchemaElement element) Initiates a walk through theXmlSchemaCollectionstarting with the provided rootXmlSchemaElement.private voidwalk(XmlSchemaGroupParticle group, long minOccurs, long maxOccurs) private voidwalk(XmlSchemaParticle particle)
-
Field Details
-
userRecognizedTypes
-
schemas
-
visitors
-
elemsBySubstGroup
-
schemasByNamespace
-
scopeCache
-
visitedTypes
-
-
Constructor Details
-
XmlSchemaWalker
Initializes theXmlSchemaWalkerwith theXmlSchemaCollectionto reference when following anXmlSchemaElement. -
XmlSchemaWalker
Initializes theXmlSchemaWalkerwith anXmlSchemaVisitorto notify as the schema is walked.(Other visitors may continue to be added after this one.)
- Parameters:
xmlSchemas- The set of schemas to walk.visitor- The visitor to visit during the walk.
-
-
Method Details
-
addVisitor
Adds a new visitor to be notified as the XML Schemas are walked.- Parameters:
visitor- The visitor to be notified.- Returns:
- This
XmlSchemaWalkerinstance for method chaining.
-
removeVisitor
Removes the visitor to be notified as the XML Schemas are walked.- Parameters:
visitor- The visitor to remove.- Returns:
- This
XmlSchemaWalkerinstance for method chaining.
-
clear
public void clear()Clears the internal state in preparation for another walk through the schema. -
setUserRecognizedTypes
Defines the set of types the calling code recognizes. If one of the types are found during the walk through the XML Schema, it is attached to the relevantXmlSchemaTypeInfothat is passed to theXmlSchemaVisitors, with lower types in the hierarchy taking precedence over higher types.This information is useful when translating from XML Schema to another schema, as this automatically associates the destination type with the source XML Schema type.
- Parameters:
userRecognizedTypes- The set of types the user recognizes and would like recognized when traversed.
-
getUserRecognizedTypes
The user-defined types set with the call tosetUserRecognizedTypes(Set), ornullif none. -
walk
Initiates a walk through theXmlSchemaCollectionstarting with the provided rootXmlSchemaElement. Any visitors will be notified as the walk progresses.Once this method completes, call
clear()before starting another walk through the XML Schemas.- Parameters:
element- The root element to start the walk from.
-
walk
-
walk
-
getElement
If the providedXmlSchemaElementis a reference, track down the original and add the minimum and maximum occurrence fields. Otherwise, just return the providedelement.- Parameters:
element- The element to get the definition of.- Returns:
- The real
XmlSchemaElement.
-
getElementQName
-