Package com.saxonica.xqj
Class SaxonXQDataFactory
- java.lang.Object
-
- com.saxonica.xqj.Closable
-
- com.saxonica.xqj.SaxonXQDataFactory
-
- All Implemented Interfaces:
XQDataFactory
- Direct Known Subclasses:
SaxonXQConnection
public abstract class SaxonXQDataFactory extends Closable implements XQDataFactory
Saxon implementation of the XQJ interface XQDataFactory. This is an abstract superclass for SaxonXQDataSource and SaxonXQConnection, both of which provide the factory methods in this interface.For Javadoc specifications of the public methods in this class, see the XQJ documentation.
-
-
Constructor Summary
Constructors Constructor Description SaxonXQDataFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XQItemTypecreateAtomicType(int baseType)Create an atomic item type object representing a particular built-in atomic typeXQItemTypecreateAtomicType(int baseType, javax.xml.namespace.QName typename, java.net.URI schemaURI)See interface definition, and description of Saxon extensions below.XQItemTypecreateAttributeType(javax.xml.namespace.QName nodename, int basetype)Creates a newXQItemTypeobject representing the XQueryattribute(nodename, basetype)type with the given node name and base type.XQItemTypecreateAttributeType(javax.xml.namespace.QName nodename, int basetype, javax.xml.namespace.QName typename, java.net.URI schemaURI)Creates a newXQItemTypeobject representing the XQueryattribute(nodename,basetype,typename,schemaURI)type, with the given node name, base type, schema type name and schema URI.XQItemTypecreateCommentType()Creates a newXQItemTypeobject representing the XQuerycomment()type.XQItemTypecreateDocumentElementType(XQItemType elementType)Creates a newXQItemTypeobject representing the XQuerydocument-node(elementType)type containing a single element.XQItemTypecreateDocumentSchemaElementType(XQItemType type)Creates a newXQItemTypeobject representing the XQuerydocument-node(elementType)type containing a singleschema-element(...).XQItemTypecreateDocumentType()Creates a newXQItemTypeobject representing the XQuerydocument-node()type.XQItemTypecreateElementType(javax.xml.namespace.QName nodename, int basetype)Creates a newXQItemTypeobject representing the XQueryelement(nodename, basetype)type, with the given node name and base type.XQItemTypecreateElementType(javax.xml.namespace.QName nodename, int basetype, javax.xml.namespace.QName typename, java.net.URI schemaURI, boolean allowNill)Creates a newXQItemTypeobject representing the XQueryelement(nodename,basetype,typename,schemaURI, allowNill)type, given the node name, base type, schema type name, schema URI, and nilled check.XQItemcreateItem(XQItem item)Creates a copy of the specifiedXQItem.XQItemcreateItemFromAtomicValue(java.lang.String value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromBoolean(boolean value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromByte(byte value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromDocument(java.io.InputStream value, java.lang.String baseURI, XQItemType type)Creates an item from the given value.XQItemcreateItemFromDocument(java.io.Reader value, java.lang.String baseURI, XQItemType type)Creates an item from the given value.XQItemcreateItemFromDocument(java.lang.String value, java.lang.String baseURI, XQItemType type)Creates an item from the given value.XQItemcreateItemFromDocument(javax.xml.stream.XMLStreamReader value, XQItemType type)Creates an item from the given value.XQItemcreateItemFromDocument(javax.xml.transform.Source value, XQItemType type)Creates an item from the givenSource.XQItemcreateItemFromDouble(double value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromFloat(float value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromInt(int value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromLong(long value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromNode(org.w3c.dom.Node value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromObject(java.lang.Object value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromShort(short value, XQItemType type)Creates an item from a given value.XQItemcreateItemFromString(java.lang.String value, XQItemType type)Creates an item from a given value.XQItemTypecreateItemType()Creates a newXQItemTypeobject representing the XQuery item type.XQItemTypecreateNodeType()Creates a newXQItemTypeobject representing the XQuerynode()type.XQItemTypecreateProcessingInstructionType(java.lang.String piTarget)Creates a newXQItemTypeobject representing the XQueryprocessing-instruction(piTarget)type.XQItemTypecreateSchemaAttributeType(javax.xml.namespace.QName name, int basetype, java.net.URI schemaURI)Creates a newXQItemTypeobject representing the XQueryschema-attribute(nodename,basetype,schemaURI)type, with the given node name, base type, and schema URI.XQItemTypecreateSchemaElementType(javax.xml.namespace.QName nodename, int basetype, java.net.URI schemaURI)Creates a newXQItemTypeobject representing the XQueryschema-element(nodename,basetype,schemaURI)type, given the node name, base type, and the schema URI.XQSequencecreateSequence(java.util.Iterator i)Creates anXQSequence, containing all the items from the iterator.XQSequencecreateSequence(XQSequence s)Creates a copy of the specifiedXQSequence.XQSequenceTypecreateSequenceType(XQItemType item, int occurrence)Creates a new sequence type from an item type and occurence indicator.XQItemTypecreateTextType()Creates a newXQItemTypeobject representing the XQuerytext()type.ObjectConvertergetObjectConverter()Get the ObjectConverter in use.protected voidinit()voidsetObjectConverter(ObjectConverter converter)Set the ObjectConverter to be used.-
Methods inherited from class com.saxonica.xqj.Closable
close, isClosed, setClosableContainer
-
-
-
-
Method Detail
-
init
protected void init()
-
setObjectConverter
public void setObjectConverter(ObjectConverter converter)
Set the ObjectConverter to be used. This allows user-defined object conversions to override or supplement the standard conversions- Parameters:
converter- the user-supplied ObjectConverter
-
getObjectConverter
public ObjectConverter getObjectConverter()
Get the ObjectConverter in use. This will either be the default object converter supplied by Saxon, or a user-supplied ObjectConverter if one has been set.- Returns:
- the ObjectConverter in use.
-
createAtomicType
public XQItemType createAtomicType(int baseType) throws XQException
Create an atomic item type object representing a particular built-in atomic type- Specified by:
createAtomicTypein interfaceXQDataFactory- Parameters:
baseType- the built-in atomic type, typically a constant such as XQItemType.XQBASETYPE_BOOLEAN- Returns:
- the corresponding XQItemType
- Throws:
XQException- if the supplied baseType parameter is not an atomic type
-
createAtomicType
public XQItemType createAtomicType(int baseType, javax.xml.namespace.QName typename, java.net.URI schemaURI) throws XQException
See interface definition, and description of Saxon extensions below.In addition to the actions described in the XQJ interface definitions, Saxon allows the typename to be a name representing a Java external type. In this case the URI part of the QName must be
NamespaceConstant.JAVA_TYPE, and the local part of the name must be the Java class name (qualified with its package name)- Specified by:
createAtomicTypein interfaceXQDataFactory- Parameters:
baseType- the "baseType" (in XQJ terminology)typename- the qualified name of the typeschemaURI- the location of a schema document in which the type is defined (may be null)- Returns:
- the item type definition
- Throws:
XQException- if a dynamic error occurs
-
createAttributeType
public XQItemType createAttributeType(javax.xml.namespace.QName nodename, int basetype) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryattribute(nodename, basetype)type with the given node name and base type. This method can be used to create item type for attributes with a pre-defined schema type.
Example -XQConnection conn = ..; // An XQuery connection - attribute() // no node name, pass null for the node name conn.createAttributeType(null, XQItemType.XQBASETYPE_ANYSIMPLETYPE); - attribute (*) // equivalent to attribute() conn.createAttributeType(null, XQItemType.XQBASETYPE_ANYSIMPLETYPE); - attribute (person) // attribute of name person and any simple type. conn.createAttributeType(new QName("person"), XQItemType.XQBASETYPE_ANYSIMPLETYPE); - attribute(foo:bar) // node name foo:bar, type is any simple type conn.createAttributeType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_ANYSIMPLETYPE); - attribute(foo:bar, xs:integer) // node name foo:bar, type is xs:integer conn.createAttributeType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_INTEGER);- Specified by:
createAttributeTypein interfaceXQDataFactory- Parameters:
nodename- specifies the name of the node.nullindicates a wildcard for the node namebasetype- the base type of the attribute. One of theXQItemType.XQBASETYPE_*other thanXQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPE- Returns:
- a new
XQItemTyperepresenting the XQueryattribute(nodename, basetype)type - Throws:
XQException- if (1) the underlying object implementing the interface is closed or (2) if the base type is one of:XQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPE
-
createAttributeType
public XQItemType createAttributeType(javax.xml.namespace.QName nodename, int basetype, javax.xml.namespace.QName typename, java.net.URI schemaURI) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryattribute(nodename,basetype,typename,schemaURI)type, with the given node name, base type, schema type name and schema URI. The type name can reference either pre-defined simple types or user-defined simple types.
Example -XQConnection conn = ..; // An XQuery connection - attribute (name, employeename) // attribute name of type employeename conn.createAttributeType(new QName("name"), XQItemType.XQBASETYPE_ANYSIMPLETYPE, new QName("employeename"), null); - attribute (foo:bar, po:city) where the prefix foo refers to the namespace http://www.foo.com and the prefix po refers to the namespace "http://www.address.com" conn.createAttributeType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_ANYSIMPLETYPE, new QName("http://address.com", "address","po"), null); - attribute (zip, zipcode) // attribute zip of type zipchode which derives from // xs:string conn.createAttributeType(new QName("zip"), XQItemType.XQBASETYPE_STRING, new QName("zipcode"), null); - attribute(foo:bar, po:hatsize) where the prefix foo refers to the namespace http://www.foo.com and the prefix po refers to the namespace "http://www.hatsizes.com" with schema URI "http://hatschema.com" conn.createAttributeType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_INTEGER, new QName("http://www.hatsizes.com", "hatsize","po"), new QName("http://hatschema.com"));- Specified by:
createAttributeTypein interfaceXQDataFactory- Parameters:
nodename- specifies the name of the node.nullindicates a wildcard for the node namebasetype- the base type of the attribute. One of theXQItemTyupe.XQBASETYPE_*constants other thanXQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPEtypename- theQNameof the type. If theQNamerefers to a predefinied type, it must match thebasetype. Can benull.schemaURI- the URI to the schema. Can benull. This can only be specified if the typename is also specified- Returns:
- a new
XQItemTyperepresenting the XQueryattribute(nodename,basetype, typename,schemaURI)type. - Throws:
XQException- if (1) the underlying object implementing the interface is closed, (2) if the base type is one of:XQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPE, (3) the schema URI is specified and the typename is not specified, (4) the implementation does not support user-defined XML schema types, or (5) if thetypenamerefers to a predefinied type and does not matchbasetype
-
createCommentType
public XQItemType createCommentType() throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerycomment()type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_COMMENT.
Example -XQConnection conn = ..; // An XQuery connection XQItemType cmttype = conn.createCommentType(); int itemkind = cmttype.getItemKind(); // will be XQItemType.XQITEMKIND_COMMENT XQExpression expr = conn.createExpression(); XQSequence result = expr.executeQuery("<!-- comments -->"); result.next(); boolean pi = result.instanceOf(cmttype); // will be true- Specified by:
createCommentTypein interfaceXQDataFactory- Returns:
- a new
XQItemTyperepresenting the XQuerycomment()type - Throws:
XQException- if the underlying object implementing the interface is closed
-
createDocumentElementType
public XQItemType createDocumentElementType(XQItemType elementType) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerydocument-node(elementType)type containing a single element. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_DOCUMENT_ELEMENTand the base type set to the item type of the inputelementType.- Specified by:
createDocumentElementTypein interfaceXQDataFactory- Parameters:
elementType- anXQItemTypeobject representing an XQueryelement()type, cannot benull- Returns:
- a new
XQItemTyperepresenting the XQuerydocument-node(elementType)type containing a single element - Throws:
XQException- if (1) the underlying object implementing the interface is closed or (2) theelementTypehas an item kind different fromXQItemType.XQITEMKIND_ELEMENT, (3) theelementTypeargument isnull, or (4) the implementation does not support user-defined XML schema types
-
createDocumentSchemaElementType
public XQItemType createDocumentSchemaElementType(XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerydocument-node(elementType)type containing a singleschema-element(...). TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_DOCUMENT_SCHEMA_ELEMENTand the base type set to the item type of the inputelementType.- Specified by:
createDocumentSchemaElementTypein interfaceXQDataFactory- Parameters:
type- anXQItemTypeobject representing an XQueryschema-element(...)type, cannot benull- Returns:
- a new
XQItemTyperepresenting the XQuerydocument-node(elementType)type containing a singleschema-element(...)element - Throws:
XQException- if (1) the underlying object implementing the interface is closed or (2) theelementTypehas an item kind different fromXQItemType.XQITEMKIND_SCHEMA_ELEMENT, (3) theelementTypeargument isnull, (4) the implementation does not support user-defined XML schema types
-
createDocumentType
public XQItemType createDocumentType() throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerydocument-node()type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_DOCUMENT.- Specified by:
createDocumentTypein interfaceXQDataFactory- Returns:
- a new
XQItemTyperepresenting the XQuerydocument-node()type - Throws:
XQException- if the underlying object implementing the interface is closed
-
createElementType
public XQItemType createElementType(javax.xml.namespace.QName nodename, int basetype) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryelement(nodename, basetype)type, with the given node name and base type. This method can be used to create item type for elements with a pre-defined schema type.
Example -XQConnection conn = ..; // An XQuery connection - element() // no node name, pass null for the node name conn.createElementType(null, XQItemType.XQBASETYPE_ANYTYPE); - element (*) // equivalent to element() conn.createElementType(null, XQItemType.XQBASETYPE_ANYTYPE); - element(person) // element of name person and any type. conn.createElementType(new QName("person"), XQItemType.XQBASETYPE_ANYTYPE); - element(foo:bar) // node name foo:bar, type is anytype conn.createElementType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_ANYTYPE); - element(foo:bar, xs:integer) // node name foo:bar, type is xs:integer conn.createElementType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_INTEGER);- Specified by:
createElementTypein interfaceXQDataFactory- Parameters:
nodename- specifies the name of the node.nullindicates a wildcard for the node namebasetype- the base type of the item. One of theXQItemType.XQBASETYPE_*constants- Returns:
- a new
XQItemTyperepresenting the XQueryelement(nodename, basetype)type - Throws:
XQException- if (1) the underlying object implementing the interface is closed
-
createElementType
public XQItemType createElementType(javax.xml.namespace.QName nodename, int basetype, javax.xml.namespace.QName typename, java.net.URI schemaURI, boolean allowNill) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryelement(nodename,basetype,typename,schemaURI, allowNill)type, given the node name, base type, schema type name, schema URI, and nilled check. The type name can reference either pre-defined schema types or user-defined types.
Example -XQConnection conn = ..; // An XQuery connection - element (person, employee) // element person of type employee conn.createElementType(new QName("person"), XQItemType.XQBASETYPE_ANYTYPE, new QName("employee"), null ,false); - element(person, employee ? ) // element person of type employee, whose nilled // property may be true or false. conn.createElementType(new QName("person"), XQItemType.XQBASETYPE_ANYTYPE, new QName("employee"), null ,true); - element(foo:bar, po:address) where the prefix foo refers to the namespace http://www.foo.com and the prefix po refers to the namespace "http://www.address.com" conn.createElementType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_ANYTYPE, new QName("http://address.com", "address","po"), null, false); - element (zip, zipcode) // element zip of type zipchode which derives from // xs:string conn.createElementType(new QName("zip"), XQItemType.XQBASETYPE_STRING, new QName("zipcode"), null, false); - element (*, xs:anyType ?) conn.createElementType(null, XQItemType.XQBASETYPE_ANYTYPE, null, null, true); - element(foo:bar, po:hatsize) where the prefix foo refers to the namespace http://www.foo.com and the prefix po refers to the namespace "http://www.hatsizes.com" with schema URI "http://hatschema.com" conn.createElementType(new QName("http://www.foo.com", "bar","foo"), XQItemType.XQBASETYPE_INTEGER, new QName("http://www.hatsizes.com", "hatsize","po"), new QName("http://hatschema.com"), false);- Specified by:
createElementTypein interfaceXQDataFactory- Parameters:
nodename- specifies the name of the element.nullindicates a wildcard for the node namebasetype- the base type of the item. One of theXQItemType.XQBASETYPE_*constantstypename- theQNameof the type. If theQNamerefers to a predefinied type, it must match thebasetype. Can benullschemaURI- the URI to the schema. Can benull. This can only be specified if the typename is also specifiedallowNill- the nilled property of the element- Returns:
- a new
XQItemTyperepresenting the XQueryelement(nodename,basetype, typename,schemaURI, allowNill)type - Throws:
XQException- if (1) schemaURI is specified but the typename is not specified, (2) the underlying object implementing the interface is closed, (3) the implementation does not support user-defined XML schema types, or (4) if thetypenamerefers to a predefinied type and does not matchbasetype
-
createItem
public XQItem createItem(XQItem item) throws XQException
Description copied from interface:XQDataFactoryCreates a copy of the specifiedXQItem. This method can be used, for example, to copy anXQResultItemobject so that the new item is not dependant on the connection.- Specified by:
createItemin interfaceXQDataFactory- Parameters:
item- theXQItemto copy- Returns:
XQItemindependent of any underlyingXQConnectionis created- Throws:
XQException- if (1) the specified item isnull, (2) the underlying object implementing the interface is closed, (3) the specified item is closed
-
createItemFromAtomicValue
public XQItem createItemFromAtomicValue(java.lang.String value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the casting fromxs:stringrules outlined in 17.1.1 Casting from xs:string and xs:untypedAtomic, XQuery 1.0 and XPath 2.0 Functions and Operators. If the cast fails anXQExceptionis thrown.- Specified by:
createItemFromAtomicValuein interfaceXQDataFactory- Parameters:
value- the lexical string value of the typetype- the item type- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) any of the arguments arenull, (2) given type is not an atomic type, (3) the conversion of the value to an XDM instance failed, or (4) the underlying object implementing the interface is closed
-
createItemFromBoolean
public XQItem createItemFromBoolean(boolean value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromBooleanin interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromByte
public XQItem createItemFromByte(byte value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromBytein interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromDocument
public XQItem createItemFromDocument(java.io.InputStream value, java.lang.String baseURI, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from the given value.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must benull,XQITEMKIND_DOCUMENT_ELEMENT, orXQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.- Specified by:
createItemFromDocumentin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benullbaseURI- an optional base URI, can benull. It can be used, for example, to resolve relative URIs and to include in error messages.type- the type of the value for the created document node. Ifnullis specified, it behaves as ifXQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, XQItemType.XQBASETYPE_XS_UNTYPED))were passed in as the type parameter. That is, the type represents the XQuery sequence typedocument-node(element(*, xs:untyped))- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) the value argument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromDocument
public XQItem createItemFromDocument(java.io.Reader value, java.lang.String baseURI, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from the given value.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must benull,XQITEMKIND_DOCUMENT_ELEMENT, orXQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.- Specified by:
createItemFromDocumentin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benullbaseURI- an optional base URI, can benull. It can be used, for example, to resolve relative URIs and to include in error messages.type- the type of the value for the created document node. Ifnullis specified, it behaves as ifXQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, XQItemType.XQBASETYPE_XS_UNTYPED))were passed in as the type parameter. That is, the type represents the XQuery sequence typedocument-node(element(*, xs:untyped))- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) the value argument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromDocument
public XQItem createItemFromDocument(javax.xml.transform.Source value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from the givenSource. An XQJ implementation must at least support the following implementations:javax.xml.transform.dom.DOMSourcejavax.xml.transform.sax.SAXSourcejavax.xml.transform.stream.StreamSource
If the value represents a well-formed XML document, it will result in a document node. The kind of the input type must benull,XQITEMKIND_DOCUMENT_ELEMENT, orXQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.- Specified by:
createItemFromDocumentin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benulltype- the type of the value for the created document node. Ifnullis specified, it behaves as ifXQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, XQItemType.XQBASETYPE_XS_UNTYPED))were passed in as the type parameter. That is, the type represents the XQuery sequence typedocument-node(element(*, xs:untyped))- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) the value argument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromDocument
public XQItem createItemFromDocument(java.lang.String value, java.lang.String baseURI, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from the given value.
If the value represents a well-formed XML document, it will be parsed and results in a document node. The kind of the input type must benull,XQITEMKIND_DOCUMENT_ELEMENT, orXQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.- Specified by:
createItemFromDocumentin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benullbaseURI- an optional base URI, can benull. It can be used, for example, to resolve relative URIs and to include in error messages.type- the type of the value for the created document node. Ifnullis specified, it behaves as ifXQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, XQItemType.XQBASETYPE_XS_UNTYPED))were passed in as the type parameter. That is, the type represents the XQuery sequence typedocument-node(element(*, xs:untyped))- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) the value argument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromDocument
public XQItem createItemFromDocument(javax.xml.stream.XMLStreamReader value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from the given value.
If the value represents a well-formed XML document, it results in a document node. The kind of the input type must benull,XQITEMKIND_DOCUMENT_ELEMENTorXQITEMKIND_DOCUMENT_SCHEMA_ELEMENT.
The value is converted into an instance of the specified type according to the rules defined in 14.3 Mapping a Java XML document to an XQuery document node, XQuery API for Java (XQJ) 1.0.
If the value is not well formed, or if a kind of the input type other than the values list above is specified, behavior is implementation defined and may raise an exception.- Specified by:
createItemFromDocumentin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benulltype- the type of the value for the created document node. Ifnullis specified, it behaves as ifXQDataFactory.createDocumentElementType( XQDataFactory.createElementType(null, XQItemType.XQBASETYPE_XS_UNTYPED))were passed in as the type parameter. That is, the type represents the XQuery sequence typedocument-node(element(*, xs:untyped))- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) the value argument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromDouble
public XQItem createItemFromDouble(double value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromDoublein interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromFloat
public XQItem createItemFromFloat(float value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromFloatin interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromInt
public XQItem createItemFromInt(int value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromIntin interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromLong
public XQItem createItemFromLong(long value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromLongin interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createItemFromNode
public XQItem createItemFromNode(org.w3c.dom.Node value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromNodein interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benulltype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) thevalueargument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromObject
public XQItem createItemFromObject(java.lang.Object value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromObjectin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benulltype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) thevalueargument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemFromString
public XQItem createItemFromString(java.lang.String value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type, which must represent anxs:stringor a type derived by restriction fromxs:string. If the specified type isnull, it defaults toxs:string.
Subsequently the value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the conversion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromStringin interfaceXQDataFactory- Parameters:
value- the value to be converted, cannot benulltype- the type of the value to be bound to the external variable. The default type,xs:string, is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- if (1) thevalueargument isnull, (2) the conversion of the value to an XDM instance failed, or (3) the underlying object implementing the interface is closed
-
createItemType
public XQItemType createItemType() throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuery item type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_ITEM.
Example -XQConnection conn = ..; // An XQuery connection XQItemType typ = conn.createItemType(); // represents the XQuery item type "item()"
- Specified by:
createItemTypein interfaceXQDataFactory- Returns:
- a new
XQItemTyperepresenting the XQuery item type - Throws:
XQException- if the underlying object implementing the interface is closed
-
createItemFromShort
public XQItem createItemFromShort(short value, XQItemType type) throws XQException
Description copied from interface:XQDataFactoryCreates an item from a given value. The value is converted into an instance of the specified type according to the rule defined in 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the converstion fails, anXQExceptionwill be thrown.- Specified by:
createItemFromShortin interfaceXQDataFactory- Parameters:
value- the value to be convertedtype- the type of the value to be bound to the external variable. The default type of the value is used in casenullis specified- Returns:
XQItemrepresenting the resulting item- Throws:
XQException- (1) the conversion of the value to an XDM instance failed, or (2) the underlying object implementing the interface is closed
-
createNodeType
public XQItemType createNodeType() throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerynode()type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_NODE.- Specified by:
createNodeTypein interfaceXQDataFactory- Returns:
- a new
XQItemTyperepresenting the XQuerynode()type - Throws:
XQException- if the underlying object implementing the interface is closed
-
createProcessingInstructionType
public XQItemType createProcessingInstructionType(java.lang.String piTarget) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryprocessing-instruction(piTarget)type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_PI. A string literal can be passed to match the PITarget of the processing instruction as described in 2.5.4.2 Matching an Item Type and an Item, XQuery 1.0: An XML Query Language.
Example -XQConnection conn = ..; // An XQuery connection XQItemType anypi = conn.createProcessingInstructionType(); XQItemType foopi = conn.createProcessingInstructionType("foo-format"); XQExpression expr = conn.createExpression(); XQSequence result = expr.executeQuery("<?format role="output" ?>"); result.next(); boolean pi = result.instanceOf(anypi); // will be true pi = result.instanceOf(foopi); // will be false XQExpression expr = conn.createExpression(); XQSequence result = expr.executeQuery("<?foo-format role="output" ?>"); result.next(); boolean pi = result.instanceOf(anypi); // will be true pi = result.instanceOf(foopi); // will be true- Specified by:
createProcessingInstructionTypein interfaceXQDataFactory- Parameters:
piTarget- the string literal to match the processing instruction's PITarget. Anullstring value will match all processing instruction nodes- Returns:
- a new
XQItemTyperepresenting the XQueryprocessing-instruction(piTarget)type - Throws:
XQException- if the underlying object implementing the interface is closed
-
createSchemaAttributeType
public XQItemType createSchemaAttributeType(javax.xml.namespace.QName name, int basetype, java.net.URI schemaURI) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryschema-attribute(nodename,basetype,schemaURI)type, with the given node name, base type, and schema URI.
Example -XQConnection conn = ..; // An XQuery connection - schema-attribute (name) // schema-attribute name, found in the schema // available at http://customerschema.com conn.createSchemaAttributeType(new QName("name"), XQItemType.XQBASETYPE_STRING, new URI(http://customerschema.com));- Specified by:
createSchemaAttributeTypein interfaceXQDataFactory- Parameters:
name- specifies the name of the nodebasetype- the base type of the attribute. One of theXQItemTyupe.XQBASETYPE_*constants other thanXQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPEschemaURI- the URI to the schema. Can benull- Returns:
- a new
XQItemTyperepresenting the XQueryschema-attribute(nodename,basetype, schemaURI)type - Throws:
XQException- if (1) the node name isnull, (2) if the base type is one of:XQItemType.XQBASETYPE_UNTYPEDorXQItemType.XQBASETYPE_ANYTYPE, (3) the underlying object implementing the interface is closed, or (4) the implementation does not support user-defined XML schema types
-
createSchemaElementType
public XQItemType createSchemaElementType(javax.xml.namespace.QName nodename, int basetype, java.net.URI schemaURI) throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQueryschema-element(nodename,basetype,schemaURI)type, given the node name, base type, and the schema URI.
Example -XQConnection conn = ..; // An XQuery connection - schema-element (customer) // schema-element person, found in // the schema available at http://customerschema.com conn.createElementType(new QName("customer"), XQItemType.XQBASETYPE_ANYTYPE, new URI("http://customerschema.com"));- Specified by:
createSchemaElementTypein interfaceXQDataFactory- Parameters:
nodename- specifies the name of the elementbasetype- the base type of the item. One of theXQItemType.XQBASETYPE_*constantsschemaURI- the URI to the schema. Can benull- Returns:
- a new
XQItemTyperepresenting the XQueryschema-element(nodename,basetype, schemaURI)type - Throws:
XQException- if (1) the node name isnull, (2) the underlying object implementing the interface is closed, or (3) the implementation does not support user-defined XML schema types
-
createSequence
public XQSequence createSequence(java.util.Iterator i) throws XQException
Description copied from interface:XQDataFactoryCreates anXQSequence, containing all the items from the iterator. The newly createdXQSequenceis scrollable and independent of any underlyingXQConnection. If the iterator returns anXQItem, it is added to the sequence. If the iterator returns any other object, an item is added to the sequence following the rules from 14.2 Mapping a Java Data Type to an XQuery Data Type, XQuery API for Java (XQJ) 1.0. If the iterator does not return any items, then an empty sequence is created.- Specified by:
createSequencein interfaceXQDataFactory- Parameters:
i- input iterator- Returns:
XQSequencerepresenting the sequence containing all items from the input iterator- Throws:
XQException- if (1) the conversion of any of the objects in the iterator to item fails, (2) theiparameter isnull, or (3) underlying object implementing the interface is closed
-
createSequence
public XQSequence createSequence(XQSequence s) throws XQException
Description copied from interface:XQDataFactoryCreates a copy of the specifiedXQSequence. The newly createdXQSequenceis scrollable and independent of any underlyingXQConnection. The newXQSequencewill contain all items from the specifiedXQSequencestarting from its current position. The copy process will implicitly perform next operations on the specified sequence to read the items. All items are consumed, the current position of the cursor is set to point after the last item.- Specified by:
createSequencein interfaceXQDataFactory- Parameters:
s- input sequence- Returns:
XQSequencerepresenting a copy of the input sequence- Throws:
XQException- if (1) there are errors accessing the items in the specified sequence, (2) the specified sequence is closed, (3) in the case of a forward only sequence, a get or write method has already been invoked on the current item, (4) thesparameter isnull, or (5) the underlying object implementing the interface is closed
-
createSequenceType
public XQSequenceType createSequenceType(XQItemType item, int occurrence) throws XQException
Description copied from interface:XQDataFactoryCreates a new sequence type from an item type and occurence indicator.- Specified by:
createSequenceTypein interfaceXQDataFactory- Parameters:
item- the item type. This parameter must benullif the occurance isXQSequenceType.OCC_EMPTY, and cannot benullfor any other occurance indicatoroccurrence- The occurence of the item type, must be one ofXQSequenceType.OCC_ZERO_OR_ONE,XQSequenceType.OCC_EXACTLY_ONE,XQSequenceType.OCC_ZERO_OR_MORE,XQSequenceType.OCC_ONE_OR_MORE,XQSequenceType.OCC_EMPTY- Returns:
- a new
XQSequenceTyperepresenting the type of a sequence - Throws:
XQException- if (1) theitemisnulland the occurance is notXQSequenceType.OCC_EMPTY, (2) theitemis notnulland the occurance isXQSequenceType.OCC_EMPTY, (3) the occurence is not one of:XQSequenceType.OCC_ZERO_OR_ONE,XQSequenceType.OCC_EXACTLY_ONE,XQSequenceType.OCC_ZERO_OR_MORE,XQSequenceType.OCC_ONE_OR_MORE,XQSequenceType.OCC_EMPTYor (4) the underlying object implementing the interface is closed
-
createTextType
public XQItemType createTextType() throws XQException
Description copied from interface:XQDataFactoryCreates a newXQItemTypeobject representing the XQuerytext()type. TheXQItemTypeobject will have the item kind set toXQItemType.XQITEMKIND_TEXT.- Specified by:
createTextTypein interfaceXQDataFactory- Returns:
- a new
XQItemTyperepresenting the XQuerytext()type - Throws:
XQException- if the underlying object implementing the interface is closed
-
-