0

I have got a problem with locally stored .xml and .xls files.

My xml file is :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="statement.xsl" ?>
<STATEMENT_3>

   <SENTENCE>
      <MENTAL>In my mind there are things I remember and things that are confused </MENTAL> 
   </SENTENCE>    
   <SENTENCE>
      <MATTERIAL>I saw him near the basketball court </MATTERIAL>
   </SENTENCE>   
   <SENTENCE>
      <MATTERIAL> I saw him at my front door  </MATTERIAL>
    </SENTENCE>   

</STATEMENT_3>

My .xsl file is the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<html  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:13pt;background-color:#E8E09C">

<xsl:for-each select="STATEMENT_3/SENTENCE">

    <div style="background-color:blue;color:white;padding:4px">
        <span style="font-weight:bold"><xsl:value-of select="MENTAL"/> - </span>
    </div>

    <div style="background-color:green;color:white;padding:4px">
        <span style="font-weight:bold"><xsl:value-of select="MATTERIAL"/> - </span>
    </div>  

</xls:for-each>

</body>
</html>
</xsl:stylesheet>

Chrome gives blank page and Firefox says there is an error:

</xls:for-each>

I have googled a lot but couldn't find any working solution.

nikos
  • 3
  • 1
  • 3
  • You need to validate your XSLT before deploying and testing with a browser. The XSLTC tool will do that for you. The `xls:for-each` error would have been picked up by an IDE. – user207421 Jul 13 '15 at 01:18

1 Answers1

0
</xls:for-each>

needs to be:

</xsl:for-each>

In addition, your stylesheet must contain at least one template. Try something like:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
        <body style="font-family:Arial;font-size:13pt;background-color:#E8E09C">
            <xsl:for-each select="STATEMENT_3/SENTENCE">
                <div style="background-color:blue;color:white;padding:4px">
                    <span style="font-weight:bold"><xsl:value-of select="MENTAL"/> - </span>
                </div>
                <div style="background-color:green;color:white;padding:4px">
                    <span style="font-weight:bold"><xsl:value-of select="MATTERIAL"/> - </span>
                </div>  
            </xsl:for-each>
        </body>
    </html> 
</xsl:template>

</xsl:stylesheet>

For issues regarding XSLT in Chrome, see (for example): Testing xslt code using your browser

Community
  • 1
  • 1
michael.hor257k
  • 113,275
  • 6
  • 33
  • 51