[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Beginning an XPath expression with a function call
Monier, Yves wrote:
Given an XPath expression (for example //foo/foo2) that works for a given xml, I would like to use the substring-before function, to keep only the characters in //foo/foo2 before '-'. The XPath would then become substring-before(//foo/foo2, '-') It's perfectly valid XPath expression, but it cannot be used with / and // operators, because they explicitly require the expression to evaluate a nodeset: "The / and // operators compose an expression and a relative location path. It is an error if the expression does not evaluate to a node-set." http://www.w3.org/TR/xpath#node-sets And of course it cannot be used with xsl:apply-templates or xsl:for-each or msxsl's selectNodes, because they all require nodeset as result of the expression's evaluation. You can use function call as first part of of the path expression, day-to-day example is document('foo.xml')/*//bar like expressions or $foo/bar expressions.Do you know if there is a simple "legal" XPath-only-based solution to achieve the same result? What are you trying to achieve actually? substring-before(//foo/foo2, '-') is ok, have you tried <xsl:value-of select="substring-before(//foo/foo2, '-')"/> -- Oleg Tkachenko Multiconn Technologies, Israel XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|