473,809 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xml+XSL: Problems with FireFox displaying

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="substri ng-before($text, '&#xa;')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<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="descrip tion"/>
</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ø"
Jul 20 '05 #1
7 6254


Jesper Stocholm wrote:
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="substri ng-before($text, '&#xa;')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<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="descrip tion"/>
</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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
Jesper Stocholm wrote:

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.


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ø"
Jul 20 '05 #3


Jesper Stocholm wrote:
On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:

Jesper Stocholm wrote:


What am I doing wrong?


Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
demonstrati ng 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


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="substri ng-before($text, '&#xa;')"/>
<br xmlns="http://www.w3.org/1999/xhtml" />
<xsl:call-template name="break">
<xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwis e>
<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/
Jul 20 '05 #4
On Fri, 05 Nov 2004 15:03:02 +0100, Martin Honnen wrote:
Jesper Stocholm wrote:
On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:

Jesper Stocholm wrote:
What am I doing wrong?

Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
demonstratin g 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


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


aah ... :o)

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

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

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


Ok - I see your point. I changed it to

<xsl:styleshe et 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ø"
Jul 20 '05 #5
On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.inv alid>
wrote:
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)

--
Morris M. Keesan -- ke****@alum.bu. edu

Jul 20 '05 #6
Jesper Stocholm <j@stocholm.inv alid> wrote in
news:cb******** *************** ******@40tude.n et:

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.
Jul 20 '05 #7
On Fri, 05 Nov 2004 23:15:41 GMT, Morris M. Keesan wrote:
On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.inv alid>
wrote:
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.


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,

:o)

--
Jesper Stocholm
http://stocholm.dk

"Man knepper ikke en anden ridders mø"
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2858
by: Marcel | last post by:
Hello all, I am working on a generic (php) script to produce (X)HTML Forms through XML and XSL based on field-definitions stored in a database. The basic way i did HTML-forms in PHP was like this: http://212.204.203.71/test/simpleform/simpleform.php source: http://212.204.203.71/test/syntax/simpleform.php
9
3285
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd no longer wait. Some Googling pointed me to several beginner tutorials, and I chose to get myself going with the guide at http://rzserv2.fhnon.de/%7Elg002556/docbuch/
2
3179
by: kmunderwood | last post by:
I am having trouble changing the font size when extracting xml into an html web page. I think it can be done so many ways, that my searches bring up examples that I am not familiar with. I am a newbie at xml and xsl This is my xml("index.xml")page(I can not change this, it comes to me this way. <?xml version="1.0" encoding="iso-8859-1" ?>
2
1024
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to...
3
2271
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We use this so that we can specify different templates to be used by the same xml node. Know that we could use global params, but would rather not have to update all teh stylesheets and any code that uses msxml and the same stylesheets.
2
3723
by: KJS | last post by:
Hello, I'm receiving: 'System.Xml.Xsl.XsltException: Missing mandatory attribute 'version' After I try and run my transformation. I spent a good few days coming up with the appropriate (I think) methods, and overrides for this task. I have verified that the source XML and XSL will transform by means of using the MSXML command line parsing tool (previous version of MSXML though). Here is my code:
2
2076
by: Joe Kraft | last post by:
We just turned on a new website that runs on an XML/XSL templates that get transformed using various .Net objects. The final call is to the MSXML3 TransformNode function. Though the page loads as expected, when it is running the TransformNode function the CPU on the server (2 2Ghz processors hyperthreaded so the server sees 4...1gig of RAM) gets pegged at 100% utilization for about a second while it's generating the HTML. We've found that a...
1
1177
by: danc888 | last post by:
I am attempting to write an XSL file to transform the orignal XML document to only show the elements I need. I have a problem though, the XML document contains an xmlns "urn" which when present means my XSL file does not work and shows nothing. What I am doing wrong? I am newbie to all of this so any help would be great. <b>XML Document:</b> <?xml version="1.0" encoding="UTF8" ?>
5
5433
by: Kniffel | last post by:
Hi everyone I do a xsl-transformation. And I try to get a Attribute, but I cannot get it. My XML/XSL experience is not very good at the moment. I have something like this: TEST.xml -------------- <?xml version="1.0" encoding="utf-8"?> <Main>
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.