[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Recursive evaluation of elements

Subject: RE: Recursive evaluation of elements
From: "Rowan Sylvester-Bradley" <rowan@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 13 Dec 2009 19:26:21 -0000
RE:  Recursive evaluation of elements
Florent Georges wrote:

>I didn't look into the details, but it seems you simply want to expand
expressions recursively:
>as long as the result of an expansion contains curly braces, it should be
expanded itself.
>So at first glance, I would adapt the following:

    <xsl:matching-substring>
       <xsl:value-of select="
           saxon:eval(
               saxon:expression(regex-group(1)),
               $tablerow,
               $source
             )"/>
    </xsl:matching-substring>

>into the following (but as I said, I didn't look into the details,
>for instance would you have to adapt params, etc.):

    <xsl:matching-substring>
       <xsl:variable name="expanded" as="text()">
          <xsl:value-of select="
              saxon:eval(
                  saxon:expression(regex-group(1)),
                  $tablerow,
                  $source
                )"/>
       </xsl:variable>
       <xsl:apply-templates select="$expanded" mode="#current"/>
    </xsl:matching-substring>

Florent - Thanks for this suggestion. It does something interesting, but not
quite what I'm looking for! It will recursively evaluate expressions, but the
problem is that the context for the evaluation (i.e. the value of the
variables $p1 and $p2) is always that of the inner expansion. It therefore
generates:
<name>Item C (Second Class) delivered by Second Class</name>
Whereas what I need is:
<name>Item C (A nasty cheap one) delivered by Second Class</name>

It needs to evaluate the expression {concat($p2/../name, ' delivered by ',
$p1/name)} where $p2/../name needs to be the result of the expression Item C
({$p1/name}) in the context of the outer expansion, i.e. with $p1 set to the
first <row> of Table1. What it actually did, I think, is to re-evaluate the
expression Item C ({$p1/name}) in the context of the inner expansion, i.e.
with $p1 set to the first row of Table 2. Hence we got "Second Class" twice.

I've tried all sorts of ways of developing your approach to make it do what I
want, but nothing has worked so far.

Can anyone suggest a way of getting this to work?

Many thanks - Rowan

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.