RE: [xsl] Why processor or stylesheets puts strange output

Subject: RE: [xsl] Why processor or stylesheets puts strange output
From: "abradoom" <thiabek@xxxxxxxxxxx>
Date: Fri, 23 Aug 2002 13:23:12 UT
Thanks Tom
It seems only you are there to answer my questions.
thanks for your response  and patience.
I tried that but it is not working .
i think it is due to processor (SABLOTRON) WHICH I AM USING .
I FOUND THIS PARAGRAPH IN THE DOCUMENTATION OF SABLOTRON ON Ginger
Alliance site.
5.10  Whitespace stripping 
strip-space, preserve-space 

Only the default whitespace stripping is done. That is, all
whitespace-only text nodes in any stylesheet, not appearing inside a
xsl:text, are removed. The two instructions for whitespace stripping
and preservation are unsupported.


so i think using <xsl:strip-space="body"/> or even 
<xsl:strip-space="*"/>
is not going to make any effect .
with this stylesheet the output i got is
<?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:strip-space elements="body"/>
<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/br" />

<xsl:template match="br">
 <br />
 </xsl:template>
 
 <xsl:template match="body/text()">
  <p><xsl:value-of select="."/></p>
  </xsl:template>

</xsl:stylesheet>

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><p>This is for br tag</p><p>

</p><p>The stylesheet is doing some mischief</p><p>

</p><p>WHAT IS THE REASON ?<br/>
<br/>
<br/>
</p><p>

</p><p>
</p><p>
</p><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><p>
</p><p>
</p><p>
it is the text which has body parent
</p>
</card></wml>


it has no <p/> but still so many <p> and </p> so i think i should stick
to the previous one as it was giving the better output.
and it is very rarely happens that you find text inside body .
normally text had atleast some tag as parent.
what do you say?

thiabek











On Fri, 23 Aug 2002 12:13:19 +0100, TSchutzerWeissmann@xxxxxxxxxxxxxxxx
said:
> 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
>

-- 
http://fastmail.fm : send your email first class

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


Current Thread