public abstract class SchemaElement extends ElementImpl
Modifier and Type | Class and Description |
---|---|
protected class |
SchemaElement.XPathStaticContext |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
NAMESPACE_ANY |
protected static java.lang.String |
NAMESPACE_LOCAL |
protected static java.lang.String |
NAMESPACE_OTHER |
protected static java.lang.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
|
NODE_LETTER
ALL_NAMESPACES, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
Constructor and Description |
---|
SchemaElement()
Construct a SchemaElement
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(NodeImpl node,
int index)
Add a child node to this node.
|
protected NodeName |
allocateAnonymousTypeCode()
Allocate a name to an anonymous type.
|
void |
allowAttributes(AttributeCollection atts,
java.lang.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(java.lang.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(java.lang.String name1,
java.lang.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,
java.lang.String name,
java.lang.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(java.lang.String category,
java.lang.String name)
This method is called when two objects in the same symbol space within
a schema have duplicate names
|
protected void |
duplicateElement(java.lang.String name)
This method is called when two occurrences of a child element are found
and only one is allowed.
|
protected void |
error(SchemaException exception)
This method is called for a general error.
|
protected void |
error(java.lang.String err)
This method is called for a general error.
|
protected StructuredQName |
getComponentName(java.lang.String name,
int option)
This method is called to check that a lexical QName is valid and allocate a
nameCode for the name in the namePool.
|
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(java.lang.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.
|
NodeImpl |
getFirstChild()
Get the first child node of the element
|
NodeImpl |
getLastChild()
Get the last child node of the element
|
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).
|
java.lang.String |
getStringValue()
Return the string-value of the node, that is, the concatenation
of the character content of all descendent elements and text nodes.
|
java.lang.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 java.lang.String |
indefiniteArticle(java.lang.String word,
java.lang.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(java.lang.String name,
java.lang.String value,
java.lang.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 AxisIterator |
iterateChildren(NodeTest test)
Get an enumeration of the children of this node
|
protected NamespaceResolver |
makeNamespaceContext()
Make a NamespaceContext object representing the list of in-scope namespaces.
|
void |
missingAttribute(java.lang.String name)
This method is called when a required attribute is not found
|
void |
missingChildElement(java.lang.String name)
This method is called when a required child element is not found
|
protected void |
mustBeFirstElement(java.lang.String name)
This method is called when a child element is required to be the first
child, but is found elsewhere
|
void |
mustBeLastElement(java.lang.String name)
This method is called when a child element is required to be the first
child, but is found elsewhere
|
protected void |
mustPrecede(java.lang.String name1,
java.lang.String name2)
This method is called when two child elements are found
in the wrong order.
|
protected void |
mutuallyExclusive(java.lang.String name1,
java.lang.String name2)
This method is called when two child elements may not coexist
|
protected void |
mutuallyExclusiveAttributes(java.lang.String name1,
java.lang.String name2)
This method is called when two attributes may not coexist
|
protected void |
mutuallyExclusiveElementAndAttribute(java.lang.String elem,
java.lang.String att)
This method is called when an attribute and a child elements may not coexist
|
boolean |
parseBooleanAttribute(java.lang.String name,
java.lang.String value)
Parse a boolean attribute value
|
int |
parseFinalOrBlock(java.lang.String attrName,
java.lang.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(java.lang.String attValue,
Wildcard wildcard)
Process the namespaces attribute of XSDAny or XSDAnyAttribute
|
protected void |
processDisallowedNamespaces(java.lang.String attValue,
Wildcard wildcard)
Process the notNamespaces attribute of XSDAny or XSDAnyAttribute
|
protected void |
processDisallowedQNames(java.lang.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(java.lang.String attValue)
Process the value of a maxOccurs attribute on any element where it appears
|
int |
processMinOccurs(java.lang.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,
java.lang.String required)
Indicate that a particular attribute is required
|
protected void |
setChildren(java.lang.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(java.lang.String err)
Report a warning
|
addAttribute, addNamespace, copy, delete, fixupInsertedNamespaces, generateId, getAttributeList, getAttributeValue, getBaseURI, getColumnNumber, getDeclaredNamespaces, getLineNumber, getNamespaceList, getNodeKind, getNodeName, getRoot, getSchemaType, getSystemId, getURIForPrefix, gsetAttributeCollection, initialise, isId, isInScopeNamespace, isNilled, iteratePrefixes, removeAttribute, removeTypeAnnotation, rename, replaceStringValue, setAttributeList, setLocation, setNamespaceDeclarations, setNamespaceList, setNilled, setNodeName, setSystemId, setTypeAnnotation
atomize, compareOrder, comparePosition, equals, getConfiguration, getDisplayName, getFingerprint, getLocalPart, getNamePool, getNextInDocument, getNextSibling, getParent, getPhysicalRoot, getPrefix, getPreviousInDocument, getPreviousSibling, getPublicId, getRawParent, getSiblingPosition, getSuccessorElement, getTreeInfo, getURI, hasFingerprint, head, insertSiblings, isDeleted, isIdref, isSameNodeInfo, isStreamed, iterate, iterateAxis, iterateAxis, newBuilder, replace, saveLocation, setRawParent, setSiblingPosition
public static final int USE_DEFAULT_NS
public static final int REQUIRE_TARGET_NS
public static final int REQUIRE_NULL_NS
public static final int USE_DEFAULT_NS_WITHOUT_IMPORT
protected static final java.lang.String NAMESPACE_ANY
protected static final java.lang.String NAMESPACE_LOCAL
protected static final java.lang.String NAMESPACE_OTHER
protected static final java.lang.String NAMESPACE_TARGET
protected boolean isTopLevel()
public void setSchemaNodeFactory(SchemaNodeFactory factory)
factory
- the schema node factorypublic SchemaNodeFactory getSchemaNodeFactory()
public void processAllAttributes() throws SchemaException
SchemaException
public abstract void prepareAttributes() throws SchemaException
SchemaException
public void allowAttributes(AttributeCollection atts, java.lang.String[] allowed) throws SchemaException
atts
- the attributes actually presentallowed
- the attributes that are allowed for this element. They must
be listed in alphabetical orderSchemaException
public void requireAttribute(AttributeCollection atts, java.lang.String required) throws SchemaException
atts
- the attribtue collectionrequired
- the local name of the required attribute, which must be in the null namespaceSchemaException
public void validateSubtree(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
protected void validateChildren(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
- if the subtree is not validpublic void validate(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
- if the subtree is not validpublic void postValidate(SchemaCompiler compiler) throws SchemaException
compiler
- used for error reportingSchemaException
- if errors are foundpublic XSDSchema getXSDSchema() throws SchemaException
SchemaException
- if none is found (which means the schema is invalid)protected SingleNamespaceSchema getSchema() throws SchemaException
SchemaException
- if the containing PreparedSchema cannot be foundprotected UserComplexType getContainingComplexType() throws SchemaException
SchemaException
- if the element is not contained in an xs:complexTypeprotected SimpleTypeDefinition getContainingSimpleType() throws SchemaException
SchemaException
- if not contained in an xs:simpleTypeprotected NamespaceResolver makeNamespaceContext()
public void checkPermittedType(int fp, java.lang.String name, java.lang.String role) throws SchemaException
SchemaException
public boolean parseBooleanAttribute(java.lang.String name, java.lang.String value) throws SchemaException
name
- the name of the attribute (for diagnostics)value
- the string value of the attribute (need not be trimmed)SchemaException
- if the value is not a valid booleanprotected void error(java.lang.String err) throws SchemaException
err
- the error message to reportSchemaException
protected void error(SchemaException exception) throws SchemaException
exception
- the error message to reportSchemaException
protected void warning(java.lang.String err)
err
- the warning messageprotected int getFingerprint(java.lang.String name, int option) throws SchemaException
name
- The QNameoption
- 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.SchemaException
- if the QName is invalid.protected StructuredQName getComponentName(java.lang.String name, int option) throws SchemaException
name
- The QName as written in the schemaoption
- 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
SchemaException
- if the QName is invalid.protected void checkOnlyChildIsAnnotation() throws SchemaException
SchemaException
protected void illegalElement(NodeInfo child) throws SchemaException
child
- The child element whose presence is an errorSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void duplicateElement(java.lang.String name) throws SchemaException
name
- the name of the illegal elementSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void duplicate(java.lang.String category, java.lang.String name) throws SchemaException
category
- the name of the first attributename
- the name of the second attributeSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void mutuallyExclusive(java.lang.String name1, java.lang.String name2) throws SchemaException
name1
- the name of the first elementname2
- the name of the second elementSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void mutuallyExclusiveElementAndAttribute(java.lang.String elem, java.lang.String att) throws SchemaException
elem
- the name of the elementatt
- the name of the attributeSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void mutuallyExclusiveAttributes(java.lang.String name1, java.lang.String name2) throws SchemaException
name1
- the name of the first attributename2
- the name of the second attributeSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void checkMutuallyExclusiveAttributes(java.lang.String name1, java.lang.String name2) throws SchemaException
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)SchemaException
protected void mustPrecede(java.lang.String name1, java.lang.String name2) throws SchemaException
name1
- the name of the element that should be firstname2
- the name of the element that should be secondSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected void mustBeFirstElement(java.lang.String name) throws SchemaException
name
- the name of the illegal elementSchemaException
- thrown if the errorListener
decides that it's a fatal error.protected java.lang.String indefiniteArticle(java.lang.String word, java.lang.String start)
word
- The word to follow the articlestart
- Typically "a" or "A"public void mustBeLastElement(java.lang.String name) throws SchemaException
name
- the name of the illegal elementSchemaException
- thrown if the errorListener
decides that it's a fatal error.public void invalidAttributeValue(java.lang.String name, java.lang.String value, java.lang.String message) throws SchemaException
name
- the name of the attributevalue
- the supplied value of the attributemessage
- additional explanation of why it's wrong. May be null.SchemaException
- thrown if the errorListener
decides that it's a fatal error.public void missingAttribute(java.lang.String name) throws SchemaException
name
- the name of the attributeSchemaException
- thrown if the errorListener
decides that it's a fatal error.public void missingChildElement(java.lang.String name) throws SchemaException
name
- the name of the required child elementSchemaException
- thrown if the errorListener
decides that it's a fatal error.public int parseFinalOrBlock(java.lang.String attrName, java.lang.String finalValue, int allowed) throws SchemaException
attrName
- the name of the attribute being parsedfinalValue
- 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.SchemaException
- if the value of the attribute is invalidpublic void processId() throws SchemaException
SchemaException
- if the id is present and is invalid or is a duplicateprotected NodeName allocateAnonymousTypeCode()
public int processMaxOccurs(java.lang.String attValue) throws SchemaException
attValue
- the value of the attribute as written, either "unbounded" or an integerSchemaException
- 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".public int processMinOccurs(java.lang.String attValue) throws SchemaException
attValue
- the value of the attribute as written, an integerSchemaException
- 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.protected void checkContentModel(int[][] stateTerms, int[][] stateTargets, boolean allowWildcards) throws SchemaException
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.
stateTerms
- an array of states, and for each state, an array containing the fingerprints
of elements allowed to appear in that statestateTargets
- an array of states, and for each state, an array containing the destinations
of transitions when the corresponding term from stateTerms is encounteredallowWildcards
- SchemaException
- if the schema being processed does not conform to the required content modelprotected boolean isFinalState(int state)
state
- the state to be testedprotected void processAllowedNamespaces(java.lang.String attValue, Wildcard wildcard) throws SchemaException
attValue
- the value of the attributewildcard
- the wildcard object being constructedSchemaException
- if the attribute is in errorprotected void processDisallowedNamespaces(java.lang.String attValue, Wildcard wildcard) throws SchemaException
attValue
- the value of the attributewildcard
- the wildcard object being constructedSchemaException
- if the attribute is in errorprotected void processDisallowedQNames(java.lang.String attValue, Wildcard wildcard) throws SchemaException
attValue
- the value of the attributewildcard
- the wildcard object being constructedSchemaException
- if the attribute is in errorpublic void checkLocalTargetNamespace(java.lang.String elementOrAttribute) throws SchemaException
elementOrAttribute
- the string "element" or "attribute" for error messagesSchemaException
- if the rules are not satisfiedprotected final long getSequenceNumber()
getSequenceNumber
in class NodeImpl
protected final int getRawSequenceNumber()
protected final void setRawSequenceNumber(int seq)
protected final void setChildren(java.lang.Object children)
children
- null if there are no children, a single NodeInfo if there is one child, an array of NodeInfo
if there are multiple childrenpublic final boolean hasChildNodes()
hasChildNodes
in interface NodeInfo
hasChildNodes
in class NodeImpl
true
if the node has any children,
false
if the node has no children.public final int getNumberOfChildren()
protected final AxisIterator iterateChildren(NodeTest test)
test
- A NodeTest to be satisfied by the child nodes, or null
if all child node are to be returnedpublic final NodeImpl getFirstChild()
getFirstChild
in interface SteppingNode<NodeImpl>
getFirstChild
in class NodeImpl
public final NodeImpl getLastChild()
getLastChild
in class NodeImpl
protected final NodeImpl getNthChild(int n)
n
- identifies the required childprotected void removeChild(NodeImpl child)
child
- the child to be removedpublic java.lang.String getStringValue()
Item.getStringValueCS()
public java.lang.CharSequence getStringValueCS()
NodeImpl
getStringValueCS
in interface Item
getStringValueCS
in class NodeImpl
Item.getStringValue()
protected void addChild(NodeImpl node, int index)
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 addedpublic void insertChildren(NodeInfo[] source, boolean atStart, boolean inherit)
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.
insertChildren
in interface MutableNodeInfo
insertChildren
in class NodeImpl
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 childreninherit
- true if the inserted nodes are to inherit the namespaces of their new parent; false
if such namespaces are to be undeclaredjava.lang.IllegalArgumentException
- if the supplied nodes use a node implementation that this
implementation does not accept.protected void insertChildrenAt(NodeInfo[] source, int index, boolean inherit)
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 childrenprotected void replaceChildrenAt(NodeInfo[] source, int index, boolean inherit)
source
- the children to be insertedindex
- 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 rangeinherit
- set to true if the new child elements are to inherit the in-scope namespaces
of their new parentjava.lang.IllegalArgumentException
- if any of the replacement nodes is not an element, text,
comment, or processing instruction nodepublic void compact(int size)
size
- the number of actual childrenCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.