[Bug 16184] [FO30] fn:path() should support fragments as well as documents

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16184

--- Comment #3 from Eric van der Vlist <vdv@dyomedea.com> 2012-03-27 18:04:58 UTC ---
(In reply to comment #2)

> <new>
> 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 "." 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:
> </new>

.../...

> (Eric, please indicate whether this specification would satisfy the use cases
> you had in mind.)

Use cases I had in mind are for variable defined as fragments, for instance in
XSLT:

<xsl:variable name="fragment" as="node()">
<foo>
 <bar/>
</foo>
</xsl:variable>

Let's say I call a template or a user defined function on one of its node,
let's say the <bar/> element, this template or function may need to call the
fn:path function to determine an XPath expression that identifies this element
when executed on one of the nodes of the same fragment.

As far as I understand your proposal, the function would return "./foo/bar".
This would work if the path is evaluated on the $fragment variable, but in my
example the template or function doesn't know about this variable.

Returning "root()/foo/var" would be an option, except that root() being a
function you couldn't use that to generate XSLT templates and my preference
would be that the fn:path function returns
"ancestor-or-self::node())[1]/foo/bar".

This is verbose but should work everywhere. 

The wording could be:

<newer.new>
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. If 
the root node is not a document node, this string is prefixed by 
"ancestor-or-self::node())[1]" . Each step consists of the character "/"
followed by a string whose form depends on the kind of node selected by that
step, as follows:
</newer.new>

It seems to me that this would make the result coherent between documents and
result trees on one hand and node fragments on the other hand in that the XPath
expression that you get from the function can be executed over any of the nodes
in the document or fragment to identify one specific node (and that's what I
think this function is really useful for).

Does it makes sense?

Eric

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 27 March 2012 18:05:03 UTC