Javascript XSLT paged显示一些计算出的节点值以及在下一行(II)中检索到的前一行值
使用上一个链接的另一个请求再次签回,如以下stackoverflow链接所示: 我不会重复整个问题的细节,因为它们可以检查出来 通过上述链接。 第二个新请求也基于提供的upkeep share bills list.xml文件,需要显示相同的数据,但需要分页(分页)。 假设我在该.xml文件中有几十行,自然应该对其进行分页,以获得良好、干净和有效的显示。 为了做到这一点,我首先使用了michael.hor257k的数据显示解决方案和另一个人的分页解决方案。 我在提供的.xsl文件上组装了这两种方法;但是没用!Javascript XSLT paged显示一些计算出的节点值以及在下一行(II)中检索到的前一行值,javascript,xml,xslt,Javascript,Xml,Xslt,使用上一个链接的另一个请求再次签回,如以下stackoverflow链接所示: 我不会重复整个问题的细节,因为它们可以检查出来 通过上述链接。 第二个新请求也基于提供的upkeep share bills list.xml文件,需要显示相同的数据,但需要分页(分页)。 假设我在该.xml文件中有几十行,自然应该对其进行分页,以获得良好、干净和有效的显示。 为了做到这一点,我首先使用了michael.hor257k的数据显示解决方案和另一个人的分页解决方案。 我在提供的.xsl文件上组装了这两种
单独而言,他们工作顺利,但把整个过程放在一起失败了。。。 接下来,我将向您提供我的.xml文件和相关的.xsl文件以及一些小的.js文件(这有助于正确分页),我请求你们支持我,因为我无法找到解决方案。 我知道这有点复杂。。。但是这就是我需要展示的东西 再次非常感谢你。。。很抱歉我自己无法解决问题 1。xml文件
<?xml version="1.0" encoding="utf-8"?>
<upkeepList>
<upkShare month_year="11_16-12_16" post_dte="01-20-17" due="02-04-17">
<OpngBlnce>22</OpngBlnce>
<mnthCrrntAmnt>77</mnthCrrntAmnt>
<Rcpt dte="01-26-17" No="5725">
<amnt>22</amnt>
<descrpt>"11/16" upkeep </descrpt>
</Rcpt>
<Rcpt dte="01-26-17" No="5726">
<amnt>41</amnt>
<descrpt>"12/16" upkeep </descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="01_17-02_17" post_dte="03-17-17" due="04-03-17">
<OpngBlnce/>
<mnthCrrntAmnt>74</mnthCrrntAmnt>
<Rcpt dte="03-30-17" No="5783">
<amnt>50</amnt>
<descrpt>"01/17-02/17" upkeep</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="03-17" post_dte="04-16-17" due="05-02-17">
<OpngBlnce/>
<mnthCrrntAmnt>55</mnthCrrntAmnt>
<Rcpt dte="05-10-17" No="5815">
<amnt>40</amnt>
<descrpt>"03/17-04/17" upkeep 1</descrpt>
</Rcpt>
<Rcpt dte="05-15-17" No="5825">
<amnt>9</amnt>
<descrpt>"03/17-04/17" upkeep 2</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="04_17-05_17" post_dte="06-05-17" due="06-30-17">
<OpngBlnce/>
<mnthCrrntAmnt>64</mnthCrrntAmnt>
<Rcpt dte="06-14-17" No="5858">
<amnt>37</amnt>
<descrpt>"05/17" upkeep 1</descrpt>
</Rcpt>
<Rcpt dte="06-18-17" No="5863">
<amnt>21</amnt>
<descrpt>"05/17" upkeep 2</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="06_17" post_dte="07-16-17" due="07-30-17">
<OpngBlnce/>
<mnthCrrntAmnt>45</mnthCrrntAmnt>
<Rcpt dte="07-28-17" No="5948">
<amnt>38</amnt>
<descrpt>"06/17" upkeep</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="07_17" post_dte="08-16-17" due="08-31-17">
<OpngBlnce/>
<mnthCrrntAmnt>54</mnthCrrntAmnt>
<Rcpt dte="07-28-17" No="6002">
<amnt>33</amnt>
<descrpt>"07/17" upkeep 1</descrpt>
</Rcpt>
<Rcpt dte="08-02-17" No="6017">
<amnt>12</amnt>
<descrpt>"07/17" upkeep 2</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="08_17" post_dte="09-19-17" due="09-31-17">
<OpngBlnce></OpngBlnce>
<mnthCrrntAmnt>41</mnthCrrntAmnt>
<Rcpt dte="09-29-17" No="6026">
<amnt>41</amnt>
<descrpt>"08/17" upkeep </descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="09_17" post_dte="10-16-17" due="10-31-17">
<OpngBlnce/>
<mnthCrrntAmnt>34</mnthCrrntAmnt>
<Rcpt dte="10-26-17" No="6050" >
<amnt>34</amnt>
<descrpt>"09/17" upkeep </descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="10_17" post_dte="11-18-17" due="11-31-17">
<OpngBlnce></OpngBlnce>
<mnthCrrntAmnt>47</mnthCrrntAmnt>
<Rcpt dte="11-27-17" No="6052">
<amnt>10</amnt>
<descrpt>upkeep amount 1</descrpt>
</Rcpt>
<Rcpt dte="11-28-17" No="6084">
<amnt>8</amnt>
<descrpt>upkeep amount 2</descrpt>
</Rcpt>
<Rcpt dte="11-30-17" No="6104">
<amnt>27</amnt>
<descrpt>upkeep amount 3</descrpt>
</Rcpt>
</upkShare>
<upkShare month_year="11_17" post_dte="12-15-17" due="01-07-18">
<OpngBlnce></OpngBlnce>
<mnthCrrntAmnt>8</mnthCrrntAmnt>
<Rcpt dte="01-06-18" No="6135">
<amnt>17</amnt>
<descrpt>some upkeep amount</descrpt>
</Rcpt>
</upkShare>
</upkeepList>
就是这样。
再一次,你们这些家伙,帮我解决这个(相对困难的)问题!!
非常非常提前谢谢你 我不确定我是否理解了您想要创建的HTML,但是下面为您的输入生成了大约三个“页面/表格”:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">
<xsl:strip-space elements="*"/> <xsl:decimal-format name="coerce" NaN="0" />
<xsl:variable name="upkshr"> <!-- upkshr varbl -->
<xsl:for-each select="*/upkShare">
<upkp pstdte="{@post_dte}" rltedmnthyr = "{@month_year}" ob = "{format-number(OpngBlnce, '#', 'coerce')}"
mcamnt = "{format-number(mnthCrrntAmnt, '#','coerce')}" term = "{@due}" rcptsum = "{format-number(sum(Rcpt/amnt), '#','coerce')}" /> <!-- missing ob node's value forced to zero -->
</xsl:for-each>
</xsl:variable>
<xsl:variable name="upkp-set" select="exsl:node-set($upkshr)/upkp"/>
<xsl:param name="size" select="4"/>
<xsl:output method="html" version="5.0" doctype-system="about:legacy-doctype"/>
<xsl:template match="upkeepList">
<html>
<head>
<script type="text/javascript">
function onInitialize()
{
var i = 1;
document.getElementById("content"+i).style.display="" ;
}
function nextPage(num)
{
document.getElementById("content"+num).style.display="";
num--;
document.getElementById("content"+num).style.display="none";
}
function prevPage(num)
{
document.getElementById("content"+num).style.display="";
num++;
document.getElementById("content"+num).style.display="none";
}
</script>
<h3 style="margin-left:45">Upkeep share bills list</h3>
</head>
<body onload="onInitialize()">
<xsl:apply-templates select="$upkp-set[position() mod $size = 1]">
<xsl:with-param name="pages" select="ceiling(count($upkp-set) div $size)"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="upkp"> <xsl:param name="pages"/>
<xsl:variable name="page" select="position()"/>
<table border="1" id='content{$page}' width="300" height="170" style="text-align:center;margin-left:50; margin-top:22px; display:none">
<tr bgcolor="#9acd32">
<th>UpkpShare_Prd</th> <th>PostDate</th> <th>InitBalance</th>
<th>UpkpShare_Amount</th>
<th>DueDate</th> <th>FullAmnt</th> <th>FullAmntPayed</th>
<th>AmntDue</th>
</tr>
<xsl:for-each select=". | following-sibling::upkp[position()<$size]">
<tr>
<td> <xsl:value-of select="@rltedmnthyr"/> </td> <!-- relatd mnthly year -->
<td> <xsl:value-of select="@pstdte"/> </td> <!-- post date -->
<xsl:variable name="initblnc" select="sum(preceding-sibling::upkp/@ob) + sum(preceding-sibling::upkp/@mcamnt) - sum(preceding-sibling::upkp/@rcptsum) + @ob" />
<td> <xsl:value-of select="$initblnc"/> <!-- initblnc = initial balance / opening balance -->
</td>
<td> <xsl:value-of select="@mcamnt"/> </td> <!-- monthly upkeep share amount -->
<td> <xsl:value-of select="@term"/> </td> <!-- due -->
<td> <xsl:value-of select="$initblnc + @mcamnt"/> </td> <!-- full amount -->
<td> <xsl:value-of select="@rcptsum"/> </td> <!-- full amount payed -->
<td> <xsl:value-of select="$initblnc + @mcamnt - @rcptsum"/> </td> <!-- amount due / closing balance -->
</tr>
</xsl:for-each>
<tr>
<td colspan="8">
<xsl:choose>
<xsl:when test="$page = 1">
<xsl:text>pag</xsl:text> <xsl:text> </xsl:text>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
<xsl:value-of select="' '"/>
<a href="#{$page+1}" onclick="nextPage({$page+1})">></a>
</xsl:when>
<xsl:when test="$page = $pages">
<xsl:value-of select="' '"/>
<a href="#{$page - 1}" onclick="prevPage({$page - 1})"><</a>
<xsl:text> </xsl:text> <xsl:text>pag</xsl:text>
<xsl:value-of select="' '"/>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
</xsl:when>
<xsl:otherwise>
<a href="#{$page - 1}" onclick="prevPage({$page - 1})"><</a>
<xsl:text> </xsl:text> <xsl:text>pag</xsl:text>
<xsl:value-of select="' '"/>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
<xsl:value-of select="' '"/>
<a href="#{$page+1}" onclick="nextPage({$page+1})">></a>
</xsl:otherwise>
</xsl:choose>
</td> </tr>
</table>
</xsl:template>
</xsl:stylesheet>
函数onInitialize()
{
var i=1;
document.getElementById(“内容”+i).style.display=“”;
}
函数下一页(num)
{
document.getElementById(“content”+num).style.display=“”;
num--;
document.getElementById(“内容”+num).style.display=“无”;
}
函数前页(num)
{
document.getElementById(“content”+num).style.display=“”;
num++;
document.getElementById(“内容”+num).style.display=“无”;
}
维护共享账单清单
UpkpShare_珠三角后日期初始余额
UpkpShare\U金额
到期日全额付款全额付款
安度
pag
pag
pag
为了完整性,我已经内联了Javascript代码,但当然,将其保存在单独的文件中应该不会有什么区别。“但是将整个过程放在一起失败了”?这到底意味着什么,至少告诉我们确切的错误消息,描述您想要的HTML输出的结果和您得到的结果。例如,
xsl:template match=“$upkshr”
不就是给您一个XSLT编译时错误吗?或者您正在使用XSLT 2或XSLT 3处理器运行XSLT 1样式表?您知道,整个迭代过程现在都发生在$upkshr变量中,在该变量中构建了片段树。我使用AltovaXMLSpy进行调试(由于altova不支持exsl=”“函数扩展,所以在altova中,我设置了XSLT2.0)。但是在我的opera浏览器中,我不得不使用XSLT1.0,因为当前的浏览器不支持XSLT1.0以外的xslt!因此,在altova xml spy中,遇到了以下错误:1.xsl:template match=“$cteintr 2.xsl:for each select=“self::$cteintr |以下同级::$cteintr[position()$size]"... 但似乎我提出的整个逻辑都是错误的…酷。。我现在需要走一点,但我很快就会回来,我会把结果告诉你。非常感谢您的快速回复。一会儿就回来……是的!!成功了!!真的非常感谢你!所有在这里登记的人。太谢谢你了!这对我帮助很大!你们(Honnen和michael.hor257k)是最好的!!继续
function onInitialize()
{
var i = 1;
document.getElementById("content"+i).style.display="" ;
}
function nextPage(num)
{
document.getElementById("content"+num).style.display="";
num--;
document.getElementById("content"+num).style.display="none";
}
function prevPage(num)
{
document.getElementById("content"+num).style.display="";
num++;
document.getElementById("content"+num).style.display="none";
}
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">
<xsl:strip-space elements="*"/> <xsl:decimal-format name="coerce" NaN="0" />
<xsl:variable name="upkshr"> <!-- upkshr varbl -->
<xsl:for-each select="*/upkShare">
<upkp pstdte="{@post_dte}" rltedmnthyr = "{@month_year}" ob = "{format-number(OpngBlnce, '#', 'coerce')}"
mcamnt = "{format-number(mnthCrrntAmnt, '#','coerce')}" term = "{@due}" rcptsum = "{format-number(sum(Rcpt/amnt), '#','coerce')}" /> <!-- missing ob node's value forced to zero -->
</xsl:for-each>
</xsl:variable>
<xsl:variable name="upkp-set" select="exsl:node-set($upkshr)/upkp"/>
<xsl:param name="size" select="4"/>
<xsl:output method="html" version="5.0" doctype-system="about:legacy-doctype"/>
<xsl:template match="upkeepList">
<html>
<head>
<script type="text/javascript">
function onInitialize()
{
var i = 1;
document.getElementById("content"+i).style.display="" ;
}
function nextPage(num)
{
document.getElementById("content"+num).style.display="";
num--;
document.getElementById("content"+num).style.display="none";
}
function prevPage(num)
{
document.getElementById("content"+num).style.display="";
num++;
document.getElementById("content"+num).style.display="none";
}
</script>
<h3 style="margin-left:45">Upkeep share bills list</h3>
</head>
<body onload="onInitialize()">
<xsl:apply-templates select="$upkp-set[position() mod $size = 1]">
<xsl:with-param name="pages" select="ceiling(count($upkp-set) div $size)"/>
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="upkp"> <xsl:param name="pages"/>
<xsl:variable name="page" select="position()"/>
<table border="1" id='content{$page}' width="300" height="170" style="text-align:center;margin-left:50; margin-top:22px; display:none">
<tr bgcolor="#9acd32">
<th>UpkpShare_Prd</th> <th>PostDate</th> <th>InitBalance</th>
<th>UpkpShare_Amount</th>
<th>DueDate</th> <th>FullAmnt</th> <th>FullAmntPayed</th>
<th>AmntDue</th>
</tr>
<xsl:for-each select=". | following-sibling::upkp[position()<$size]">
<tr>
<td> <xsl:value-of select="@rltedmnthyr"/> </td> <!-- relatd mnthly year -->
<td> <xsl:value-of select="@pstdte"/> </td> <!-- post date -->
<xsl:variable name="initblnc" select="sum(preceding-sibling::upkp/@ob) + sum(preceding-sibling::upkp/@mcamnt) - sum(preceding-sibling::upkp/@rcptsum) + @ob" />
<td> <xsl:value-of select="$initblnc"/> <!-- initblnc = initial balance / opening balance -->
</td>
<td> <xsl:value-of select="@mcamnt"/> </td> <!-- monthly upkeep share amount -->
<td> <xsl:value-of select="@term"/> </td> <!-- due -->
<td> <xsl:value-of select="$initblnc + @mcamnt"/> </td> <!-- full amount -->
<td> <xsl:value-of select="@rcptsum"/> </td> <!-- full amount payed -->
<td> <xsl:value-of select="$initblnc + @mcamnt - @rcptsum"/> </td> <!-- amount due / closing balance -->
</tr>
</xsl:for-each>
<tr>
<td colspan="8">
<xsl:choose>
<xsl:when test="$page = 1">
<xsl:text>pag</xsl:text> <xsl:text> </xsl:text>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
<xsl:value-of select="' '"/>
<a href="#{$page+1}" onclick="nextPage({$page+1})">></a>
</xsl:when>
<xsl:when test="$page = $pages">
<xsl:value-of select="' '"/>
<a href="#{$page - 1}" onclick="prevPage({$page - 1})"><</a>
<xsl:text> </xsl:text> <xsl:text>pag</xsl:text>
<xsl:value-of select="' '"/>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
</xsl:when>
<xsl:otherwise>
<a href="#{$page - 1}" onclick="prevPage({$page - 1})"><</a>
<xsl:text> </xsl:text> <xsl:text>pag</xsl:text>
<xsl:value-of select="' '"/>
<xsl:value-of select="$page"/>
<xsl:value-of select="'/'"/>
<xsl:value-of select="$pages"/>
<xsl:value-of select="' '"/>
<a href="#{$page+1}" onclick="nextPage({$page+1})">></a>
</xsl:otherwise>
</xsl:choose>
</td> </tr>
</table>
</xsl:template>
</xsl:stylesheet>