Package net.sf.saxon.type.gnode
Class NamedXNodeType
java.lang.Object
net.sf.saxon.type.gnode.GNodeType
net.sf.saxon.type.gnode.XNodeType
net.sf.saxon.type.gnode.NamedXNodeType
- All Implemented Interfaces:
NamedXNodePredicate,NodePredicate,NodeTest,NodeVectorMatchMaker,ItemType,ItemTypeWithSequenceTypeCache
NamedXNodeType is a node type corresponding to the syntax
element(N, T) or attribute(N, T) or namespace(N)
or processing-instruction(N).
It tests for a node of a particular kind, whose name matches a QNameTest (which embraces wildcards and choices) and whose type annotation matches a given schema type; it is also conditional on whether the node is nilled.
A NamedXNodeType is tied to one Configuration, which means it
cannot be used in the signature of a built-in function, as these are shared
across configurations. An alternative is therefore available in the class
PortableNamedXNodeType.
-
Constructor Summary
ConstructorsConstructorDescriptionNamedXNodeType(int nodeKind, StructuredQName nameTest, Configuration config) Simplified convenience constructorNamedXNodeType(int nodeKind, QNameTest nameTest, Configuration config) Simplified convenience constructorNamedXNodeType(int nodeKind, QNameTest nameTest, SchemaType schemaType, boolean nillable, Configuration config) Create an NamedNodeKindType -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.explainMismatch(Item item, TypeHierarchy th) Get extra diagnostic information about why a supplied item does not conform to this item type, if available.Get the set of allowed node names that this type if capable of matchingGet the item type of the atomic values that will be produced when an item of this type is atomized (assuming that atomization succeeds)Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived.Get the Saxon Configuration to which this type belongsGet the allowed content type permitted by this item type.final doubleDetermine the default priority of this node test when used on its own as a PatterngetMatcher(NodeVectorTree tree) Get a matching function that can be used to test whether numbered nodes in a TinyTree or DominoTree satisfy the node test.Get the corresponding StructuredQName: the name that all nodes must have if they are to satisfy the predicateintGet the kind of nodes that this node predicate matchesGet the primitive item type corresponding to this item type.intDetermine the types of nodes to which this pattern applies.Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTestintFor anXNodeTypethat can only match one kind of node and one node name, return that node name, as an integer fingerprint.getUType()Get the correspondingUType.inthashCode()Returns a hash code value for the object.booleanAsk whether values of this type are atomizablebooleanAsk whether having the required fingerprint and node kind is a sufficient condition for a node to satisfy the predicate, or whether other conditions (such as type annotation or nillability) must also be satisfied.booleanThe test is nillable if a question mark was specified as the occurrence indicatorstatic NodeTestmake(int nodeKind, int fingerprint, Configuration config) static NodeTestmake(int nodeKind, NamespaceUri uri, String localName, Configuration config) booleanTest whether a given item conforms to this typeNormalize this item type, returning a potentially different item type that matches the same items.voidsetImplicitSchemaType(boolean implicitSchemaType) Say that the schema type is implicit.Return a string representation of this ItemType suitable for use in stylesheet export files.toString()Methods inherited from class net.sf.saxon.type.gnode.XNodeType
asXNodeTest, getCoercionPlan, getGenre, getRequiredFingerprintMethods inherited from class net.sf.saxon.type.gnode.GNodeType
getItemType, isAtomicType, isPlainType, one, oneOrMore, test, toShortString, zeroOrMore, zeroOrOneMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.type.ItemType
asChoiceItemType, getNormalizedDefaultPriority
-
Constructor Details
-
NamedXNodeType
public NamedXNodeType(int nodeKind, QNameTest nameTest, SchemaType schemaType, boolean nillable, Configuration config) Create an NamedNodeKindType- Parameters:
nodeKind- the kind of nodes to be matched: always elements or attributesnameTest- constrains the name of the nodeschemaType- the required type annotation, as a simple or complex schema typenillable- indicates whether an element with xsi:nil=true satisifies the testconfig- the Configuration, supplied because this KindTest needs access to schema information
-
NamedXNodeType
Simplified convenience constructor- Parameters:
nodeKind- the kind of nodes to be matched: always elements or attributesnameTest- constrains the name of the nodeconfig- the Configuration, supplied because this KindTest needs access to schema information
-
NamedXNodeType
Simplified convenience constructor- Parameters:
nodeKind- the kind of nodes to be matched: always elements or attributesnameTest- constrains the name of the nodeconfig- the Configuration, supplied because this KindTest needs access to schema information
-
-
Method Details
-
make
-
make
-
setImplicitSchemaType
public void setImplicitSchemaType(boolean implicitSchemaType) Say that the schema type is implicit. As an item type, element(E) and element(E, xs:anyType?) are equivalent, but as XSLT patterns, they have different default priority, and therefore need to be distinguished. If the schema type was omitted in the pattern we set implicitType to true, and this affects the calculation of a default priority.- Parameters:
implicitSchemaType- true if the node test in a pattern did not contain an explicit schema type
-
getUType
Get the correspondingUType. A UType is a union of primitive item types. -
getQNameTest
Extract a QNameTest (the strongest one possible) that must be satisfied by a node if it is to satisfy this NodeTest- Specified by:
getQNameTestin interfaceNodeTest- Overrides:
getQNameTestin classGNodeType- Returns:
- the strongest possible QNameTest
-
getAllowedNodeNames
Get the set of allowed node names that this type if capable of matching- Specified by:
getAllowedNodeNamesin classXNodeType- Returns:
- the allowed node names
-
getRequiredFingerprint
public int getRequiredFingerprint()For anXNodeTypethat can only match one kind of node and one node name, return that node name, as an integer fingerprint. In other cases, return -1.- Specified by:
getRequiredFingerprintin interfaceNamedXNodePredicate- Returns:
- an integer fingerprint in the case of a node type that only matches one node kind and one qualified name. In other cases return -1.
-
getPrimitiveItemType
Description copied from class:GNodeTypeGet the primitive item type corresponding to this item type. For item(), this is Type.ITEM. For node(), it is Type.NODE. For specific node kinds, it is the value representing the node kind, for example Type.ELEMENT. For anyAtomicValue and union types it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. For other atomic types it is the primitive type as defined in XML Schema, except that integer, xs:dayTimeDuration, and xs:yearMonthDuration are considered to be primitive types.- Specified by:
getPrimitiveItemTypein interfaceItemType- Overrides:
getPrimitiveItemTypein classGNodeType- Returns:
- the corresponding primitive type
-
getMatchingNodeName
Get the corresponding StructuredQName: the name that all nodes must have if they are to satisfy the predicate- Specified by:
getMatchingNodeNamein interfaceNamedXNodePredicate- Returns:
- if all nodes selected by the node test are of the required nodeKind, and have the same name, then return that name; otherwise return null.
-
isFingerprintSufficient
public boolean isFingerprintSufficient()Ask whether having the required fingerprint and node kind is a sufficient condition for a node to satisfy the predicate, or whether other conditions (such as type annotation or nillability) must also be satisfied.- Specified by:
isFingerprintSufficientin interfaceNamedXNodePredicate- Returns:
- true if matching the fingerprint is a sufficient condition.
-
getConfiguration
Get the Saxon Configuration to which this type belongs- Returns:
- the Saxon configuration
-
isNillable
public boolean isNillable()The test is nillable if a question mark was specified as the occurrence indicator- Specified by:
isNillablein interfaceNodeTest- Overrides:
isNillablein classXNodeType- Returns:
- true if the test is nillable
-
getContentType
Description copied from class:XNodeTypeGet the allowed content type permitted by this item type. Defaults to allowing any content- Overrides:
getContentTypein classXNodeType- Returns:
- the allowed content type
-
getNodeKind
public int getNodeKind()Description copied from interface:NamedXNodePredicateGet the kind of nodes that this node predicate matches- Specified by:
getNodeKindin interfaceNamedXNodePredicate- Returns:
- the kind of nodes, for example
Type.ELEMENTornet.sf.saxon.type.Type#ATTRIBUTE
-
matches
Test whether a given item conforms to this type -
getMatcher
Get a matching function that can be used to test whether numbered nodes in a TinyTree or DominoTree satisfy the node test. (Calling this matcher must give the same result as callingmatchesNode(tree.getNode(nodeNr)), but it may well be faster).- Specified by:
getMatcherin interfaceNodeVectorMatchMaker- Parameters:
tree- the tree against which the returned function will operate- Returns:
- an IntPredicate; the matches() method of this predicate takes a node number as input, and returns true if and only if the node identified by this node number matches the node predicate.
-
getDefaultPriority
public final double getDefaultPriority()Determine the default priority of this node test when used on its own as a Pattern- Specified by:
getDefaultPriorityin interfaceItemType- Specified by:
getDefaultPriorityin interfaceNodeTest- Returns:
- the default priority
-
getPrimitiveType
public int getPrimitiveType()Determine the types of nodes to which this pattern applies. Used for optimisation.- Specified by:
getPrimitiveTypein interfaceItemType- Overrides:
getPrimitiveTypein classGNodeType- Returns:
- the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT
-
getAtomizedItemType
Get the item type of the atomic values that will be produced when an item of this type is atomized (assuming that atomization succeeds)- Specified by:
getAtomizedItemTypein interfaceItemType- Overrides:
getAtomizedItemTypein classGNodeType- Returns:
- the best available item type of the atomic values that will be produced when an item of this type is atomized, or null if it is known that atomization will throw an error.
-
isAtomizable
Ask whether values of this type are atomizable- Specified by:
isAtomizablein interfaceItemType- Overrides:
isAtomizablein classGNodeType- Parameters:
th- The type hierarchy cache- Returns:
- true unless it is known that these items will be elements with element-only content, in which case return false
-
toString
-
toExportString
Return a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of callingtoString().- Specified by:
toExportStringin interfaceItemType- Returns:
- the string representation as an instance of the XPath SequenceType construct
-
hashCode
public int hashCode()Returns a hash code value for the object. -
equals
Indicates whether some other object is "equal to" this one. -
normalizeItemType
Description copied from interface:ItemTypeNormalize this item type, returning a potentially different item type that matches the same items. For example,record(*)andmap(*)match the same items. The default implementation returns the item type unchanged. This method does NOT expand item types to an equivalent choice item type.Item types should be normalized before comparison using equals().
- Specified by:
normalizeItemTypein interfaceItemType- Returns:
- the normalized item type.
-
explainMismatch
Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.- Specified by:
explainMismatchin interfaceItemType- Specified by:
explainMismatchin interfaceNodeTest- Overrides:
explainMismatchin classGNodeType- Parameters:
item- the item that doesn't match this typeth- the type hierarchy cache- Returns:
- optionally, a message explaining why the item does not match the type
-
getBasicAlphaCode
Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.- Specified by:
getBasicAlphaCodein interfaceItemType- Returns:
- the alphacode for the nearest containing built-in type. For example: for xs:string return "AS", for xs:boolean "AB", for node() "N", for element() "NE", for map(*) "FM", for array(*) "FA".
-