Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Carrige returns in xsl code?

0 views
Skip to first unread message

Jose Gilberto Torres

unread,
Aug 6, 2001, 3:08:57 PM8/6/01
to
Hello,
I have a really lame question. Within in my xsl code I have a couple
"if" statements within a "for-each" loop that takes up a few lines of
code. Reading the code looks really ugly. Is there a way I can put
in carrige returns or some special character in the code with out
screwing up the code. When I put "CR"s , it causes compile errors in
tomcat/cocoon. Thanks!

P.S.
Here is my example if it helps. It's ugly! I'm trying to build an
CGI URL.

<xsl:value-of select="$position"/> =
insFld(<xsl:value-of select="generate-id(..)"/>,
gFld("<xsl:value-of select="$node-name"/>",

"editor.jsp?node-name=<xsl:value-of
select="$node-name"/><![CDATA[&]]><xsl:for-each select='@*'><xsl:if
test='position()> 1'><![CDATA[&]]></xsl:if><xsl:value-of
select='name(.)'/><xsl:text>=</xsl:text><xsl:value-of
select='(.)'/></xsl:for-each><![CDATA[&]]>text-node<xsl:text>=</xsl:text><xsl:value-of
select='normalize-space(text())'/>"));

Kenneth J Hughes

unread,
Aug 7, 2001, 12:05:28 PM8/7/01
to
jogeeda...@yahoo.com (Jose Gilberto Torres) wrote in message news:<ac9e029c.01080...@posting.google.com>...

Use the fact that whitespace-only text nodes will be pruned away.
You can selectively wrap your output text with xsl:text to take
advantage of this property.

For example, the following XSLT generates "ABCD" all on the same line
yet is still very readable:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:text>A</xsl:text>
<xsl:text>B</xsl:text>
<xsl:text>C</xsl:text>
<xsl:choose>
<xsl:when test="1">
<xsl:text>D</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>E</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


Kenneth J. Hughes k...@entel.com
Entelechy Corporation http://www.entel.com/

0 new messages