Xml+XSL: Problems with FireFox displaying

Jesper Stocholm

Usenet Archive
Joined
Oct 22, 2000
Messages
35
Reaction score
0
I have som XML that link to an XSL-file to enable on-the-fly HTML-generation by e.g. IE or FireFox. The transformation actually works like a charm, but I have problems with changing line breaks in the XML to their html-equivilant <br/>.

I use the XSL:

<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '
')">
<xsl:value-of select="substring-before($text, '
')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,' ')"/> </xsl:call-template> </xsl:when> <xsl:eek:therwise> <xsl:value-of select="$text"/> </xsl:eek:therwise> </xsl:choose> </xsl:template>

And I apply it to the specific XML-element with the code

<xsl:call-template name="break">
<xsl:with-param name="text" select="description"/>
</xsl:call-template>

When I display the XML-file in IE, it all looks fine and dandy - but when I load the page in FireFox (1.0 PR), the linebreaks are not converted to html-<br>-tags.

What am I doing wrong?

And - are there some programs out there that will allow me to supply a XML-file and a XSL-stylesheet - and then display the result of the XSL(T)-transaformation?
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Jesper said:
I have som XML that link to an XSL-file to enable on-the-fly HTML-generation by e.g. IE or FireFox. The transformation actually works like a charm, but I have problems with changing line breaks in the XML to their html-equivilant <br/>.

I use the XSL:

<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '
')">
<xsl:value-of select="substring-before($text, '
')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,' ')"/> </xsl:call-template> </xsl:when> <xsl:eek:therwise> <xsl:value-of select="$text"/> </xsl:eek:therwise> </xsl:choose> </xsl:template>

And I apply it to the specific XML-element with the code

<xsl:call-template name="break">
<xsl:with-param name="text" select="description"/>
</xsl:call-template>

When I display the XML-file in IE, it all looks fine and dandy - but when I load the page in FireFox (1.0 PR), the linebreaks are not converted to html-<br>-tags.

What am I doing wrong?

Hard to tell, maybe you can post the URLs of a short XML sample and XSLT demonstrating the problem. I see nothing wrong in that XSLT snippet you have above but the problem could be with your XML input.
 

Jesper Stocholm

Usenet Archive
Joined
Oct 22, 2000
Messages
35
Reaction score
0
Jesper Stocholm wrote:

Hard to tell, maybe you can post the URLs of a short XML sample and XSLT demonstrating the problem. I see nothing wrong in that XSLT snippet you have above but the problem could be with your XML input.

the content is located at http://blog.stocholm.dk

When displayed in IE the result is as expected - but not in FireFox

:)
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Jesper said:
the content is located at http://blog.stocholm.dk

When displayed in IE the result is as expected - but not in FireFox

You are transforming to XHTML but inside that template you call the <br/> elements are in the null namespace so make that

<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '
')">

<xsl:value-of select="substring-before($text, '
')"/>
<br xmlns="http://www.w3.org/1999/xhtml" />
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,' ')"/> </xsl:call-template> </xsl:when> <xsl:eek:therwise> <xsl:value-of select="$text"/> </xsl:eek:therwise>

</xsl:choose>
</xsl:template>

and it should work.

By the way, to output a DOCTYPE node you shouldn't use disable output escaping but rather the <xsl:eek:utput> element.
 

Jesper Stocholm

Usenet Archive
Joined
Oct 22, 2000
Messages
35
Reaction score
0
You are transforming to XHTML but inside that template you call the <br/> elements are in the null namespace so make that

aah ... :eek:)

<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '
')">

<xsl:value-of select="substring-before($text, '
')"/>
<br xmlns="http://www.w3.org/1999/xhtml" /> <xsl:call-template name="break"> <xsl:with-param name="text" select="substring-after($text,' ')"/> </xsl:call-template> </xsl:when> <xsl:eek:therwise> <xsl:value-of select="$text"/> </xsl:eek:therwise>

</xsl:choose>
</xsl:template>

and it should work.

It did, thanks.

By the way, to output a DOCTYPE node you shouldn't use disable output escaping but rather the <xsl:eek:utput> element.

Ok - I see your point. I changed it to

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

<xsl:eek:utput
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" encoding="ISO-8859-1" method="html" />

And the above now also looks as intended in FireFox.

Thanks for your help and have a nice weekend,

:eek:)
 

Morris M. Keesan

Usenet Archive
Joined
Oct 26, 2004
Messages
14
Reaction score
0
And - are there some programs out there that will allow me to supply a XML-file and a XSL-stylesheet - and then display the result of the XSL(T)-transaformation?

If you have a recent version of IE, you probably have MSXML somewhere on your system, if you can figure out how to use it.

Or you can use either of these two open-source XSLT processors

Saxon: http://saxon.sourceforge.net/ (Java based)
Xalan: http://xml.apache.org/xalan-j/ (Java version) or http://xml.apache.org/xalan-c/ (C++ version)
 

John Fereira

Usenet Archive
Joined
Jul 27, 2004
Messages
28
Reaction score
0
And - are there some programs out there that will allow me to supply a XML-file and a XSL-stylesheet - and then display the result of the XSL(T)-transaformation?

If you're looking for something that is free. Try jEdit. I know several people that like Eclipse and XMLBuddy as well. XMLSpy and StyleStudio are both good commercial products that will perform XML/XSLT transformation. The Xalan package has a simple XSTL transformation example that works fine from a command line.
 

Jesper Stocholm

Usenet Archive
Joined
Oct 22, 2000
Messages
35
Reaction score
0
If you have a recent version of IE, you probably have MSXML somewhere on your system, if you can figure out how to use it.

I bet I can - I have used it before, I just seem to remember a command-line tool I once used to test xslt-transformation.
Or you can use either of these two open-source XSLT processors

Saxon: http://saxon.sourceforge.net/ (Java based)
Xalan: http://xml.apache.org/xalan-j/ (Java version)

I will look at the above - or write a small test-harness in C#.

Thanks,

:eek:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top