com.saxonica.schema.sdoc
Class SchemaElement

java.lang.Object
  extended by net.sf.saxon.tree.linked.NodeImpl
      extended by net.sf.saxon.tree.linked.ElementImpl
          extended by com.saxonica.schema.sdoc.SchemaElement
All Implemented Interfaces:
Source, SourceLocator, PullEvent, FingerprintedNode, Item<NodeInfo>, MutableNodeInfo, NamespaceResolver, NodeInfo, ValueRepresentation<NodeInfo>, SiblingCountingNode
Direct Known Subclasses:
AnnotationParent, UnknownElement, XSDAnnotation, XSDAttribute, XSDAttributeGroup, XSDComplexContent, XSDComplexContentRestriction, XSDComplexType, XSDCompositor, XSDDocumentation, XSDElement, XSDExtension, XSDGroup, XSDIdentityConstraint, XSDList, XSDOverride, XSDRedefine, XSDSchema, XSDSimpleContent, XSDSimpleContentRestriction, XSDSimpleType, XSDSimpleTypeRestriction, XSDUnion

public abstract class SchemaElement
extends ElementImpl

An element in an XML Schema document. This is an abstract superclass for the elements in the schema document; many of its methods are designed to be called from the subclasses


Nested Class Summary
protected  class SchemaElement.XPathStaticContext
           
 
Field Summary
protected static String NAMESPACE_ANY
           
protected static String NAMESPACE_LOCAL
           
protected static String NAMESPACE_OTHER
           
protected static String NAMESPACE_TARGET
           
static int REQUIRE_NULL_NS
          Option indicating "no namespace prefix is allowed; the name is in the null Namespace"
static int REQUIRE_TARGET_NS
          Option indicating "no namespace prefix is allowed; the name is in the targetNamespace"
static int USE_DEFAULT_NS
          Option indicating "use the default element namespace when unprefixed"
static int USE_DEFAULT_NS_WITHOUT_IMPORT
          Option indicating "use the default element namespace when unprefixed", but without a requirement to have an xs:import
 
Fields inherited from class net.sf.saxon.tree.linked.NodeImpl
NODE_LETTER
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
 
Constructor Summary
SchemaElement()
          Construct a SchemaElement
 
Method Summary
protected  void addChild(NodeImpl node, int index)
          Add a child node to this node.
protected  int allocateAnonymousTypeCode()
          Allocate a name to an anonymous type.
 void allowAttributes(AttributeCollection atts, String[] allowed)
          Check the attributes of an element against a list of allowed attributes.
protected  void checkContentModel(int[][] stateTerms, int[][] stateTargets, boolean allowWildcards)
          Check the content model of an element in the schema.
 void checkLocalTargetNamespace(String elementOrAttribute)
          For an element or attribute declaration with a targetNamespace attribute (XSD 1.1), check the highly-paternalistic rules for when this attribute is permitted.
protected  void checkMutuallyExclusiveAttributes(String name1, String name2)
          This method tests whether two attributes coexist and reports an error if they do
protected  void checkOnlyChildIsAnnotation()
          Check that the only child element of this element is an (optional and non-repeatable) xs:annotation element
 void checkPermittedType(int fp, String name, String role)
          Check that a given type is a permitted type
 void compact(int size)
          Compact the space used by this node
protected  void duplicate(String category, String name)
          This method is called when two objects in the same symbol space within a schema have duplicate names
protected  void duplicateElement(String name)
          This method is called when two occurrences of a child element are found and only one is allowed.
protected  AxisIterator enumerateChildren(NodeTest test)
          Get an enumeration of the children of this node
protected  void error(SchemaException exception)
          This method is called for a general error.
protected  void error(String err)
          This method is called for a general error.
protected  UserComplexType getContainingComplexType()
          Get the complexType associated with the containing xs:complexType element
protected  SimpleTypeDefinition getContainingSimpleType()
          Get the simpleTypeDefinition associated with the containing xs:simpleType element
protected  int getFingerprint(String name, int option)
          This method is called to check that a QName is valid and allocate a fingerprint for the name in the namePool.
 NodeInfo getFirstChild()
          Get the first child node of the element
 NodeInfo getLastChild()
          Get the last child node of the element
protected  int getNameCode(String name, int option)
          This method is called to check that a QName is valid and allocate a nameCode for the name in the namePool.
protected  NodeImpl getNthChild(int n)
          Get the nth child node of the element (numbering from 0)
 int getNumberOfChildren()
          Determine how many children the node has
protected  int getRawSequenceNumber()
           
protected  SingleNamespaceSchema getSchema()
          Get the schema corresponding to the contents of the schema document containing this element
 SchemaNodeFactory getSchemaNodeFactory()
          Get the nodeFactory used to create this element.
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 String getStringValue()
          Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
 CharSequence getStringValueCS()
          Get the value of the item as a CharSequence.
 XSDSchema getXSDSchema()
          Get the owning XSDSchema element.
 boolean hasChildNodes()
          Determine if the node has any children.
protected  void illegalElement(NodeInfo child)
          This method is called when an illegal Element is encountered.
protected  String indefiniteArticle(String word, String start)
          Construct an indefinite article in English
 void insertChildren(NodeInfo[] source, boolean atStart, boolean inherit)
          Insert a sequence of nodes as children of this node.
protected  void insertChildrenAt(NodeInfo[] source, int index, boolean inherit)
          Insert children before or after a given existing child
 void invalidAttributeValue(String name, String value, String message)
          This method is called when an invalid attribute value is found
protected  boolean isFinalState(int state)
          For elements whose content model is parsed using a finite state machine, test whether a given state is a final state.
protected  boolean isTopLevel()
          Return true if this element is a child of xs:schema or xs:redefine
protected  SavedNamespaceContext makeNamespaceContext()
          Make a NamespaceContext object representing the list of in-scope namespaces.
 void missingAttribute(String name)
          This method is called when a required attribute is not found
 void missingChildElement(String name)
          This method is called when a required child element is not found
protected  void mustBeFirstElement(String name)
          This method is called when a child element is required to be the first child, but is found elsewhere
 void mustBeLastElement(String name)
          This method is called when a child element is required to be the first child, but is found elsewhere
protected  void mustPrecede(String name1, String name2)
          This method is called when two child elements are found in the wrong order.
protected  void mutuallyExclusive(String name1, String name2)
          This method is called when two child elements may not coexist
protected  void mutuallyExclusiveAttributes(String name1, String name2)
          This method is called when two attributes may not coexist
protected  void mutuallyExclusiveElementAndAttribute(String elem, String att)
          This method is called when an attribute and a child elements may not coexist
 boolean parseBooleanAttribute(String name, String value)
          Parse a boolean attribute value
 int parseFinalOrBlock(String attrName, String finalValue, int allowed)
          Parse a list of blocked or final derivations.
 void postValidate(SchemaCompiler compiler)
          Hook to allow additional validation of a parent element immediately after its children have been validated.
abstract  void prepareAttributes()
          Set the attribute list for the element.
 void processAllAttributes()
          Process the attributes of this element and all its children
protected  void processAllowedNamespaces(String attValue, Wildcard wildcard)
          Process the namespaces attribute of XSDAny or XSDAnyAttribute
protected  void processDisallowedNamespaces(String attValue, Wildcard wildcard)
          Process the notNamespaces attribute of XSDAny or XSDAnyAttribute
protected  void processDisallowedQNames(String attValue, Wildcard wildcard)
          Process the notQNames attribute of XSDAny or XSDAnyAttribute
 void processId()
          Process an @id attribute on the schema element: if present, check that it is a valid ID, and that it is unique in the schema document
 int processMaxOccurs(String attValue)
          Process the value of a maxOccurs attribute on any element where it appears
 int processMinOccurs(String attValue)
          Process the value of a minOccurs attribute on any element where it appears
protected  void removeChild(NodeImpl child)
          Remove a given child
protected  void replaceChildrenAt(NodeInfo[] source, int index, boolean inherit)
          Replace child at a given index by new children
 void requireAttribute(AttributeCollection atts, String required)
          Indicate that a particular attribute is required
protected  void setChildren(Object children)
          Set the children of this node
protected  void setRawSequenceNumber(int seq)
           
 void setSchemaNodeFactory(SchemaNodeFactory factory)
          Set the nodeFactory used to create this element.
 void validate(SchemaCompiler compiler)
          Check that the schema element is valid.
protected  void validateChildren(SchemaCompiler compiler)
          Validate the children of this node, recursively.
 void validateSubtree(SchemaCompiler compiler)
          Recursive walk through the schema to validate all nodes
protected  void warning(String err)
          Report a warning
 
Methods inherited from class net.sf.saxon.tree.linked.ElementImpl
addAttribute, addNamespace, copy, delete, fixupInsertedNamespaces, generateId, getAttributeList, getAttributeValue, getAttributeValue, getBaseURI, getColumnNumber, getDeclaredNamespaces, getDocumentRoot, getLineNumber, getNameCode, getNamespaceList, getNodeKind, getPrefixForURI, getRoot, getSchemaType, getSystemId, getTypeAnnotation, getURIForPrefix, gsetAttributeCollection, initialise, isId, isNilled, iteratePrefixes, removeAttribute, removeTypeAnnotation, rename, replaceStringValue, setAttributeList, setLocation, setNameCode, setNamespaceDeclarations, setNamespaceList, setSystemId, setTypeAnnotation
 
Methods inherited from class net.sf.saxon.tree.linked.NodeImpl
atomize, compareOrder, equals, getConfiguration, getDisplayName, getDocumentNumber, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getRawParent, getSiblingPosition, getTypedValue, getURI, insertSiblings, isDeleted, isIdref, isSameNodeInfo, iterateAxis, iterateAxis, newBuilder, replace, setRawParent, setSiblingPosition
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.NodeInfo
hashCode
 

Field Detail

USE_DEFAULT_NS

public static final int USE_DEFAULT_NS
Option indicating "use the default element namespace when unprefixed"

See Also:
Constant Field Values

REQUIRE_TARGET_NS

public static final int REQUIRE_TARGET_NS
Option indicating "no namespace prefix is allowed; the name is in the targetNamespace"

See Also:
Constant Field Values

REQUIRE_NULL_NS

public static final int REQUIRE_NULL_NS
Option indicating "no namespace prefix is allowed; the name is in the null Namespace"

See Also:
Constant Field Values

USE_DEFAULT_NS_WITHOUT_IMPORT

public static final int USE_DEFAULT_NS_WITHOUT_IMPORT
Option indicating "use the default element namespace when unprefixed", but without a requirement to have an xs:import

See Also:
Constant Field Values

NAMESPACE_ANY

protected static final String NAMESPACE_ANY
See Also:
Constant Field Values

NAMESPACE_LOCAL

protected static final String NAMESPACE_LOCAL
See Also:
Constant Field Values

NAMESPACE_OTHER

protected static final String NAMESPACE_OTHER
See Also:
Constant Field Values

NAMESPACE_TARGET

protected static final String NAMESPACE_TARGET
See Also:
Constant Field Values
Constructor Detail

SchemaElement

public SchemaElement()
Construct a SchemaElement

Method Detail

isTopLevel

protected boolean isTopLevel()
Return true if this element is a child of xs:schema or xs:redefine

Returns:
true if this element is a child of xs:schema or xs:redefine

setSchemaNodeFactory

public void setSchemaNodeFactory(SchemaNodeFactory factory)
Set the nodeFactory used to create this element.

Parameters:
factory - the schema node factory

getSchemaNodeFactory

public SchemaNodeFactory getSchemaNodeFactory()
Get the nodeFactory used to create this element. This nodeFactory is used to keep track of any errors encountered during construction of the schema document

Returns:
factory the schema node factory

processAllAttributes

public void processAllAttributes()
                          throws SchemaException
Process the attributes of this element and all its children

Throws:
SchemaException

prepareAttributes

public abstract void prepareAttributes()
                                throws SchemaException
Set the attribute list for the element. This is called to process the attributes (note the distinction from processAttributes in the superclass). Must be supplied in a subclass

Throws:
SchemaException

allowAttributes

public void allowAttributes(AttributeCollection atts,
                            String[] allowed)
                     throws SchemaException
Check the attributes of an element against a list of allowed attributes. Report an error if any extraneous attribute is present

Parameters:
atts - the attributes actually present
allowed - the attributes that are allowed for this element. They must be listed in alphabetical order
Throws:
SchemaException

requireAttribute

public void requireAttribute(AttributeCollection atts,
                             String required)
                      throws SchemaException
Indicate that a particular attribute is required

Parameters:
atts - the attribtue collection
required - the local name of the required attribute, which must be in the null namespace
Throws:
SchemaException

validateSubtree

public void validateSubtree(SchemaCompiler compiler)
                     throws SchemaException
Recursive walk through the schema to validate all nodes

Parameters:
compiler - used for error reporting
Throws:
SchemaException

validateChildren

protected void validateChildren(SchemaCompiler compiler)
                         throws SchemaException
Validate the children of this node, recursively.

Parameters:
compiler - used for error reporting
Throws:
SchemaException - if the subtree is not valid

validate

public void validate(SchemaCompiler compiler)
              throws SchemaException
Check that the schema element is valid. This is called once for each element, after the entire tree has been built. As well as validation, it can perform first-time initialisation. The default implementation does nothing; it is normally overriden in subclasses.

Parameters:
compiler - used for error reporting
Throws:
SchemaException - if the subtree is not valid

postValidate

public void postValidate(SchemaCompiler compiler)
                  throws SchemaException
Hook to allow additional validation of a parent element immediately after its children have been validated.

Parameters:
compiler - used for error reporting
Throws:
SchemaException - if errors are found

getXSDSchema

public XSDSchema getXSDSchema()
                       throws SchemaException
Get the owning XSDSchema element.

Returns:
the containing xs:schema element
Throws:
SchemaException - if none is found (which means the schema is invalid)

getSchema

protected SingleNamespaceSchema getSchema()
                                   throws SchemaException
Get the schema corresponding to the contents of the schema document containing this element

Returns:
the PreparedSchema object used to assemble the schema components defined in the schema document that contains this element.
Throws:
SchemaException - if the containing PreparedSchema cannot be found

getContainingComplexType

protected UserComplexType getContainingComplexType()
                                            throws SchemaException
Get the complexType associated with the containing xs:complexType element

Returns:
the UserComplexType object representing the containing complex type
Throws:
SchemaException - if the element is not contained in an xs:complexType

getContainingSimpleType

protected SimpleTypeDefinition getContainingSimpleType()
                                                throws SchemaException
Get the simpleTypeDefinition associated with the containing xs:simpleType element

Returns:
the schema component representing the containing simple type
Throws:
SchemaException - if not contained in an xs:simpleType

makeNamespaceContext

protected SavedNamespaceContext makeNamespaceContext()
Make a NamespaceContext object representing the list of in-scope namespaces. The NamePool used for numeric codes in the NamespaceContext will be the target name pool.

Returns:
a copy of the namespace context for this element

checkPermittedType

public void checkPermittedType(int fp,
                               String name,
                               String role)
                        throws SchemaException
Check that a given type is a permitted type

Throws:
SchemaException

parseBooleanAttribute

public boolean parseBooleanAttribute(String name,
                                     String value)
                              throws SchemaException
Parse a boolean attribute value

Parameters:
name - the name of the attribute (for diagnostics)
value - the string value of the attribute (need not be trimmed)
Returns:
the boolean value of the attribute if it is valid
Throws:
SchemaException - if the value is not a valid boolean

error

protected void error(String err)
              throws SchemaException
This method is called for a general error. The location of this message is the current element.

Parameters:
err - the error message to report
Throws:
SchemaException

error

protected void error(SchemaException exception)
              throws SchemaException
This method is called for a general error. The location of this message is the current element.

Parameters:
exception - the error message to report
Throws:
SchemaException

warning

protected void warning(String err)
Report a warning

Parameters:
err - the warning message

getFingerprint

protected int getFingerprint(String name,
                             int option)
                      throws SchemaException
This method is called to check that a QName is valid and allocate a fingerprint for the name in the namePool. If the QName isn't valid, the method throws an exception: it is the caller's responsibility to call the error handler and recover from the error. The method makes use of the namespace context information for the schema element.

Parameters:
name - The QName
option - The option for handling unprefixed names. Options are to use the default namespace, the target namespace, or the null namespace Note that this method assumes the name, if unprefixed, is in the default namespace: NOT the targetNamespace of the schema.
Returns:
a fingerprint
Throws:
SchemaException - if the QName is invalid.

getNameCode

protected int getNameCode(String name,
                          int option)
                   throws SchemaException
This method is called to check that a QName is valid and allocate a nameCode for the name in the namePool. If the QName isn't valid, the method throws an exception: it is the caller's responsibility to call the error handler and recover from the error. The method makes use of the namespace context information for the schema element.

Parameters:
name - The QName
option - The option for handling unprefixed names. Options are to use the default namespace USE_DEFAULT_NS, the target namespace REQUIRE_TARGET_NS, or the null namespace REQUIRE_NULL_NS
Returns:
an integer name code
Throws:
SchemaException - if the QName is invalid.

checkOnlyChildIsAnnotation

protected void checkOnlyChildIsAnnotation()
                                   throws SchemaException
Check that the only child element of this element is an (optional and non-repeatable) xs:annotation element

Throws:
SchemaException

illegalElement

protected void illegalElement(NodeInfo child)
                       throws SchemaException
This method is called when an illegal Element is encountered.

Parameters:
child - The child element whose presence is an error
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

duplicateElement

protected void duplicateElement(String name)
                         throws SchemaException
This method is called when two occurrences of a child element are found and only one is allowed.

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

duplicate

protected void duplicate(String category,
                         String name)
                  throws SchemaException
This method is called when two objects in the same symbol space within a schema have duplicate names

Parameters:
category - the name of the first attribute
name - the name of the second attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusive

protected void mutuallyExclusive(String name1,
                                 String name2)
                          throws SchemaException
This method is called when two child elements may not coexist

Parameters:
name1 - the name of the first element
name2 - the name of the second element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusiveElementAndAttribute

protected void mutuallyExclusiveElementAndAttribute(String elem,
                                                    String att)
                                             throws SchemaException
This method is called when an attribute and a child elements may not coexist

Parameters:
elem - the name of the element
att - the name of the attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mutuallyExclusiveAttributes

protected void mutuallyExclusiveAttributes(String name1,
                                           String name2)
                                    throws SchemaException
This method is called when two attributes may not coexist

Parameters:
name1 - the name of the first attribute
name2 - the name of the second attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

checkMutuallyExclusiveAttributes

protected void checkMutuallyExclusiveAttributes(String name1,
                                                String name2)
                                         throws SchemaException
This method tests whether two attributes coexist and reports an error if they do

Parameters:
name1 - the local name of the first attribute (must be in the null namespace)
name2 - the local name of the second attribute (must be in the null namespace)
Throws:
SchemaException

mustPrecede

protected void mustPrecede(String name1,
                           String name2)
                    throws SchemaException
This method is called when two child elements are found in the wrong order.

Parameters:
name1 - the name of the element that should be first
name2 - the name of the element that should be second
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

mustBeFirstElement

protected void mustBeFirstElement(String name)
                           throws SchemaException
This method is called when a child element is required to be the first child, but is found elsewhere

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

indefiniteArticle

protected String indefiniteArticle(String word,
                                   String start)
Construct an indefinite article in English

Parameters:
word - The word to follow the article
start - Typically "a" or "A"
Returns:
the indefinite article

mustBeLastElement

public void mustBeLastElement(String name)
                       throws SchemaException
This method is called when a child element is required to be the first child, but is found elsewhere

Parameters:
name - the name of the illegal element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

invalidAttributeValue

public void invalidAttributeValue(String name,
                                  String value,
                                  String message)
                           throws SchemaException
This method is called when an invalid attribute value is found

Parameters:
name - the name of the attribute
value - the supplied value of the attribute
message - additional explanation of why it's wrong. May be null.
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

missingAttribute

public void missingAttribute(String name)
                      throws SchemaException
This method is called when a required attribute is not found

Parameters:
name - the name of the attribute
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

missingChildElement

public void missingChildElement(String name)
                         throws SchemaException
This method is called when a required child element is not found

Parameters:
name - the name of the required child element
Throws:
SchemaException - thrown if the errorListener decides that it's a fatal error.

parseFinalOrBlock

public int parseFinalOrBlock(String attrName,
                             String finalValue,
                             int allowed)
                      throws SchemaException
Parse a list of blocked or final derivations. Used to process the block, final, blockDefault, and finalDefault attributes.

Parameters:
attrName - the name of the attribute being parsed
finalValue - A list of values to be parsed, as a string, for example "extension restriction"
allowed - The permitted values, as a bit-significant integer. For example the value (DERIVE_BY_EXTENSION | DERIVE_BY_RESTRICTION) allows the values "extension" and "restriction" to appear.
Returns:
The final/blocked values, as a bit-significant integer
Throws:
SchemaException

processId

public void processId()
               throws SchemaException
Process an @id attribute on the schema element: if present, check that it is a valid ID, and that it is unique in the schema document

Throws:
SchemaException - if the id is present and is invalid or is a duplicate

allocateAnonymousTypeCode

protected int allocateAnonymousTypeCode()
Allocate a name to an anonymous type. It's important that the name allocated should be repeatable, because it can be referenced as a type annotation in a PTree document.

Returns:
the name code of the allocated name

processMaxOccurs

public int processMaxOccurs(String attValue)
                     throws SchemaException
Process the value of a maxOccurs attribute on any element where it appears

Parameters:
attValue - the value of the attribute as written, either "unbounded" or an integer
Returns:
the value of the attribute as an integer, or -1 indicating "unbounded"
Throws:
SchemaException - if the value is invalid (in which case the error will have been reported). If the value is a very high integer (greater than Integer.MAX_VALUE), the method outputs a warning and treats the value as "unbounded".

processMinOccurs

public int processMinOccurs(String attValue)
                     throws SchemaException
Process the value of a minOccurs attribute on any element where it appears

Parameters:
attValue - the value of the attribute as written, an integer
Returns:
the value of the attribute as an integer
Throws:
SchemaException - if the value is invalid (in which case the error will have been reported). If the value is a very high integer (greater than Integer.MAX_VALUE), the method outputs a warning and treats the value as Integer.MAX_VALUE.

checkContentModel

protected void checkContentModel(int[][] stateTerms,
                                 int[][] stateTargets,
                                 boolean allowWildcards)
                          throws SchemaException
Check the content model of an element in the schema. This uses a finite state machine generated into the Java source code by applying an XSLT transformation to the schema component model for the Schema for Schemas.

The finite state machine is generated as follows: First process the S4S to create an SCM model, then apply the stylesheet generate-S4S-code in the build directory with type=complexType, for example. The value of the type parameter can be either the name of the type or its ID in the SCM file.

Parameters:
stateTerms - an array of states, and for each state, an array containing the fingerprints of elements allowed to appear in that state
stateTargets - an array of states, and for each state, an array containing the destinations of transitions when the corresponding term from stateTerms is encountered
allowWildcards -
Throws:
SchemaException - if the schema being processed does not conform to the required content model

isFinalState

protected boolean isFinalState(int state)
For elements whose content model is parsed using a finite state machine, test whether a given state is a final state. The default implementation of this method is never used; it exists for the benefit of subclasses that do not use this mechanism

Parameters:
state - the state to be tested
Returns:
true if the given state is a final state

processAllowedNamespaces

protected void processAllowedNamespaces(String attValue,
                                        Wildcard wildcard)
                                 throws SchemaException
Process the namespaces attribute of XSDAny or XSDAnyAttribute

Parameters:
attValue - the value of the attribute
wildcard - the wildcard object being constructed
Throws:
SchemaException - if the attribute is in error

processDisallowedNamespaces

protected void processDisallowedNamespaces(String attValue,
                                           Wildcard wildcard)
                                    throws SchemaException
Process the notNamespaces attribute of XSDAny or XSDAnyAttribute

Parameters:
attValue - the value of the attribute
wildcard - the wildcard object being constructed
Throws:
SchemaException - if the attribute is in error

processDisallowedQNames

protected void processDisallowedQNames(String attValue,
                                       Wildcard wildcard)
                                throws SchemaException
Process the notQNames attribute of XSDAny or XSDAnyAttribute

Parameters:
attValue - the value of the attribute
wildcard - the wildcard object being constructed
Throws:
SchemaException - if the attribute is in error

checkLocalTargetNamespace

public void checkLocalTargetNamespace(String elementOrAttribute)
                               throws SchemaException
For an element or attribute declaration with a targetNamespace attribute (XSD 1.1), check the highly-paternalistic rules for when this attribute is permitted.

Parameters:
elementOrAttribute - the string "element" or "attribute" for error messages
Throws:
SchemaException - if the rules are not satisfied

getSequenceNumber

protected final long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and document nodes) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position. For nodes added by XQUery Update, the sequence number is -1L

Overrides:
getSequenceNumber in class NodeImpl
Returns:
the sequence number if there is one, or -1L otherwise.

getRawSequenceNumber

protected final int getRawSequenceNumber()

setRawSequenceNumber

protected final void setRawSequenceNumber(int seq)

setChildren

protected final void setChildren(Object children)
Set the children of this node

Parameters:
children - null if there are no children, a single NodeInfo if there is one child, an array of NodeInfo if there are multiple children

hasChildNodes

public final boolean hasChildNodes()
Determine if the node has any children.

Specified by:
hasChildNodes in interface NodeInfo
Overrides:
hasChildNodes in class NodeImpl
Returns:
true if the node has any children, false if the node has no children.

getNumberOfChildren

public final int getNumberOfChildren()
Determine how many children the node has

Returns:
the number of children of this parent node

enumerateChildren

protected final AxisIterator enumerateChildren(NodeTest test)
Get an enumeration of the children of this node

Parameters:
test - A NodeTest to be satisfied by the child nodes, or null if all child node are to be returned
Returns:
an iterator over the children of this node

getFirstChild

public final NodeInfo getFirstChild()
Get the first child node of the element

Overrides:
getFirstChild in class NodeImpl
Returns:
the first child node of the required type, or null if there are no children

getLastChild

public final NodeInfo getLastChild()
Get the last child node of the element

Overrides:
getLastChild in class NodeImpl
Returns:
the last child of the element, or null if there are no children

getNthChild

protected final NodeImpl getNthChild(int n)
Get the nth child node of the element (numbering from 0)

Parameters:
n - identifies the required child
Returns:
the last child of the element, or null if there is no n'th child

removeChild

protected void removeChild(NodeImpl child)
Remove a given child

Parameters:
child - the child to be removed

getStringValue

public String getStringValue()
Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.

Returns:
the accumulated character content of the element, including descendant elements.
See Also:
Item.getStringValueCS()

getStringValueCS

public CharSequence getStringValueCS()
Description copied from class: NodeImpl
Get the value of the item as a CharSequence. This is in some cases more efficient than the version of the method that returns a String.

Specified by:
getStringValueCS in interface Item<NodeInfo>
Specified by:
getStringValueCS in interface ValueRepresentation<NodeInfo>
Overrides:
getStringValueCS in class NodeImpl
Returns:
the string value of the item
See Also:
Item.getStringValue()

addChild

protected void addChild(NodeImpl node,
                        int index)
Add a child node to this node. For system use only. Note: normalizing adjacent text nodes is the responsibility of the caller.

Parameters:
node - the node to be added as a child of this node. This must be an instance of NodeImpl. It will be modified as a result of this call (by setting its parent property and sibling position)
index - the position where the child is to be added

insertChildren

public void insertChildren(NodeInfo[] source,
                           boolean atStart,
                           boolean inherit)
Insert a sequence of nodes as children of this node.

This method takes no action unless the target node is a document node or element node. It also takes no action in respect of any supplied nodes that are not elements, text nodes, comments, or processing instructions.

The supplied nodes will form the new children. Adjacent text nodes will be merged, and zero-length text nodes removed. The supplied nodes may be modified in situ, for example to change their parent property and to add namespace bindings, or they may be copied, at the discretion of the implementation.

Specified by:
insertChildren in interface MutableNodeInfo
Overrides:
insertChildren in class NodeImpl
Parameters:
source - the nodes to be inserted. The implementation determines what implementation classes of node it will accept; this implementation will accept text, comment, and processing instruction nodes belonging to any implementation, but elements must be instances of ElementImpl. The supplied nodes will be modified in situ, for example to change their parent property and to add namespace bindings, if they are instances of ElementImpl; otherwise they will be copied. If the nodes are copied, then on return the supplied source array will contain the copy rather than the original.
atStart - true if the new nodes are to be inserted before existing children; false if they are to be inserted after existing children
inherit - true if the inserted nodes are to inherit the namespaces of their new parent; false if such namespaces are to be undeclared
Throws:
IllegalArgumentException - if the supplied nodes use a node implementation that this implementation does not accept.

insertChildrenAt

protected void insertChildrenAt(NodeInfo[] source,
                                int index,
                                boolean inherit)
Insert children before or after a given existing child

Parameters:
source - the children to be inserted. We allow any kind of text, comment, or processing instruction node, but element nodes must be instances of this NodeInfo implementation.
index - the position before which they are to be inserted: 0 indicates insertion before the first child, 1 insertion before the second child, and so on.
inherit - true if the inserted nodes are to inherit the namespaces that are in-scope for their new parent; false if such namespaces should be undeclared on the children

replaceChildrenAt

protected void replaceChildrenAt(NodeInfo[] source,
                                 int index,
                                 boolean inherit)
Replace child at a given index by new children

Parameters:
source - the children to be inserted
index - the position at which they are to be inserted: 0 indicates replacement of the first child, replacement of the second child, and so on. The effect is undefined if index is out of range
inherit - set to true if the new child elements are to inherit the in-scope namespaces of their new parent
Throws:
IllegalArgumentException - if any of the replacement nodes is not an element, text, comment, or processing instruction node

compact

public void compact(int size)
Compact the space used by this node

Parameters:
size - the number of actual children


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.