I have managed to get my table working with Saxon-CE, however I cannot find a way to specify the element in which I would like my XSL Table placed.
Any ideas?
EDIT: Apologies for lack of code, was trying to post before I left work. Here is the code:
EDIT2: I have managed to get the result-document to now work, now I just need to style the table! I have updated my post with the working code.
XML File:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="stylesheet.xsl" type="text/xsl" ?>
<leaderboard>
<row>
<position>1</position>
<name>XXXXX</name>
<class>Mage</class>
<level>90</level>
<points>160</points>
</row>
<row>
<position>2</position>
<name>XXXXX</name>
<class>Warrior</class>
<level>90</level>
<points>155</points>
</row>
<row>
<position>3</position>
<name>XXXXX</name>
<class>Death Knight</class>
<level>90</level>
<points>145</points>
</row>
<row>
<position>4</position>
<name>XXXXX</name>
<class>Shaman</class>
<level>90</level>
<points>140</points>
</row>
<row>
<position>5</position>
<name>XXXXXXX</name>
<class>Druid</class>
<level>90</level>
<points>130</points>
</row>
<row>
<position>6</position>
<name>XXXXXX</name>
<class>Monk</class>
<level>90</level>
<points>120</points>
</row>
<row>
<position>7</position>
<name>XXXXXX</name>
<class>Warlock</class>
<level>90</level>
<points>115</points>
</row>
<row>
<position>8</position>
<name>XXXXXX</name>
<class>Priest</class>
<level>90</level>
<points>100</points>
</row>
<row>
<position>9</position>
<name>XXXXXX</name>
<class>Hunter</class>
<level>90</level>
<points>90</points>
</row>
<row>
<position>10</position>
<name>XXXXXX</name>
<class>Warrior</class>
<level>90</level>
<points>80</points>
</row>
</leaderboard>
XSL Stylesheet:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<xsl:result-document href="#leadertable" method="text">
<xsl:apply-templates select="leaderboard">
<xsl:sort select="position" data-type="number"/>
</xsl:apply-templates>
</xsl:result-document>
</xsl:template>
<xsl:template match="leaderboard" >
<table width="1070px" height="950px" border="1" >
<tr bgcolor = "#cccccc" >
<td>Position</td>
<td>Character Name</td>
<td>Class</td>
<td>Level</td>
<td>Points</td>
</tr>
<xsl:for-each select="row" >
<tr>
<td> <xsl:value-of select="position" /> </td>
<td> <xsl:value-of select="name" /> </td>
<td> <xsl:value-of select="class" /> </td>
<td> <xsl:value-of select="level" /> </td>
<td> <xsl:value-of select="points" /> </td>
</tr>
</xsl:for-each>
</table>
</xsl:template >
</xsl:stylesheet >
Content Page on my CMS:
<p>
<script type="text/javascript" language="javascript">// <![CDATA[
onSaxonLoad = function() {
proc = Saxon.run( {
stylesheet: '/mattmodx/assets/templates/imperious/xml/stylesheet.xsl',
source: '/mattmodx/assets/templates/imperious/xml/leaderboard.xml'
} );
}
// ]]></script>
</p>
<div class="leaderwrapper">
<div class="leaderboard"><img src="[[++site_url]]/assets/templates/imperious/images/leaderboardhead.png" alt="" width="1102" height="41" />
<div id="leadertable"> </div>
</div>
</div>
I think given
in your HTML document an
in your stylesheet is supposed to write to that element with id
foo
. See http://saxonica.com/ce/user-doc/1.1/index.html#!coding/result-documents.