Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a value 1

Status
Not open for further replies.

Miros

Programmer
Jan 27, 2001
506
0
0
US
My XML input file has tags similar to the following:
Code:
<tag>Name [345:456]</tag>
<tag>Name1 Name2 [1345:5456]</tag>

I'd like my output to look like this:
Code:
Name,345,456
Name1 Name2,1345,5456

I assume I need to work with value-of(), but have no idea where to start.

 
I'd prefer an XSL solution. Sorry I forgot to mention it!
 
You can make a named template for that purpose. For instance, a realization of the named template, "processtag", can be called when "tag" node is in context.
[tt]
<xsl:template name="processtag">
<xsl:variable name="desc" select="normalize-space(substring-before(.,'['))" />
<xsl:variable name="data" select="normalize-space(substring-before(substring-after(.,'['),']'))" />
<xsl:value-of select="$desc" />
<xsl:value-of select="','" />
<xsl:value-of select="translate($data,':',',')" />
</xsl:template>
[/tt]
 
Final fix:
Code:
<xsl:value-of select="translate(translate(translate(.,':',','),' [',','),']','')" /><xsl:text> 
</xsl:text>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top