This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

An XSLT puzzle


Hello, friends.

Imagine the following exotic situation.
A stylesheet contains a named template, say

  <xsl:template name="qq">...</xsl:template>

with "..." an arbitrary valid XSLT code.
This template is to be used in two different "regimes".
The first regime is the usual one: the template
is called via

  <xsl:call-template name="qq"/>

The second regime is exotic: the template's 
content is identically copied into the output
(as a result tree fragment).

For instance, let the stylesheet be as follows:

  <xsl:template name="qq">
    <node attr="{2+2=4}"/>
  </xsl:template>

  <xsl:template match="/">
    <results>
      <usual-result>
        <xsl:call-template name="qq"/>
      </usual-result>
      <exotic-result>
        ... your code ...
      </exotic-result>
    </results>
  </xsl:template>

Then the result of transforming a document
via this stylesheet should be as follows:

  <results>
    <usual-result>
      <node attr="true"/>
    </usual-result>
    <exotic-result>
      <node attr="{2+2=4}"/>
    </exotic-result>
  </results>

The task is to find a pure XSLT solution.
An interesting puzzle, isn't it?
(Not so difficult, though.)

-- 
Alexander E. Gutman

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]