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

Re: Whitespace problem in IE5

Subject: Re: Whitespace problem in IE5
From: "Chanukov Orit" <orit@xxxxxxxxxxxxxxx>
Date: Wed, 26 May 1999 11:34:34 +0200
ie5 pre
Hi .
Thanks for the answer .
I tried it , but unfortunately it still doesn't work .
See attached XML/XSL files with this change .
Any ideas or comments will be appreciated .

Thanks again ,
Orit .
----- Original Message -----
From: Dave Dieno <daved@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Tuesday, May 25, 1999 7:59 PM
Subject: RE: Whitespace problem in IE5


> I think you need an HTML <PRE>...</PRE> block in your output stream...
> I.E.
> <xsl:template match="Spaces">
>      <PRE>
>      <xsl:eval > getText(this) </xsl:eval>
>      </PRE>
> </xsl:template>
>
> Cheers
> Dave
>
>
> > Hello .
> > Can anybody answer  on this question please ?
> > I have a problem with displaying whitespaces for a long time , and asked
> > some times this list about it ,
> > but didn't receive any answer .
> > Any comments will be appreciated .
> > Thanks in advance ,
> > Orit .
> >
> >
> > ----- Original Message -----
> > From: Chanukov Orit <orit@xxxxxxxxxxxxxxx>
> > To: <xsl-list@xxxxxxxxxxxxxxxx>
> > Sent: Sunday, May 23, 1999 12:44 PM
> > Subject: Re: Whitespace problem in IE5
> >
> >
> > > Hello .
> > >
> > > I'm transforming XML to HTML via XSL using IE5 too .
> > > I put there Dave's solution with <xsl:script>, but it still strips the
> > > whitespace.
> > > Could You please look on my XML/XSL test files  ?
> > > What wrong here ?
> > >
> > > XML :
> > >
> > > <?xml version='1.0'?>
> > > <?xml:stylesheet type="text/xsl" href="spaces1.xsl"
> > xml:space="preserve"?>
> > > <Screen >
> > > <Spaces xml:space="preserve">                    </Spaces>
> > > <Field >This text should be shown with offset 20</Field>
> > > </Screen>
> > >
> > >
> > > XSL :
> > >
> > > <?xml version='1.0'?>
> > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
> > > <xsl:template match="/">
> > > <HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
> > >  <BODY xml:space="preserve"  >
> > >  <xsl:apply-templates select="Screen"/>
> > >  </BODY>
> > > </HTML>
> > > </xsl:template>
> > >
> > > <xsl:script><![CDATA[
> > >   function getText(e) {
> > >     return (e.text);
> > > }
> > > ]]></xsl:script>
> > >
> > > <xsl:template match="Screen">
> > >  <xsl:apply-templates />
> > > </xsl:template>
> > >
> > > <xsl:template match="Field">
> > >   <xsl:apply-templates />
> > > </xsl:template>
> > >
> > > <xsl:template match="text()"><xsl:value-of /></xsl:template>
> > >
> > > <xsl:template match="Spaces">
> > >     <xsl:eval > getText(this) </xsl:eval>
> > > </xsl:template>
> > > </xsl:stylesheet>
> > >
> > >
> > > Thanks ,
> > > Orit .
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: Dave Dieno <daved@xxxxxxxxxxxx>
> > > To: <xsl-list@xxxxxxxxxxxxxxxx>
> > > Sent: Thursday, May 20, 1999 7:14 PM
> > > Subject: RE: Whitespace problem in IE5
> > >
> > >
> > > > FYI:
> > > >
> > > > I managed to work around the problem in IE5 with some help from MSDN
> > (see
> > > > Controlling Whitespace :
> > > > http://msdn.microsoft.com/xml/xslguide/xsl-whitespace.asp ).
> > > >
> > > > If you want to preserve the whitespace in your source document you
> > have
> > to
> > > > specify the following attribute for those source document elements
> > with
> > > > whitespace, for example:
> > > >
> > > > <sourceline xml:space="preserve">
> > > >
> > > > This passes the whitespace through to the stylesheet.
> > > >
> > > > However, it seems that in IE5 the <xsl:value-of> element strips the
> > > leading
> > > > whitespace.   When I looked at the text value of the <sourceline>
node
> > > using
> > > > Jscript and the DOM I found a workaround.
> > > >
> > > > <xsl:template match="sourceline">
> > > >     <xsl:eval> getText(this) </xsl:eval>
> > > > </xsl:template>
> > > >
> > > > <xsl:script><![CDATA[
> > > >   function getText(e) {
> > > >     return (e.text);
> > > > }
> > > >
> > > > Not very elegant, but it works :)
> > > >
> > > > Cheers,
> > > > Dave
> > > >
> > > >
> > > > > I haven't tried this, but I seem to remember its coming up before.
> > If
> > I
> > > > > recall, the solution is to use an <xsl:text> element to force the
> > > spaces.
> > > > > Something like:
> > > > >
> > > > > <PRE><xsl:text>     </xsl:text>Indented text</PRE>
> > > > >
> > > > > Worst case would be to use entity references for non-breaking
> > spaces.
> > > > >
> > > > > Hope that helps,
> > > > > John
> > > > >
> > > > > At 09:12 PM 05/19/1999 -0700, Dave Dieno wrote:
> > > > > >Yes, the HTML is placed in a <PRE> section... sorry, I should
have
> > > > > included
> > > > > >the XSL template:
> > > > > >
> > > > > ><xsl:template match="sourceline">
> > > > > > <PRE STYLE="font-family:monospace">
> > > > > >      <xsl:value-of />
> > > > > >  </PRE>
> > > > > ></xsl:template>
> > > > > >
> > > > > >I've also considered (but not tried) using the DTD approach I.E.
> > > > > <!ATTLIST
> > > > > >sourceline xml:space="preserve"> however I'm trying not to use a
> > DTD
> > > for
> > > > > >this project :)
> > > > > >Dave
> > > > > >
> > > > > > Steve Dahl wrote:
> > > > > >
> > > > > >> When you generate the HTML, do you put these text lines inside
a
> > > <PRE>
> > > > > >> section?
> > > > > >>
> > > > > >> XML's specifications control how XML is treated, but not how
HTML
> > is
> > > > > >> treated--HTML strips preceding and following whitespace unless
> > the
> > > text
> > > > > is
> > > > > >> in
> > > > > >> a <PRE>, and does not pay attention to xml:space.
> > > > > >>
> > > > > >>
> > > > > >> Dave Dieno wrote:
> > > > > >>
> > > > > >> > I'm transforming XML to HTML via XSL using IE5.
> > > > > >> >
> > > > > >> > I've got an XML element for which I would like to preserve
the
> > > > > >> whitespace
> > > > > >> > upon output to HTML.
> > > > > >> >
> > > > > >> > For example, I'd like the following XML fragment:
> > > > > >> >
> > > > > >> > <codelisting>
> > > > > >> > <sourceline>
> > > > > >> >     if ( x  ==    "testcase") {
> > > > > >> > </sourceline>
> > > > > >> > <sourceline>
> > > > > >> >         o.method(x);
> > > > > >> > </sourceline>
> > > > > >> > <sourceline>
> > > > > >> >     }
> > > > > >> > </sourceline>
> > > > > >> > </codelisting>
> > > > > >> >
> > > > > >> > Viewed in the browser as:
> > > > > >> >
> > > > > >> >     if ( x  ==    "testcase") {
> > > > > >> >         o.method(x);
> > > > > >> >     }
> > > > > >> >
> > > > > >> > My output font is monospaced, and I've tried using both the
> > > > > stylesheet
> > > > > >> > attribute:
> > > > > >> >
> > > > > >> > <xsl:stylesheet default-space="preserve"> and the element
> > > attribute:
> > > > > >> >
> > > > > >> > <sourceline xml:space="preserve">.
> > > > > >> >
> > > > > >> > What I get is:
> > > > > >> >
> > > > > >> > if ( x  ==    "testcase") {
> > > > > >> > o.method(x);
> > > > > >> > }
> > > > > >> >
> > > > > >> > While the whitespace within a line is preserved, all of the
> > leading
> > > > > >> > whitespace characters (spaces and tabs) are removed :(
> > > > > >> >
> > > > > >> > Any ideas?
> > > > > >> >
> > > > > >> > Thanks,
> > > > > >> > Dave Dieno
> > > > > >> > Aeroinfo Systems Inc.
> > > > > >> > http://www.aeroinfo.com
> > > > > >> >
> > > > > >> >  XSL-List info and archive:
> > > http://www.mulberrytech.com/xsl/xsl-list
> > > > > >>
> > > > > >> --
> > > > > >> - Steve Dahl
> > > > > >> sdahl@xxxxxxxxxxx
> > > > >
> > > > > ==========================================================
> > > > > John E. Simpson            | The secret of eternal youth
> > > > > simpson@xxxxxxxxxxx        | is arrested development.
> > > > > http://www.flixml.org      |  -- Alice Roosevelt Longworth
> > > > >
> > > > >
> > > > >  XSL-List info and archive:
> > http://www.mulberrytech.com/xsl/xsl-list
> > > >
> > > >
> > > >  XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
> > > >
> > >
> > >
> > >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> > >
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="spaces1.xsl" xml:space="preserve"?>
<Screen >
<Spaces xml:space="preserve">          </Spaces>
<Field colr="2">This text should be shown with offset 20</Field>
</Screen>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
	<BODY xml:space="preserve"  >
	<xsl:apply-templates select="Screen"/>
	</BODY>
</HTML>
</xsl:template>

<xsl:script><![CDATA[
  function getText(e) {
    return (e.text);
}
]]></xsl:script>

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

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

<xsl:template match="text()"><xsl:value-of /></xsl:template>

<xsl:template match="Spaces">
    <PRE ><xsl:eval > getText(this) </xsl:eval></PRE>

</xsl:template>



</xsl:stylesheet>
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.