This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Why processor or stylesheets puts strange output


Hi Thiabek,

All those <p>s are coming up because this html,
<br />
<br />
<br />
<br />
<br />
is in fact 5 br nodes and 5 text nodes - the text nodes are the linefeeds. 
This, <br /><br /><br /><br /><br />, on the other hand, is just 5 br nodes.

If you use <xsl:strip-space elements="body"/> at the top level of your
stylesheet, the whitespace
that becomes these unwanted text nodes will be stripped from the contents of
your <body> node,
and you won't get those pesky p's.

The reason your "it is text which has body as parent" doesn't appear is that
your body/text()
template is firing instead of the default text() template, which looks like
this:

<xsl:template match="text()|@*">
	<xsl:value-of select="."/>
</xsl:template>

Text nodes are like your br nodes, they don't have children so
<xsl:apply-templates> does
nothing. Just replace it with <xsl:value-of select="."/>.

salut,
Tom


> -----Original Message-----
> From: abradoom [mailto:thiabek@fastmail.fm]
> Sent: 23 August 2002 11:06
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Why processor or stylesheets puts strange output
> 
> 
> hello 
> I have been wondering why a simple thing is bothering me so much.
> i asked this on list...... got reply......  tried that...... and after
> all the things
> IT IS NOT WORKING
> 
> and this mail is quite lengthy as i wanted to explain every 
> thing which
> i can.
> I have a simple HTML 
> 
> <html>
> <head>
> <meta name="generator" content="HTML Tidy, see www.w3.org" />
> <title>HELLO LIST</title>
> </head>
> <body bgcolor="#C4C4C4" text="#443481" link="#1111EE">
> <p>This is for br tag</p>
> 
> <div>The stylesheet is doing some mischief</div>
> 
> <div><font size="+1">WHAT IS THE REASON ?</font><br />
> <br />
> <br />
> </div>
> 
> <br />
> <br />
> <br />
> <br />
> <br />
> <br />
> <p>Is it not the proper syntax for matching<br />
> tag.</p>
> 
> <br />
> <br />
> <br />
> <br />
> <br />
> it is text which has body as parent
> </body>
> </html>
> 
> i wrote a simple stylesheet to convert it in WML
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output omit-xml-declaration="yes"/>
> 
> 
> <xsl:template match="/">
> <wml>
> <card title="output">
> <xsl:apply-templates/>
> </card>
> </wml>
> </xsl:template>
> <xsl:template match="head"/>
> <xsl:template match="body">
> <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="p/div | div/div | center/div | font/div">
> <xsl:apply-templates/>
> </xsl:template>
>    
> <xsl:template match="div">
> <p><xsl:apply-templates/></p>
> </xsl:template>
> 
> <xsl:template match="font/p | center/p | div/p | p/p">
> <xsl:apply-templates/>
> </xsl:template>     
>       
> <xsl:template match="p">
> <p><xsl:apply-templates/></p>
> </xsl:template>
> 
> <xsl:template match="p/font | center/font | div/font | font/font">
> <xsl:apply-templates/>
> </xsl:template>     
> 
> <xsl:template match="font">
> <p><xsl:apply-templates/></p>
> </xsl:template>
> 
> <xsl:template match="br[preceding-sibling::node()[1][self::br]]" />
> 	
> 
> 
> <xsl:template match="body/text()" />
> 
> <xsl:template match="body/br" />
> 
> <xsl:template match="br">
>  <br />
>  </xsl:template>
> 
> </xsl:stylesheet>
> 
> You must be wondering why so many <br />template match.but that is the
> whole problem.
> all i want to do is put <br /> in the output if it is in input.that is
> simple.
> but i want if the <br />is just after <a> ...</a> or <li>...</li> or
> <br /> or it has body it's parent then do not put <br /> in 
> the output.
> now when i wrote this in the style sheet
> <xsl:template match="body/text()">
> <p><xsl:apply-templates /></p>
> </xsl:template>
> 
> and removing <xsl:template match="body/text()" />
> i got this output 
> <?xml version="1.0"?><!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML
> 1.2//EN'
>   'http://www.wapforum.org/DTD/wml_1.2.xml'><wml><card title="output">
> 
> <p/><p>This is for br tag</p><p/><p>The stylesheet is doing some
> mischief</p><p/><p>WHAT IS THE REASON ?<br/>
> <br/>
> <br/>
> </p><p/><p/><p/><p/><p/><p/><p/><p>Is it not the proper syntax for
> matching<br/>
> tag.</p><p/><p/><p/><p/><p/><p/>
> </card></wml>
> 
> the strange thing is the so many <p /> tags .i do not know from where
> they are coming as there is no <p /> in the stylesheet though many <p>
> and </p> are there.
> and not giving the "it is text which has body as parent" .I thought to
> sacrifice that ok not coming this text which has body as parent.
> but i tried for  not putting<br />in output if it is after <br /> as
> written in the style sheet(though i want to test for <a> <li> and <br
> /> but i tried only for <br /> )
> but it is giving this output
> <?xml version="1.0"?><!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML
> 1.2//EN'
>   'http://www.wapforum.org/DTD/wml_1.2.xml'><wml><card title="output">
> 
> <p>This is for br tag</p><p>The stylesheet is doing some
> mischief</p><p>WHAT IS THE REASON ?<br/>
> <br/>
> <br/>
> </p><p>Is it not the proper syntax for matching<br/>
> tag.</p>
> </card></wml>
> 
> this is better than that though not outputing text having body as
> parent but it has no strange <p/>.
> but it still has three <br /> after "WHAT IS THE REASON?" but 
> it should
> have one <br />.
> for this output i have used the stylesheet which is given .
> can any one tell me about strange out out and how to get correct
> output.
> 
> output should be like something
> 
> <?xml version="1.0"?><!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML
> 1.2//EN'
>   'http://www.wapforum.org/DTD/wml_1.2.xml'><wml><card title="output">
> 
> <p>This is for br tag</p><p>The stylesheet is doing some
> mischief</p><p>WHAT IS THE REASON ?<br/>
> </p><p>Is it not the proper syntax for matching<br/>
> tag.</p>
> <p>it is text which has body as parent</p>
> </card></wml>
> 
> 
> thiabek
> -- 
> http://fastmail.fm : send your email first class
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]