Topic: xml -> html with xslt Pages that link to <a href="https://ozoneasylum.com/backlink?for=23008" title="Pages that link to Topic: xml -&amp;gt; html with xslt" rel="nofollow" >Topic: xml -&gt; html with xslt\

 
Author Thread
anx721
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Aug 2004

IP logged posted posted 08-21-2004 00:45 Edit Quote

I have this xml file (a.xml):

code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="a.xsl"?>
<document>
<list>
<item>1</item>
<item>2</item>
<item>3</item>
</list>
</document>



this xslt file (a.xsl):

code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<xsl:apply-templates select="//list"/>
</body></html>
</xsl:template>


<xsl:template match="list">
<ul>
<xsl:for-each select="node()">
<li>element
<xsl:apply-templates select="." />
</li>
</xsl:for-each>
</ul>
</xsl:template>

</xsl:stylesheet>



and this is the result aftere the transformation with saxon 6.5.3 (a.html):

code:
<html>
<body>
<ul>
<li>element
</li>
<li>element 1
</li>
<li>element
</li>
<li>element 2
</li>
<li>element
</li>
<li>element 3
</li>
<li>element
</li>
</ul>
</body>
</html>




Why there are so many <li> items in the output and not just 3??? If i open the file a.xml with intertnet explorer 6.0 there are only 3 item in the list, but if i open it with FireFox the result is the same of saxon. Why? thank you for you replies.

(Edited by anx721 on 08-21-2004 00:46)

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

IP logged posted posted 08-21-2004 18:29 Edit Quote

Since you match all nodes within <list>, the whitespace before, after and between the item elements will also be matched. Instead, use

code:
<xsl:for-each select="*">

or

code:
<xsl:for-each select="item">



(Edited by HZR on 08-21-2004 19:44)

anx721
Obsessive-Compulsive (I) Inmate

From:
Insane since: Aug 2004

IP logged posted posted 08-21-2004 20:20 Edit Quote

thank you; i have resolved with '*' and now I've understood the behavior of node()

bye



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu