Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > carriage return

Reply
Thread Tools

carriage return

 
 
js
Guest
Posts: n/a
 
      08-19-2004
Hi,
This may not so much related to this group than xslt group, but just
desparately need to get the problem solved. So here it goes.

I have an XML document like the following. I use xsl to output the
html code. However, <br/> is always shown as is instead of a carriage
return. I've tried using &lt;br/&gt; and &#x0D and &#x0A. None of
these escape sequence worked. They all show up as typed. In addition,
the carriage return in the content would also cause the javascript
"unterminated string constant" error. I would appreciate if anyone
could help. Thanks.


XML
====

<root>
<news>
<content>The first paragraph with \'carriage return\' in single
quote.<br/> The second paragraph with \"carriage return\" in double
quote. <br/> The last paragraph.
</content>
</news>
<news>
<content>The first paragraph with \'carriage return\' escaped.
&#x0A; The second paragraph with \"carriage return\" escaped. &#x0D;
</content>
</news>
<news>
<content>The first paragraph with \'carriage return\' escaped.
&lt;br/&gt;. The second paragraph with \"carriage return\" escaped.
&#x0D;
</content>
</news>

</root>

Partial xslt
============
<xsl:template match="/root/news">
<xsl:variable name="displayLength">200</xsl:variable>
<xsl:variable name="formatContent">
<xsl:choose>
<xsl:when test='contains(content,"\")'>
<xsl:value-of disable-output-escaping="yes"
select='translate(content,"\","")'/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="content"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>


<p id="partialText" style="padding-left:10px">
<xsl:choose>
<xsl:when test="string-length(.)> $displayLength">
<xsl:value-of select="substring($formatContent,1,$displayLength) "/>...
<img id="ImgClickHere" src="/images/epingle.gif" alt="more"
height="15" width="15" align="top" title="click for full content">
<xsl:attribute name="onmouseover">this.style.cursor='hand'</xsl:attribute>
<xsl:attribute name="onclick">
var strContent = "<xsl:value-of select="content"/>";
var oContent = document.getElementById("moreNews");
var oFullContent = document.getElementById("fullContent");

oFullContent.innerHTML=strContent;
getPos(event);
with (oContent.style)
{
top = eTop;
left = eLeft;
display = 'block';
}
</xsl:attribute>
</img>
</xsl:when>
<xsltherwise><xsl:value-of
select="$formatContent"/></xsltherwise>
</xsl:choose>
</p>
</xsl:template>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Carriage Return added during return of large string from class method Xeno Campanoli Ruby 0 02-13-2006 08:39 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
Re: Carriage Return/Formatting/ASP/Access Question Jeff Clark ASP .Net 0 10-17-2003 08:43 AM
Re: Carriage Return/Formatting/ASP/Access Question Kevin Spencer ASP .Net 3 10-11-2003 07:19 PM
Postback after carriage return input Ferdi ASP .Net 5 08-24-2003 07:12 AM



Advertisments