Subject: Variable
Posted By: safin Post Date: 10/4/2005 5:40:31 AM
Hi,
i have this code

<xsl:template match="@src">
 <xsl:variable name="imgURL" select="src"></xsl:variable>
 <xsl:attribute name="src"><xsl:value-of select="$imgURL"/></xsl:attribute>
</xsl:template>

But the $imgURL value is always an empty string
i'm trying to catch the src attribute from an <img> node (in an HTML file) and change it, but i need the current src value, so i can do some logic with it
Thanks

Reply By: mhkay Reply Date: 10/4/2005 5:48:50 AM
select="src" means select="child::src", it selects a child element of the context node. But within <xsl:template match="@src"> the context node is an attribute, and attributes don't have children. Perhaps you just want select=".". Actually I'm not sure why you want a variable at all, but you haven't show us all your logic presumably.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply By: safin Reply Date: 10/4/2005 6:09:15 AM
thanks for your help, it works now
I want to do some testing and parsing with the imgURL, but for simplification i didn't post it
Thanks


Go to topic 35375

Return to index page 460
Return to index page 459
Return to index page 458
Return to index page 457
Return to index page 456
Return to index page 455
Return to index page 454
Return to index page 453
Return to index page 452
Return to index page 451