fn:path() should support fragments as well as documents

Bug #1005995 reported by Juan Zacarias
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Fix Released
Critical
Juan Zacarias

Bug Description

Modify fn:path to add support for fragments

Related branches

Changed in zorba:
importance: Undecided → Critical
Changed in zorba:
milestone: none → 2.7
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :
Download full text (3.8 KiB)

13.9 fn:path

Summary
Returns a path expression that can be used to select the supplied node relative to the root of its containing document.

Signatures
fn:path() as xs:string?
fn:path($arg as node()?) as xs:string?
Properties
The one-argument form of this function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.

The two-argument form of this function is ·deterministic·, ·context-independent·, and ·focus-independent·.

Rules
The behavior of the function if the argument is omitted is exactly the same as if the context item (.) had been passed as the argument.

If $arg is the empty sequence, the function returns the empty sequence.

If $arg is a document node, the function returns the string "/".

Otherwise, the function constructs a string that consists of a sequence of steps, one for each ancestor-or-self of $arg other than the root node. This string is prefixed by "Q{http://www.w3.org/2005/xpath-functions}root()" if the root node is not a document node. Each step consists of the character "/" followed by a string whose form depends on the kind of node selected by that step, as follows:

For an element node, Q{uri}local[position], where uri is the namespace URI of the node name or the empty string if the node is in no namespace, local is the local part of the node name, and position is an integer representing the position of the selected node among its like-named siblings.
For an attribute node:
if the node is in no namespace, @local, where local is the local part of the node name
otherwise, @Q{uri}local, where uri is the namespace URI of the node name, and local is the local part of the node name
For a text node: text()[position] where position is an integer representing the position of the selected node among its text node siblings
For a comment node: comment()[position] where position is an integer representing the position of the selected node among its comment node siblings
For a processing-instruction node: processing-instruction(local)[position] where local is the name of the processing instruction node and position is an integer representing the position of the selected node among its like-named processing-instruction node siblings
For a namespace node:
If the namespace node has a name: namespace::prefix, where prefix is the local part of the name of the namespace node (which represents the namespace prefix).
If the namespace node has no name (that is, it represents the default namespace): namespace::*[Q{http://www.w3.org/2005/xpath-functions}local-name()=""]
Examples
let $e :=

fn:parse-xml('<?xml version="1.0"?>
<p xmlns="http://example.com/one" xml:lang="de" author="Friedrich von Schiller">
Freude, schöner Götterfunken,<br/>
Tochter aus Elysium,<br/>
Wir betreten feuertrunken,<br/>
Himmlische, dein Heiligtum.</p>')

The expression fn:path($e) returns '/'.

The expression fn:path($e/*:p) returns '/Q{http://example.com/one}p[1]'.

The expression fn:path($e/*:p/@xml:lang) returns '/Q{http://example.com/one}p[1]/@Q{http://www.w3.org/XML/1998/namespace}lang'.

The expression fn:path($e/*:p/@author) returns '/Q{http://example.com/one}p[1]/@author'.

The expression fn:path($e/*:p/*:br[2]) returns '/Q{http://examp...

Read more...

Changed in zorba:
status: New → Fix Committed
Changed in zorba:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.