我已经设法让我的表使用Saxon-CE,但是我找不到一种方法来指定我希望放置XSL表的元素。
有什么想法吗?
编辑: 对于缺乏代码的道歉,我试图在我离开工作之前发帖。这是代码:
EDIT2:我已经设法让结果文档现在正常工作,现在我只需要设置表格样式!我已使用工作代码更新了我的帖子。
XML文件:
<?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样式表:
<?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 >
我的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>
答案 0 :(得分:1)
我认为
<div id="foo"></div>
在HTML文档中
<xsl:result-document href="#foo">...</xsl:result-document>
样式表中的应该写入id为foo
的元素。请参阅http://saxonica.com/ce/user-doc/1.1/index.html#!coding/result-documents。