Hi,

does XALAN handle for-each correctly? MSXML and XMLSpy 2005 display
all occurrences of xpg:keywords, XALAN (2.4.1) only the first one.

Thanks in advance
Reinhard Haller

PAGE-DEMO.XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                      xmlns="http://www.w3.org/1999/xhtml";
                     
xmlns:xpg="http://www.interactive-net.de/ns/page";
                     exclude-result-prefixes="xpg">
        <xsl:output  method="xml" 
                         omit-xml-declaration="yes"
                         version="1.0" 
                         encoding="ISO-8859-1"
                         doctype-public="-//W3C//DTD XHTML 1.0
Strict//EN" 
                        
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; 
                         indent="yes"/>

        <xsl:template match="/">
                <html xmlns="http://www.w3.org/1999/xhtml"; lang="de"
xml:lang="de">
                        <xsl:apply-templates select="xpg:page"/>
                </html>
        </xsl:template>

        <xsl:template match="xpg:page">
                <xsl:call-template name="htmlhead"/>
                <body>
                </body>
        </xsl:template>

        <xsl:template name="htmlhead">
                <head>
                        <meta http-equiv="Content-type"
content="text/xhtml+xml; charset=iso-8859-1"/>
                        <meta http-equiv="Content-language"
content="de-de"/>
                        <meta name="copyright"
content="{xpg:copyright}"/>
                        <xsl:text>
</xsl:text>
                        <xsl:for-each select="//xpg:keywords |
//xpg:keywords/@alternate"> 
                                <xsl:comment>Count:<xsl:value-of
select="last()"/> - Position:<xsl:value-of select="position()"/> -
Value:<xsl:value-of select="."/>
                                </xsl:comment>
                                <xsl:choose>
                                        <xsl:when test="position()=1">
                                                <xsl:comment>Test Pos 1
ok</xsl:comment>
                                        </xsl:when>
                                        <xsl:when
test="position()=last()">
                                                <xsl:comment>Test Pos
last ok</xsl:comment>
                                        </xsl:when>
                                        <xsl:otherwise>
                                                <xsl:comment>Test Pos
other ok</xsl:comment>
                                        </xsl:otherwise>
                                </xsl:choose>
                        </xsl:for-each>
                        <xsl:text>
</xsl:text>
                </head>
        </xsl:template>
</xsl:stylesheet>

DEMO.XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<xpg:page xmlns:xpg="http://www.interactive-net.de/ns/page";
                xmlns="http://www.w3.org/1999/xhtml";
                name="demo.html">
<xpg:copyright date="2005">INTERACTIVE Computer Systems
GmbH</xpg:copyright>
<xpg:keywords>Spam</xpg:keywords>
<xpg:content>
  <h3>demo</h3>
  <p>demo text 
        (<xpg:setLink id="18"><xpg:keywords alternate="Sender Policy
Framework">SPF</xpg:keywords></xpg:setLink>/
        <xpg:setLink
id="19"><xpg:keywords>Caller-ID</xpg:keywords></xpg:setLink>).  
  </p>
  <p>demo text 
        <xpg:keywords>last</xpg:keywords> demo text.
  </p>
</xpg:content>
</xpg:page>

DEMO.HTML (XMLSpy-Output)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; lang="de" xml:lang="de">
        <head>
                <meta content="text/xhtml+xml; charset=iso-8859-1"
http-equiv="Content-type"/>
                <meta content="de-de" http-equiv="Content-language"/>
                <meta content="INTERACTIVE Computer Systems GmbH"
name="copyright"/>
<!--Count:5 - Position:1 - Value:Spam-->
                <!--Test Pos 1 ok-->
                <!--Count:5 - Position:2 - Value:SPF-->
                <!--Test Pos other ok-->
                <!--Count:5 - Position:3 - Value:Sender Policy
Framework-->
                <!--Test Pos other ok-->
                <!--Count:5 - Position:4 - Value:Caller-ID-->
                <!--Test Pos other ok-->
                <!--Count:5 - Position:5 - Value:last-->
                <!--Test Pos last ok-->
</head>
        <body/>
</html>

DEMO.HTML (XALAN-Output)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="de" lang="de">
<head>
<meta content="text/xhtml+xml; charset=iso-8859-1"
http-equiv="Content-type" />
<meta content="de-de" http-equiv="Content-language" />
<meta content="INTERACTIVE Computer Systems GmbH" name="copyright" />
<!--Count:5 - Position:1 - Value:Spam--><!--Test Pos 1 ok-->
</head>
<body />
</html>

Reply via email to