net.sf.saxon.s9api
Class ItemTypeFactory
java.lang.Object
net.sf.saxon.s9api.ItemTypeFactory
public class ItemTypeFactory
extends java.lang.Object
This class is used for creating ItemType objects.
ItemTypeFactory
public ItemTypeFactory(Processor processor)
Create an ItemTypeFactory
processor
- the processor used by this ItemTypeFactory. This must be supplied
in the case of user-defined types or types that reference element or attribute names;
for built-in types it can be omitted.
getAtomicType
public ItemType getAtomicType(QName name)
throws SaxonApiException
Get an item type representing an atomic type. This may be a built-in type in the
XML Schema namespace, or a user-defined atomic type.
It is undefined whether two calls supplying the same QName will return the same ItemType
object.
name
- the name of the built-in atomic type required
- an ItemType object representing this built-in atomic type
SaxonApiException
- if the type name is not known, or if the type identified by the
name is not an atomic type.
getAttributeTest
public ItemType getAttributeTest(QName name,
QName schemaType)
throws SaxonApiException
Get an ItemType that tests an element name and/or schema type. This is the
equivalent of the XPath syntax
element(element-name, type)
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
name
- the element name, or null if there is no constraint on the name (equivalent to
specifying element(*, type)
)schemaType
- the name of the required schema type, or null of there is no constraint
on the type (equivalent to specifying element(name)
)
SaxonApiException
- if the schema does not contain a global element declaration
for the given name
getDocumentTest
public ItemType getDocumentTest(ItemType elementTest)
Make an ItemType representing a document-node() test with an embedded element test.
This reflects the XPath syntax
document-node(element(N, T))
or
document-node(schema-element(N))
.
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
elementTest
- the elementTest. An IllegalArgumentException is thrown if the supplied
ItemTest is not an elementTest or schemaElementTest.
- a new ItemType representing the document test
getElementTest
public ItemType getElementTest(QName name,
QName schemaType,
boolean nillable)
throws SaxonApiException
Make an ItemType that tests an element name and/or schema type. This is the
equivalent of the XPath syntax
element(element-name, type)
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
name
- the element name, or null if there is no constraint on the name (equivalent to
specifying element(*, type)
)schemaType
- the name of the required schema type, or null of there is no constraint
on the type (equivalent to specifying element(name)
)nillable
- if a nilled element is allowed to match the type (equivalent to specifying
"?" after the type name). The value is ignored if schemaType is null.
SaxonApiException
- if the schema does not contain a global element declaration
for the given name
getItemType
public ItemType getItemType(XdmItem item)
Get an ItemType representing the type of a supplied XdmItem. If the supplied item is
an atomic value, the returned ItemType will reflect the most specific atomic type of the
item. If the supplied item is a node, the returned item type will reflect the node kind,
and if the node has a name, then its name. It will not reflect the type annotation.
item
- the supplied item whose type is required
- the type of the supplied item
getItemType
public ItemType getItemType(XdmNodeKind kind,
QName name)
Get an item type that matches nodes of a specified kind with a specified name.
This corresponds to the XPath syntactic forms element(name), attribute(name),
and processing-instruction(name). In the case of processing-instruction, the supplied
QName must have no namespace.
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
kind
- the kind of nodes that matchname
- the name of the nodes that match
- an ItemType that matches nodes of a given node kind with a given name
getNodeKindTest
public ItemType getNodeKindTest(XdmNodeKind kind)
Get an item type that matches any node of a specified kind.
This corresponds to the XPath syntactic forms element(), attribute(),
document-node(), text(), comment(), processing-instruction(). It also provides
an option, not available in the XPath syntax, that matches namespace nodes.
It is undefined whether two calls supplying the same argument value will
return the same ItemType object.
kind
- the kind of node for which a NodeTest is required
- an item type corresponding to the specified kind of node
getSchemaAttributeTest
public ItemType getSchemaAttributeTest(QName name)
throws SaxonApiException
Get an ItemType representing an attribute declaration in the schema. This is the
equivalent of the XPath syntax
schema-attribute(attribute-name)
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
name
- the attribute name
SaxonApiException
- if the schema does not contain a global attribute declaration
for the given name
getSchemaElementTest
public ItemType getSchemaElementTest(QName name)
throws SaxonApiException
Make an ItemType representing an element declaration in the schema. This is the
equivalent of the XPath syntax
schema-element(element-name)
It is undefined whether two calls supplying the same argument values will
return the same ItemType object.
SaxonApiException
- if the schema does not contain a global element declaration
for the given name