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]

Re: Evaluating XPath expressions found in the source document


Hi James,

> If the source document that I am processing contains XPath
> expressions, how do I write a stylesheet that will process them?

The easiest way is to use an extension function to dynamically
evaluate strings as XPath expressions. What type of dynamic evaluation
is available to you depends on your processor. Saxon and Xalan-J both
have evaluate() extension functions in their respective namespaces. In
MSXML, it's fairly straight forward to write your own extension
function for evaluating location paths but I haven't seen one for
other expressions.

But if you want a pure XSLT solution, you need a two-stage process in
which you construct a stylesheet from your XML document, and then run
that generated stylesheet. So for example, in your stylesheet you'd
have:

  <xsl:element name="xsl:value-of">
    <xsl:attribute name="select">
      <xsl:value-of select="rootTag" />
    </xsl:attribute>
  </xsl:element>

which would create the following in the stylesheet that you generate:

  <xsl:value-of select="concat('A', 'B')" />

You can then run this generated stylesheet to get the result that
you're after.

Of course you could always write an XPath parser and evaluator in
XSLT, but that's likely to take a fair amount of work :)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]