[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

Subject: RE: 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
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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.