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

Re: How to expand a string

Subject: Re: How to expand a string
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 30 Aug 2006 12:19:25 +0100
xsl expanding a string
> but I am stuck in the 1.0 world;


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
<xsl:template match="w">
was: <xsl:value-of select="."/>
now: <xsl:call-template name="decamel"/> 
</xsl:template>

<xsl:template name="decamel">
  <xsl:param name="s" select="."/>
  <xsl:variable name="a" select="substring($s,1,1)"/>
  <xsl:if test="not(translate($a,'QWERTYUIOPASDFGHJKLZXCVBNM',''))">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:value-of select="$a"/>
  <xsl:if test="string-length($s)&gt;1">
    <xsl:call-template name="decamel">
      <xsl:with-param name="s" select="substring($s,2)"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>
</xsl:stylesheet>


<x>
<w>FailedCriteria</w>
<w>NoSampleDetected</w>
<w>OutsideOfCalibrationRange</w>
<w>DetectorOverRange</w>
</x>


$ saxon camel.xml camel.xsl
<?xml version="1.0" encoding="utf-8"?>

was: FailedCriteria
now:  Failed Criteria

was: NoSampleDetected
now:  No Sample Detected

was: OutsideOfCalibrationRange
now:  Outside Of Calibration Range

was: DetectorOverRange
now:  Detector Over Range


(with a bit of extra work you could avoid putting a space in front of
leading capitals as well)

David

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-2011 All Rights Reserved.