From: Tony Zanella [mailto:tony(_dot_)zanella(_at_)gmail(_dot_)com]
Sent: Thursday, May 29, 2008 7:52 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] how to assign part of an attributes value to another
attribute within the same element?
The output I get is:
<?xml version="1.0" encoding="UTF-8"?><root>
<ptr target="abc.07.7.1fm" n="abc.07.7.1fm"/>
<ptr target="abc.07.7.6tm" n="abc.07.7.6tm"/>
</root>
This is not quite what I want, which is:
<?xml version="1.0" encoding="UTF-8"?><root>
<ptr target="abc.07.7.1fm" n="1"/>
<ptr target="abc.07.7.6tm" n="6"/>
</root>
Since you are using XSL 2.0 then change your template to:
<xsl:template match="ptr[(_at_)target|@n]">
<xsl:element name="ptr">
<xsl:attribute name="target" select="@target"/>
<xsl:attribute name="n"
select="replace(@target,'^(.+\.)(\d+)([ft]m)$',$2)"/>
</xsl:element>
</xsl:template>
Andy.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--