[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Replacing portion of element name

Subject: RE: Replacing portion of element name
From: "Jim Fuller" <jim.fuller@xxxxxxxxxxxxxx>
Date: Mon, 24 Nov 2003 19:34:51 -0000
stylus studio 6 crack
Note that you have a space in your element...which is not allowed in xml.

Its relatively easy to get the name of a element and do something with
it...no need for extension functions, though if u were to use one I would
recc exslt regexp:replace at EXSLT
http://www.exslt.org/regexp/functions/replace/index.html 


If I have this as an xml file;

Xml document

<?xml version="1.0"?>
<commander_s_tracked_station_list>
test
</commander_s_tracked_station_list>

Then something like the following will print out

<xsl:value-of select="local-name(*)"/>

The name of the element...now you need to deal with replacing the
underscores with spaces, or the complex part to determine when to replace an
underscore with an apostrophe. Hmmmm

You could first place your element name in a variable to work with;

<xsl:variable name="myvar" select="local-name(*)"/>

Then easily convert underscores into spaces, using the translate() command;

<xsl:variable name="myvar1" select="translate($myvar,'_',' ')"/>

Then is the tricky part ( I have listed it in full again )

	
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method = "html" encoding="Windows-1252" />
	
	<xsl:template match="/">	

	<xsl:variable name="myvar" select="local-name(*)"/>
	
	<xsl:variable name="myvar1" select="translate($myvar,'_',' ')"/>


<xsl:value-of select="substring-before($myvar1,' s')"/>'s<xsl:value-of
select="substring-after($myvar1,'s')"/>
	
	
	</xsl:template>
</xsl:stylesheet>


You can come up with something iterative, but the below is the operative
term

<xsl:value-of select="substring-before($myvar1,' s')"/>'s<xsl:value-of
select="substring-after($myvar1,'s')"/>

Gl, jim fuller

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Boyd, Eddie
Sent: Monday, November 24, 2003 6:51 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'

Hi all,

I have an element name <commander_s_ tracked_station_list>, among others,
that needs to be transformed to a string with an apostrophe followed by an
s, i.e. "commander's tracked...".  How can I get the 's without using
external functions?  Is this possible with XSLT/XPATH 1.0?  I can easily
convert the underscores to a non-breaking space using the translate
function, but I have not been able to crack the code to make the apostrophe
appear in the appropriate place.  Any suggestions would be greatly
appreciated.

Thank you,
Eddie

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.