Class Wildcard

    • Constructor Detail

      • Wildcard

        public Wildcard()
    • Method Detail

      • isInexpressible

        public boolean isInexpressible()
        Determine whether this wildcard represents an "inexpressible" intersection or union
        Returns:
        true if the intersection or union is inexpressible, as defined in XML Schema. This is essentially an error condition, so the wildcard should not be used if this property is true.
      • allowsAny

        public final boolean allowsAny()
        Determine whether this wildcard allows any namespace (##any)
        Returns:
        true if this wildcard allows any namespace
      • setNoNamespacesAllowed

        public void setNoNamespacesAllowed()
        Initialize the set of permitted namespaces to an empty set. This is needed in case the namespace attribute is present but empty; it indicates that no namespaces are allowed.
      • addAllowedNamespace

        public void addAllowedNamespace​(java.lang.String namespace)
        Add a permitted namespace. This must be an actual namespace, not one of the special tokens such as ##other; the non-namespace ("absent") is represented by the zero-length string. Validation of the namespace is the responsibility of the caller.
        Parameters:
        namespace - the namespace to add
      • addDisallowedNamespace

        public void addDisallowedNamespace​(java.lang.String namespace)
        Add a disallowed namespace. This corresponds to the option ##other.
        Parameters:
        namespace - the disallowed namespace to be added
      • getDisallowedNamespaces

        public java.util.Set<java.lang.String> getDisallowedNamespaces()
        Get the disallowed namespaces. Returns null if there is no disallowed namespace.
        Returns:
        the set of disallowed namespaces; may be null to represent the empty set
      • matches

        public boolean matches​(java.lang.String uri)
        Determine whether a particular namespace is allowed by this wildcard. This method ignores the QNames that have been explicitly disallowed (using notQNames)
        Parameters:
        uri - the namespace to be tested. Supply "" for the no-namespace.
        Returns:
        true if the wildcard allows this namespace, false if not.
      • matches

        public boolean matches​(StructuredQName name,
                               boolean isElement,
                               Configuration config,
                               UserComplexType parentType)
        Determine whether a name is allowed by this wildcard. This method ignores the restrictions imposed by ##definedSiblings
        Parameters:
        name - the name to be tested
        isElement - true if looking for an element, false if looking for an attribute
        config - the Saxon configuration
        parentType - the governing type definition of the parent element, used to assess whether the ##definedSibling constraint prevents an element from matching. May be null, in which case ##definedSibling is ignored.
        Returns:
        true if the wildcard allows this name, false if not.
      • matches

        public boolean matches​(NodeName name,
                               boolean isElement,
                               Configuration config,
                               UserComplexType parentType)
        Determine whether a name is allowed by this wildcard. This method ignores the restrictions imposed by ##definedSiblings
        Parameters:
        name - the name to be tested
        isElement - true if looking for an element, false if looking for an attribute
        config - the Saxon configuration
        parentType - the governing type definition of the parent element, used to assess whether the ##definedSibling constraint prevents an element from matching. May be null, in which case ##definedSibling is ignored.
        Returns:
        true if the wildcard allows this name, false if not.
      • reasonForNonMatch

        public java.lang.String reasonForNonMatch​(NodeName nn,
                                                  boolean isElement,
                                                  Configuration config,
                                                  UserComplexType parentType)
        If matches() returns false, return a string explaining the reason for the non-match
        Parameters:
        nn - the name of the node that does not match the wildcard
        isElement - true if looking for an element, false if looking for an attribute
        config - the Saxon configuration
        parentType - the governing type definition of the parent element, used to assess whether the ##definedSibling constraint prevents an element from matching. May be null, in which case ##definedSibling is ignored.
        Returns:
        null if the name matches, or a string explaining the reason if not. The string will be in the form of one or more complete English sentences terminated by a full stop and trailing space.
      • disallowsQName

        public boolean disallowsQName​(int fingerprint)
        Test whether a name is in the set of disallowed QNames
        Parameters:
        fingerprint - the fingerprint of the name to be tested
        Returns:
        true if the name is in the set of explicitly disallowed QNames
      • getAllowedNamespaces

        public java.util.Set<java.lang.String> getAllowedNamespaces()
        Returns the set of permitted namespaces of this wildcard
        Returns:
        the set of permitted namespaces of this wildcard, or null if no namespaces are explicitly permitted
      • getProcessContents

        public java.lang.String getProcessContents()
        Returns the processContents attribute of this wildcard
        Returns:
        the processContents attribute of this wildcard, as a string ("strict", "lax", or "skip")
      • setProcessContents

        public void setProcessContents​(java.lang.String process)
        Sets the processContents attribute of the wildCard. For internal use only.
        Parameters:
        process - the processContents value to set (e.g. "strict", "lax"). Validation of the value is the responsibility of the caller.
      • setDisallowDefinedNames

        public void setDisallowDefinedNames​(boolean disallow)
        Say that defined names are not allowed (notQName = "##defined")
        Parameters:
        disallow - true if defined names are disallowed
      • isDisallowDefinedNames

        public boolean isDisallowDefinedNames()
        Ask whether globally-defined names are disallowed
        Returns:
        true if globally-defined names are disallowed (notQName = "##defined")
      • setDisallowDefinedSiblings

        public void setDisallowDefinedSiblings​(boolean disallow)
        Say that defined siblings are not allowed (notQName = "##definedSibling")
        Parameters:
        disallow - true if defined siblings are disallowed
      • isDisallowDefinedSiblings

        public boolean isDisallowDefinedSiblings()
        Ask whether defined siblings are disallowed
        Returns:
        true if the names of defined siblings are disallowed (notQName = "##definedSibling")
      • addDisallowedQName

        public void addDisallowedQName​(int fingerprint)
        Mark a specific QName as being disallowed
        Parameters:
        fingerprint - the NamePool fingerprint of the disallowed name
      • isDisallowedQName

        public boolean isDisallowedQName​(int fingerprint)
        Ask whether a specific QName is disallowed
        Parameters:
        fingerprint - the NamePool fingerprint of the QName in question
        Returns:
        true if the QName is in the list of QNames specifically disallowed by this wildcard
      • validate

        public boolean validate​(SchemaCompiler compiler)
        Perform validation on this wildcard (this implementation of the method is a no-op)
        Specified by:
        validate in interface UserSchemaComponent
        Overrides:
        validate in class SchemaStructure
        Parameters:
        compiler - the schema compiler
        Returns:
        true when this Schema definition is valid, otherwise false.
      • toString

        public java.lang.String toString()
        Get a string representation of this wildcard, used for diagnostics
        Overrides:
        toString in class java.lang.Object
      • isSubset

        public boolean isSubset​(Wildcard sup,
                                NamePool pool)
        Determine whether this wildcard is a subset of another wildcard. See Schema Part 1 Schema Component Constraint: Wildcard Subset (section 3.10.6.2)
        Parameters:
        sup - the other wildcard
        pool - the NamePool
        Returns:
        true if this wildcard is a subset of the other wildcard, as defined in the XSD specification
      • overlaps

        public boolean overlaps​(Wildcard other)
        Determine whether this wildcard overlaps another wildcard, that is, whether there is an element that could match either. Note, this is no longer a defined algorithm in Schema 1.1, but it is still needed to assess UPA.
        Parameters:
        other - the other wildcard
        Returns:
        true if the two wildcards overlap, that is, if there are possible elements that could match either of the wildcards
      • isNotStronger

        public static boolean isNotStronger​(java.lang.String str1,
                                            java.lang.String str2)
        Test whether one processContents value is <= the strength of another, where skip < lax < strict
        Parameters:
        str1 - the first processContents value, as a string
        str2 - the second processContents value, as a string
        Returns:
        true if the pair is one of (strict, strict), (lax, lax), (skip, skip), (skip, strict), (lax, strict), (skip, lax)
      • compareStrength

        public int compareStrength​(Wildcard other)
      • makeIntersection

        public static Wildcard makeIntersection​(Wildcard wat1,
                                                Wildcard wat2,
                                                NamePool pool)
        Create an AttributeWildcard as the intersection of two AttributeWildcards. For internal use only.

        In XML Schema 1.1, the intersection of two wildcards is always expressible. The resulting wildcard might not be expressible using XML Schema 1.0, however.

        Parameters:
        wat1 - the first operand: the processContents is taken from this operand
        wat2 - the second operand
        pool - the NamePool
        Returns:
        a new AttributeWildcard representing the intersection, as defined in Schema Component Constraint: Attribute Wildcard Intersection; if the intersection "is not expressible" this will be flagged as such, for later rejection by the validator.
      • makeUnion

        public static Wildcard makeUnion​(Wildcard wat1,
                                         Wildcard wat2,
                                         NamePool pool)
        Create a AttributeWildcard as the union of two AttributeWildcards. For internal use only.
        Parameters:
        wat1 - the first operand: the processContents is taken from this operand
        wat2 - the second operand
        pool - the Name Pool
        Returns:
        a new AttributeWildcard representing the union, as defined in Schema Component Constraint: Attribute Wildcard Union; if the union "is not expressible" then the result will be marked as such, for later use by the validator.
      • getComponentAsFunction

        public Function getComponentAsFunction()
        Description copied from interface: SchemaComponent
        Get the schema component in the form of a function item. This allows schema information to be made visible to XSLT or XQuery code. The function makes available the contents of the schema component as defined in the XSD specification. The function takes a string as argument representing a property name, and returns the corresponding property of the schema component. There is also a property "class" which returns the kind of schema component, for example "Attribute Declaration".
        Specified by:
        getComponentAsFunction in interface SchemaComponent
        Overrides:
        getComponentAsFunction in class SchemaStructure
        Returns:
        the schema component represented as a function from property names to property values.