Connecting Tech Pros Worldwide Forums | Help | Site Map

Xml+XSL: Problems with FireFox displaying

Jesper Stocholm
Guest
 
Posts: n/a
#1: Jul 20 '05
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, '&#xa;')">
<xsl:value-of select="substring-before($text, '&#xa;')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substring-after($text,'&#xa;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</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?

--
Jesper Stocholm
http://stocholm.dk

"Man knepper ikke en anden ridders mø"

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying




Jesper Stocholm wrote:[color=blue]
> 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, '&#xa;')">
> <xsl:value-of select="substring-before($text, '&#xa;')"/>
> <br/>
> <xsl:call-template name="break">
> <xsl:with-param name="text" select="substring-after($text,'&#xa;')"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$text"/>
> </xsl:otherwise>
> </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?[/color]

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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jesper Stocholm
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying


On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
[color=blue]
> Jesper Stocholm wrote:[/color]
[color=blue][color=green]
>> What am I doing wrong?[/color]
>
> 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.[/color]

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

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

:-)

--
Jesper Stocholm
http://stocholm.dk

"Man knepper ikke en anden ridders mø"
Martin Honnen
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying




Jesper Stocholm wrote:[color=blue]
> On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
>
>[color=green]
>>Jesper Stocholm wrote:[/color]
>
>[color=green][color=darkred]
>>>What am I doing wrong?[/color]
>>
>>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.[/color]
>
>
> the content is located at http://blog.stocholm.dk
>
> When displayed in IE the result is as expected - but not in FireFox[/color]

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, '&#xa;')">

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

</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:output> element.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jesper Stocholm
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying


On Fri, 05 Nov 2004 15:03:02 +0100, Martin Honnen wrote:
[color=blue]
> Jesper Stocholm wrote:[color=green]
>> On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
>>
>>[color=darkred]
>>>Jesper Stocholm wrote:[/color]
>>
>>[color=darkred]
>>>>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.[/color]
>>
>>
>> the content is located at http://blog.stocholm.dk
>>
>> When displayed in IE the result is as expected - but not in FireFox[/color]
>
> You are transforming to XHTML but inside that template you call the
> <br/> elements are in the null namespace so make that[/color]

aah ... :o)

[color=blue]
> <xsl:template name="break">
> <xsl:param name="text" select="."/>
> <xsl:choose>
> <xsl:when test="contains($text, '&#xa;')">
>
> <xsl:value-of select="substring-before($text, '&#xa;')"/>
> <br xmlns="http://www.w3.org/1999/xhtml" />
> <xsl:call-template name="break">
> <xsl:with-param name="text" select="substring-after($text,'&#xa;')"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$text"/>
> </xsl:otherwise>
>
> </xsl:choose>
> </xsl:template>
>
> and it should work.[/color]

It did, thanks.

[color=blue]
> By the way, to output a DOCTYPE node you shouldn't use disable output
> escaping but rather the <xsl:output> element.[/color]

Ok - I see your point. I changed it to

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

<xsl:output
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,

:o)

--
Jesper Stocholm
http://stocholm.dk

"Man knepper ikke en anden ridders mø"
Morris M. Keesan
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying


On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.invalid>
wrote:
[color=blue]
>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?[/color]

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)

--
Morris M. Keesan -- keesan@alum.bu.edu

John Fereira
Guest
 
Posts: n/a
#7: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying


Jesper Stocholm <j@stocholm.invalid> wrote in
news:cb6a7onsklo0$.lrb5z4ddb1jk$.dlg@40tude.net:

[color=blue]
> 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?
>[/color]

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
Guest
 
Posts: n/a
#8: Jul 20 '05

re: Xml+XSL: Problems with FireFox displaying


On Fri, 05 Nov 2004 23:15:41 GMT, Morris M. Keesan wrote:
[color=blue]
> On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.invalid>
> wrote:
>[color=green]
>>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?[/color]
>
> 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.[/color]

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.
[color=blue]
> 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)[/color]

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

Thanks,

:o)

--
Jesper Stocholm
http://stocholm.dk

"Man knepper ikke en anden ridders mø"
Closed Thread


Similar .NET Framework bytes