com.saxonica.schema
Class Wildcard

java.lang.Object
  extended by com.saxonica.schema.SchemaStructure
      extended by com.saxonica.schema.Wildcard
All Implemented Interfaces:
SerializableSchemaComponent, Term, java.io.Serializable, javax.xml.transform.SourceLocator, SchemaComponent

public class Wildcard
extends SchemaStructure
implements SchemaComponent, SerializableSchemaComponent, Term

A class that represents an XML Schema Wildcard. This is a helper class used to support the two distinct but similar schema components ElementWildcard and AttributeWildcard. A wilcard is represented by the XML elements xs:any and xs:anyAttribute

See Also:
Serialized Form

Field Summary
protected  java.util.Set allowedNamespaces
          The set of permitted namespaces.
 
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
 
Constructor Summary
Wildcard()
           
 
Method Summary
 void addAllowedNamespace(java.lang.String namespace)
          Add a permitted namespace.
 boolean allowsAny()
          Determine whether this wildcard allows any namespace (##any)
 java.util.Iterator getAllowedNamespaces()
          Returns an enumeration that contains the permitted namespaces of this wildcard
 java.lang.String getDisallowedNamespace()
          Get the disallowed namespace.
 java.lang.String getProcessContents()
          Returns the processContents attribute of this wildcard
 boolean isInexpressible()
          Determine whether this wildcard represents an "inexpressible" intersection or union
 boolean isIntensionalSubset(Wildcard sup)
          Determine whether this wildcard is an intensional subset of another wildcard.
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
static Wildcard makeIntersection(Wildcard wat1, Wildcard wat2)
          Create an AttributeWildcard as the intersection of two AttributeWildcards.
static Wildcard makeUnion(Wildcard wat1, Wildcard wat2)
          Create a AttributeWildcard as the union of two AttributeWildcards.
 boolean matches(java.lang.String uri)
          Determine whether a particular namespace is allowed by this wildcard
 boolean overlaps(Wildcard other)
          Determine whether this wildcard overlaps another wildcard, that is, whether there is an element that could match either.
 void serialize(SchemaModelSerializer serializer)
          Serialize this schema component
 void setDisallowedNamespace(java.lang.String namespace)
          Set the disallowed namespace.
 void setNoNamespacesAllowed()
          Initialize the set of permitted namespaces to an empty set.
 void setProcessContents(java.lang.String process)
          Sets the processContents attribute of the wildCard.
 java.lang.String toString()
          Get a string representation of this wildcard, used for diagnostics
 boolean validate(SchemaCompiler compiler)
          Perform validation on this wildcard (this implementation of the method is a no-op)
 
Methods inherited from class com.saxonica.schema.SchemaStructure
elaborate, fixup, getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getSystemId, getValidationStatus, lookForCycles, setConfiguration, setFixupStatus, setLineNumber, setLocator, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getValidationStatus
 

Field Detail

allowedNamespaces

protected java.util.Set allowedNamespaces
The set of permitted namespaces. The value "" represents the no-namespace, referred to as "absent" in the specifications. The set may be empty, indicating that no namespaces are explicitly allowed. If allowedNamespaces is non-null, then disallowedNamespaces must be null.

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)


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

setDisallowedNamespace

public void setDisallowedNamespace(java.lang.String namespace)
Set the disallowed namespace. This corresponds to the option ##other.


getDisallowedNamespace

public java.lang.String getDisallowedNamespace()
Get the disallowed namespace. Returns null if there is no disallowed namespace.


matches

public boolean matches(java.lang.String uri)
Determine whether a particular namespace is allowed by this wildcard

Parameters:
uri - the namespace to be tested. Supply "" for the null namespace.
Returns:
true if the wildcard allows this namespace, false if not.

getAllowedNamespaces

public java.util.Iterator getAllowedNamespaces()
Returns an enumeration that contains the permitted namespaces of this wildcard

Returns:
an enumeration that contains the permitted namespaces of this wildcard, or null if the wildcard uses the ##any or ##other options

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.

validate

public boolean validate(SchemaCompiler compiler)
                 throws SchemaException
Perform validation on this wildcard (this implementation of the method is a no-op)

Throws:
SchemaException

toString

public java.lang.String toString()
Get a string representation of this wildcard, used for diagnostics

Overrides:
toString in class java.lang.Object

isIntensionalSubset

public boolean isIntensionalSubset(Wildcard sup)
Determine whether this wildcard is an intensional subset of another wildcard. See Schema Part 1 Schema Component Constraint: Wildcard Subset (section 3.10.6)


overlaps

public boolean overlaps(Wildcard other)
Determine whether this wildcard overlaps another wildcard, that is, whether there is an element that could match either.


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)

makeIntersection

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

Parameters:
wat1 - the first operand: the processContents is taken from this operand
wat2 - the second operand
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)
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
Returns:
a new AttributeWildcard representing the intersection, 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.

serialize

public void serialize(SchemaModelSerializer serializer)
               throws XPathException
Serialize this schema component

Specified by:
serialize in interface SerializableSchemaComponent
Throws:
XPathException


Copyright (c) Saxonica Limited. All rights reserved.