Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT: remove CRLF from a string

Status
Not open for further replies.

GuardianOfTheFlame

Programmer
Sep 4, 2007
31
IT
Hi all,
how can I remove CRLF chars from a string?
I have this fragment of XML that create a javascript output:

Code:
<xsl:text>
        dd.elements["</xsl:text><xsl:value-of select="@domid"/><xsl:text>"].props["content"] = "</xsl:text>
      <xsl:call-template name="cleanQuote">
        <xsl:with-param name="string"><xsl:value-of select="./content" />
        </xsl:with-param>
      </xsl:call-template>
      <xsl:text>";</xsl:text>

my output is:

Code:
dd.elements["paragraph_62"].props["content"] = "sdfsdfsdf&nbsp;<br />
<br />
<br />
sfsd sdfsfdfsd&nbsp;<br />
<br />
<br />
<br />
sfdsfdsfd sfdsfd&nbsp;<br />
safsdff";

the problem is that the CRLF chars cause problems in the resulting page... so I want this output:
Code:
dd.elements["paragraph_62"].props["content"] = "sdfsdfsdf&nbsp;<br /><br /><br />sfsd sdfsfdfsd&nbsp;<br /><br /><br /><br />sfdsfdsfd sfdsfd&nbsp;<br />safsdff";

must I use the translate() function? if so how can I specify the CRLF char?
Code:
<xsl:value-of select="translate(./content,CRLF,'')" />
Thanks!
Salo

The surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us - Calvin (and Hobbes) ;-)
 
The behaviour likely arises in the named template and it can be controlled if alternative outcome like what described is more desirable. Judiciously use normalize-space() xslt function to render text value in the template. Or else, show the forum the template.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top