Note that there are some explanatory texts on larger screens.

plurals
  1. POusing parentheses in xpath/xslt
    primarykey
    data
    text
    <p>I'm trying to use parentheses to override default operator precedence in an xpath expression within an xslt with no luck. For example:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl" version="1.0"&gt; &lt;xsl:output encoding="utf-8" standalone="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:apply-templates select="*"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@* | node()"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@* | node()"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;!--these should work but don't--&gt; &lt;xsl:template match="//(X|Y|Z)/AABBCC"/&gt; &lt;xsl:template match="(book/author)[last()]"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Visual Studio 2010 won't compile this returning:</p> <p>Unexpected token '(' in the expression. // -->(&lt;-- X|Y|Z)/AABBCC</p> <p>Unexpected token '(' in the expression. -->(&lt;-- book/author)[last()]</p> <p>Yet the second example is from MSDN:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms256086.aspx">http://msdn.microsoft.com/en-us/library/ms256086.aspx</a></p> <p>and numerous references say you can use parentheses in this way:</p> <p><a href="http://saxon.sourceforge.net/saxon6.5.3/expressions.html">http://saxon.sourceforge.net/saxon6.5.3/expressions.html</a></p> <p><a href="http://www.stylusstudio.com/xsllist/200207/post90450.html">http://www.stylusstudio.com/xsllist/200207/post90450.html</a></p> <p><a href="http://www.mulberrytech.com/quickref/XSLT_1quickref-v2.pdf">http://www.mulberrytech.com/quickref/XSLT_1quickref-v2.pdf</a></p> <p>Is this an xpath 1.0 vs 2.0 thing...or is there something else i'm missing? If it's an xpath 2.0 thing, is there a nice xpath 1.0 way to do the same thing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload