[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Context node traversal inside predicates (was: Nodes and Strings)


Subject: [xsl] Context node traversal inside predicates (was: Nodes and Strings)
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Tue, 26 Jul 2005 14:10:28 +0200

Hello group,

Tempore 22:47:47, die 07/25/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Elaine Prata <Elaine.Prata@xxxxxxxxxxxxxx>:

<setA>
    <element>value1</element>
    <element>value2</element>
    <element>value3</element>
    <element>value4</element>
    <element>value5</element>
</setA>

<setB>
    <element>aStringBeforeValue.value1</element>
    <element>aStringBeforeValue.value2</element>
    <element>aStringBeforeValue.value3</element>
</setB>

expected result (for intersection between the sets):

<setC>
    <element>value1</element>
    <element>value2</element>
    <element>value3</element>
</setC>


This problem encouraged me to finally post about some lack of functionality I've always been experiencing in XPath1.0


I'd wish I could solve the problem above with an Xpath like this:

$SetA/Element[$setB/Element[substring-after(.,'.')=context(1)]]

The 'context()' function would be similar to the 'current()' fuction.
It would recall previous context nodes.

'context(n)' would recall the n-th context node (as found when propagating upwards in the predicates of the expression)

e.g.:
'context(0)' is equal to '.'
'context(1)' is equal to the context node as constructed by the immmediately outer predicate.
...
'context(-1)' would be equal to the context node as found in the outermost predicate.


Will this kind of functionality be available in Xpath 2 ? Or is it a proof of bad coding practices that one thinks he should be needing this?

please ask for more explanation if I did not stated this clear.

Thanks in advance for any reply...
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
"NN= N?N/N4N1 OON9 N?ON4N-N= N?N/N4N1"  - N#O	N:ON1ON7O


Current Thread
Keywords