Sign Up
Search
Options
search
Chat
Help
News
Log in
Not Logged in
Home
»
Boards
»
Stylus Studio Developer Network
»
XSLT Help and Discussion
»
Replacing Attribute Value?
Topic
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
next
Subject:
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!
top
Subject:
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
Prev Topic
Next Topic
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 to Conference:
Select Conference
Stylus Studio Feature Requests
Stylus Studio Technical Forum
Website Feedback
XSLT Help and Discussion
XQuery Help and Discussion
Stylus Studio FAQs
Stylus Studio Code Samples & Utilities
Stylus Studio Announcements
go
Log In Options
Username:
Password:
Site Map
|
Privacy Policy
|
Terms of Use
|
Trademarks
Stylus Scoop XML Newsletter:
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.