This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:value-of not allowed inside a stylesheet
The situation is that I compile the html file from several xsl and one xml
file. The value-of causes XSLT error, in the variable NumberOfMessages
"Compiler" file:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- used variables declaration -->
<xsl:import href="Variables.xsl" />
<!-- Build header of page -->
<xsl:import href="Header.xsl" />
<!-- Build sorting arrows -->
<xsl:import href="Sorting.xml" />
<!-- Build the topic listing -->
<xsl:import href="TopicList.xsl" />
<xsl:output method="html" encoding="ISO-8859-1" indent="yes" />
<xsl:template match="/">
<html>
<xsl:apply-imports/>
</html>
</xsl:template>
<xsl:template match="Subject">
<xsl:value-of select="concat(substring(., 1, 55),
substring('...', 1 div (string-length(.) > 55), 3))" />
</xsl:template>
</xsl:stylesheet>
Variables file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="status">
<xsl:for-each select="Document/Information">
<xsl:sort select="Time" order="ascending" />
<xsl:sort select="Clock" order="ascending" />
<xsl:if test="position() = last()">
<xsl:value-of select="@SignStatus" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="recent">
<xsl:for-each select="Document/Information">
<xsl:sort select="Time" order="ascending" />
<xsl:sort select="Clock" order="ascending" />
<xsl:if test="position() = last()">
<a href="html?{Subject/@id}{Subject/@id2}">
<xsl:apply-templates select="Subject" /></a>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="sender">
<xsl:for-each select="Document/Information">
<xsl:sort select="Time" order="ascending" />
<xsl:sort select="Clock" order="ascending" />
<xsl:if test="position() = last()">
<xsl:value-of select="Sender" />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="NumberOfMessages">
<xsl:for-each select="Document">
<xsl:value-of select="count(Information)" />
</xsl:for-each>
</xsl:variable>
</xsl:stylesheet>
Header file, that uses varibles (part of it):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<table width="800" height="20" border="0" cellspacing="2"
cellpadding="2" bgcolor="white">
<tr>
<td width="148" valign="top" bgcolor="#E1EDFF">
<p><b>Message count= </b><xsl:value-of
select="$NumberOfMessages" />
</p> </td>
<td width="58" valign="top" align="left" bgcolor="#E1EDFF">
<p><b>Recent: </b>
</p>
</td>
<xsl:comment>The recent message subject is found by variable "recent" in
Variables.xsl</xsl:comment>
<td width="360" valign="top" bgcolor="#E1EDFF"><p>
<xsl:copy-of select="$recent" /></p>
</td>
<xsl:comment>The recent message's status is found by variable "status" in
Variables.xsl</xsl:comment>
<td width="63" valign="top" bgcolor="#E1EDFF"><p ID="Status">
<xsl:value-of select="$status" /></p>
</td>
<xsl:comment>The recent message's sender is found by variable "status" in Variables.xsl</xsl:comment>
<td width="155" valign="top" bgcolor="#E1EDFF"><p>
<font size="-2"><xsl:value-of select="$sender" /></font>
</p></td>
</tr></table><br></br>
</xsl:stylesheet>
******************************************************************
Jarkko Moilanen *You are wise, witty, and wonderful, *
Researcher/ ITCM *but you spend too much time *
jm60697@uta.fi *reading this sort of trash. *
www.uta.fi/~jm60697 * *
GSM: +358 50 3766 927 * *
******************************************************************
* ITCM | Information Technology and Crisis Management *
* http://www.itcm.org *
******************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list