[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] how to assign part of an attributes value to another attribute within the same element?
Subject: RE: [xsl] how to assign part of an attributes value to another attribute within the same element? From: "Houghton,Andrew" <houghtoa@xxxxxxxx> Date: Thu, 29 May 2008 20:01:06 -0400 |
> From: Tony Zanella [mailto:tony.zanella@xxxxxxxxx] > Sent: Thursday, May 29, 2008 7:52 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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[@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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] how to assign part of an attr, Tony Zanella | Thread | Re: [xsl] how to assign part of an , David Carlisle |
[xsl] how to assign part of an attr, Tony Zanella | Date | Re: [xsl] how to assign part of an , David Carlisle |
Month |
Keywords