XQuery Reference

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

XQuery Node Functions Reference

This chapter provides descriptions of the XQuery node functions available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery functions. To learn more, see Invoking Functions or Operators in a Query.

In addition to the XQuery functions and operators available in the mapper functionality, a larger set functions and operators is provided. You can manually add invocations to these functions and XQuery Node Functions Reference

This section provides descriptions of the XQuery node functions available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery functions. To learn more, see Invoking Functions or Operators in a Query.

In addition to the XQuery functions and operators available in the mapper functionality, a larger set functions and operators is provided. You can manually add invocations to these functions and operators to queries in the Source View of the mapper functionality. For a list of these additional functions and operators, see the XQuery 1.0 and XPath 2.0 Functions and Operators - W3C Working Draft 16 August 2002 available from the W3C Web site at the following URL:

http://www.w3.org/TR/2002/WD-xquery-operators-20020816

This section lists the node functions available from the mapper functionality:

 


xf: node-kind

If a $node-var is not a node, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method:

Type error in function node-kind invocation: expected type node, given type

[string@http://www.w3.org/2001/XMLSchema]

If the value of $node-var is the empty sequence, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method:

Type error in function node-kind invocation: expected type node, given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xf:node-kind(xf: node $node-var) —>xs: string

Table 8-1 Arguments
Data Type
Argument
Description
node
$node-var
Represents the node from which to determine type.

Returns

Returns a string which represents the kind of $node-var. One of the following strings will be returned: document, element, attribute, text, namespace, processing-instruction, or comment.

Examples
Element

When you invoke the following query:

let $x := <e a="b">c</e>

return <type>{xf:node-kind($x)}</type>

The following result is generated:

<type>element</type>

Attribute

When you invoke the following query:

let $x := <e a="b">c</e>

return <type>{xf:node-kind($x/@a)}</type>

The following result is generated:

<type>attribute</type>

Text

When you invoke the following query:

let $x := <e a="b">c</e>

return <type>{xf:node-kind($x/text())}</type>

The following result is generated:

<type>text</type>

Related Topics

W3C node-kind function description.

 


xf: node-name

Returns the expanded QName of $node-var. An expanded QName contains a namespace URI and a local name.

If the value of $node-var is the empty sequence, the following error message is displayed:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method:

Type error in function node-name invocation: expected type node, given type empty

The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

If a $node-var is not a node, the following error is displayed in the mapper:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method:

Type error in function node-name invocation: expected type node, given type

[string@http://www.w3.org/2001/XMLSchema]

Signatures

xf:node-name(xf: node $node-var) —> xs: QName?

Table 8-2 Arguments
Data Type
Argument
Description
node
$node-var
Represents the nod to extract the QName from

Returns

Returns the expanded QName of $node-var. An expanded QName contains a namespace URI and a local name.

Returns the empty sequence for nodes that do not have names (document, text, processing-instruction, comment). The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Examples
Simple

When you invoke the following query:

let $x := <elem xmlns:foo="http://www.acme.org/"><foo:subelem/></elem>,

$name := xf:node-name(children($x))

return

<result>

<uri> {

xf:get-namespace-from-QName($name)

}</uri>

<local>{

xf:get-local-name-from-QName($name)

}</local>

</result>

The preceding query generates the following result:

<?xml version="1.0" encoding="UTF-8"?>

<result>

<uri>http://www.acme.org/</uri>

<local>subelem</local>

</result>

Related Topics

W3C node-name function description.

 


xf: local-name

Returns the local name (as a string) of $node-var.

Signatures

xf:local-name(xf: node? $node-var) —> xs: string

Table 8-3 Arguments
Data Type
Argument
Description
node?
$node-var
Represents the node to get the local name from.

Returns

Returns the local name (as a string) of $node-var.

Examples
Simple

The following XML document defines the namespace called xacme:

<?xml version='1.0'?>

<mydoc xmlns:xacme="http://www.acme.com/foo"> <xacme:n/> </mydoc>

The preceding XML Document associates the namespace prefix xacme to the URI: http://www.acme.com/foo. The string xacme:n is qualified name for the URI/local name pair: ("http://www.acme.com/foo", "n").

The following example query returns the local part of the URI/local name pair as shown in the following XQuery code:

let $a := <mydoc xmlns:xacme="http://www.acme.com/foo"> <xacme:n/> </mydoc>

return <name>{xf:local-name($a/*[1])}</name>

The preceding query generates the following result:

<name>n</name>

Related Topics

W3C local-name function description.


  Back to Top       Previous  Next