[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: how to assign part of an attributes value to anoth
> From: Tony Zanella [mailto:tony.zanella@xxxxxxxxx] > Sent: Thursday, May 29, 2008 7:52 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: 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[@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.
|
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
|