[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: break line using stylesheet

Subject: Re: break line using stylesheet
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Fri, 21 Oct 2005 08:47:49 -0500
div break line
On 10/21/05, Vincent Lapointe <lapointe_vincent_1975@xxxxxxxxxxx> wrote:
> Hi all,
> I'm pretty new to xml/xsl/html files and have the following problem: I'm
> using xml and xsl to generate a simple html file.

In XML files elements that are empty still need a closing tag or need
to use the empty tag symbols...

ie <br> should be either <br /> or <br></br>.  You don't have a
well-formed XML file.  If it's not an element, and you're doing
character escaping it is just text.  If you need to convert sgml to
xml there are tools out there (drawing a blank, but I'm pretty sure
James Clark has one. trang?  )  Of course, if it's just sgml html you
can convert it using tidy.


> the same output as internet explorer. In internet explorer the break lines
> appear as html break lines, but in mozilla the break lines appear as
> litteral string "<br>".

You've done disable-output-escaping (doe), so that probably causing
the problem.  It's not required for a processor to implement.  (It's
described more in 16.4 of the XSLT 1.0 spec).

> - I setted the disable-output-escaping attribute to "yes" and "no", and it
> didn't work with above combination...

Again, why the heck are you using doe?

> - I added the <xsl:preserve-space elements="text"/> in my xsl file and it
> didn't work with above combination...

Considering that <br> isn't  whitespace that certainly wouldn't work.
How you are treating it is the opposite of whitespace, ie right now
it's pure character data.  But for it to be really useful, you need to
treat it as an element.  Remember XSLT doesn't treat any xml input in
a special way.  It has no idea that <br> is supposed to be
"whitespace".

> Any idea? Thanks for your comments...
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
> <xsl:template match="root">
> <html>
> <body>
> <xsl:apply-templates select="text"/>
> </body>
> </html>
> </xsl:template>
> <xsl:template match="text">
> <div>
> <xsl:value-of select="." disable-output-escaping="yes"/>
> </div>
> </xsl:template>
> </xsl:stylesheet>

Why the xsl:value-of select="." disable-output-escaping="yes"?

Why not just do something like the following example?

> <xsl:template match="text">
> <div>
<xsl:apply-templates />
> </div>
> </xsl:template>

<xsl:template match="br">
<br />
</xsl:template>

That way the built-in rules will catch the various text nodes, and the
br will work once you actually have well-formed XML.

These are all FAQs, and you might want to look through some tutorials
and the FAQ.


Jon Gorman

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.