Sign In/My Account | View Cart  
advertisement

Article:
 Controlling Whitespace, Part 1
Subject: please suggest a solution...problem with white space in node
Date: 2007-08-12 10:58:42
From: Bob DuCharme
Response to: please suggest a solution...problem with white space in node

(For questions like this, the XSL-list at http://www.mulberrytech.com/xsl/xsl-list/ is generally the place where XSLT questions will get the quickest answers.)


You're trying to create elements names from content, and space isn't allowed in element names. The translate function (see http://www.w3.org/TR/1999/REC-xpath-19991116#function-translate) will help you take them out; the following stylesheet (which can use any stylesheet as input) demonstrates how:


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


<xsl:variable name="s1">this is a test</xsl:variable>


<xsl:template match="/">
<xsl:value-of select="translate($s1,' ','')"/>
</xsl:template>


</xsl:stylesheet>


Just about any use of disable-output-escaping is a kludge. You'd be better off creating your elements with the xsl:element element. Then you could have something like
Bob



No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Sponsored By: