wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Replacing elemnt name using XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Replacing elemnt name using XSL" Watch "Replacing elemnt name using XSL" New topic
Author

Replacing elemnt name using XSL

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
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!
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Sure it can be done.
Something like -

<xsl:variable name="newTableName" select="substring(/Table/@name, 10)"/>

This truncates the value of Table/@name attribute and returns the forst 10 chars, which you can use as the 'short-name' for the new table element that you write after transforming.

The constructs you are looking for are substring, substring-before and substring-after. Check the XSLT/XPath specs for the details on these functions. Don't have the links handy right now.

- m


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Thanks you!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Replacing elemnt name using XSL