Class XmlSchemaWalker

java.lang.Object
org.apache.ws.commons.schema.walker.XmlSchemaWalker

public final class XmlSchemaWalker extends Object
Walks an XmlSchema from a starting XmlSchemaElement, notifying attached visitors as it descends.
  • Field Details

  • Constructor Details

  • Method Details

    • addVisitor

      public XmlSchemaWalker addVisitor(XmlSchemaVisitor visitor)
      Adds a new visitor to be notified as the XML Schemas are walked.
      Parameters:
      visitor - The visitor to be notified.
      Returns:
      This XmlSchemaWalker instance for method chaining.
    • removeVisitor

      public XmlSchemaWalker removeVisitor(XmlSchemaVisitor visitor)
      Removes the visitor to be notified as the XML Schemas are walked.
      Parameters:
      visitor - The visitor to remove.
      Returns:
      This XmlSchemaWalker instance for method chaining.
    • clear

      public void clear()
      Clears the internal state in preparation for another walk through the schema.
    • setUserRecognizedTypes

      public void setUserRecognizedTypes(Set<QName> userRecognizedTypes)
      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 relevant XmlSchemaTypeInfo that is passed to the XmlSchemaVisitors, 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

      public Set<QName> getUserRecognizedTypes()
      The user-defined types set with the call to setUserRecognizedTypes(Set), or null if none.
    • walk

      public void walk(XmlSchemaElement element)
      Initiates a walk through the XmlSchemaCollection starting with the provided root XmlSchemaElement. 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

      private void walk(XmlSchemaParticle particle)
    • walk

      private void walk(XmlSchemaGroupParticle group, long minOccurs, long maxOccurs)
    • getElement

      private XmlSchemaElement getElement(XmlSchemaElement element, boolean isSubstitutionGroup)
      If the provided XmlSchemaElement is a reference, track down the original and add the minimum and maximum occurrence fields. Otherwise, just return the provided element.
      Parameters:
      element - The element to get the definition of.
      Returns:
      The real XmlSchemaElement.
    • getElementQName

      private static QName getElementQName(XmlSchemaElement element)