Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] selecting an element in an external doc using its id attribute

From: "J.Pietschmann" <j3322ptm@-------->
To:
Date: 6/17/2002 2:45:00 PM
Cindy Mazza wrote:
But when I try to find an element whose id attribute is equal to the
value of the 'from' variable, I get an error saying "Unexpected token
[<function>] in path expression."

        <xsl:variable name="from" select="@from"/>
        <xsl:variable name="docnode" select="document('../texts/odes.xml')"/>
        <xsl:message>
          <xsl:value-of select="$docnode//id($from)"/>
        </xsl:message>

You can't use id() this way. A slash '/' in an XPath mus be
followed by another step, and functions, like id(), do not
fall into this category (in XPath 1.0).

Use either a predicete
  <xsl:message>
    <xsl:value-of select="$docnode//*[@id=$from]"/>
  </xsl:message>
(supposed all your ID attributes are named "id")
or change the context using an xsl:for-each:
  <xsl:message>
    <xsl:for-each select="$docnode">
      <xsl:value-of select="id($from)"/>
    </xsl:for-each>
  </xsl:message>

This makes it a bit inconvenient to use id() or key() to
grab elements from another document, but so are the rules...

J.Pietschmann




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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent