![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - XSLT evaluate XPath from a string >Thread Next - Re: XSLT evaluate XPath from a string Re: XSLT evaluate XPath from a stringTo: NULL Date: 8/20/2008 1:05:00 PM Mycroft wrote: > I have tried using code from EXSLT but that has not worked and everything I > read suggests that XSLT 2.0 might have a method to perform this operation, > but I find no examples. Saxon 9 is the current Saxon version that implements XSLT and XPath 2.0. It has http://www.saxonica.com/documentation/extensions/functions/evaluate.html and http://www.saxonica.com/documentation/extensions/functions/evaluate-node.html so with your sample XML corrected to (you had 'type' instead of '@type' which does not find anything) <library> <books> <book title="A" type="science fiction"/> <book title="B" type="fantasy"/> <book title="C" type="romance"/> <book title="D" type="science fiction"/> <book title="E" type="Christianity"/> </books> <librarian> <defaultXPath>//book[@type="Christianity"]</defaultXPath> </librarian> </library> and a stylesheet with <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="saxon" version="2.0"> <xsl:template match="/"> <xsl:apply-templates select="saxon:evaluate-node(library/librarian/defaultXPath)"/> </xsl:template> <xsl:template match="book"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> the output is <?xml version="1.0" encoding="UTF-8"?><book title="E" type="Christianity"/> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
