XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
gemini mosesSubject: Replacing Attribute Value?
Author: gemini moses
Date: 13 Jun 2005 10:47 AM
Can I do it using XSLT? How ?

Portion of Input XML file --

<table name="very_long_name" >
....
....
</table>

I want it to be converted to --

<table name="short_name" >
.....
......
</table>


Please tell me how I can do this?

Thanks!

Posttop
Ivan PedruzziSubject: Replacing Attribute Value?
Author: Ivan Pedruzzi
Date: 13 Jun 2005 11:27 PM
Assuming your input xml looks like this

<?xml version="1.0"?>
<tables>
<table name="very_long_name"/>
<table name="very_long_name"/>
</tables>

Using the following XSLT you can change the value for the attribute 'name'. In my solution i just hard coded the value "short-name"

Hope this helps
Ivan Pedruzzi
Stylus Studio Team


<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<tables>
<xsl:apply-templates select="tables/table"/>
</tables>
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@name">
<xsl:attribute name="name">
<xsl:value-of select="'short-name'"/>
</xsl:attribute>
</xsl:template>

</xsl:stylesheet>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.