XSLT对XML进行数学,逻辑运算(主要是进行分页)?和DELPHIBBS的分页方法不同.YYSUN请看看.(100分)

  • 主题发起人 主题发起人 liu_xiao_bo
  • 开始时间 开始时间
L

liu_xiao_bo

Unregistered / Unconfirmed
GUEST, unregistred user!
根据start,range,count分页
XML
-----------------------------
<forum>
<page>
<start>3</start>
<range>2</range>
<count>6</count>
</page>
</forum>
XSL
----------------------
<xsl:choose>
<xsl:when test="forum/page/start&amp;#62;forum/page/range">
<xsl:value-of select="forum/page/start-forum/page/range"/>
</xsl:when>
<xsl:otherwise>
1
</xsl:otherwise>
</xsl:choose>
-----------
<xsl:choose>
<xsl:when test="(forum/page/start+forum/page/range)&amp;#60;forum/page/count">
<xsl:value-of select="forum/page/start+forum/page/range"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="forum/page/count"/>
</xsl:otherwise>
</xsl:choose>
 
大于号,小于好已经被&amp;amp;#60;,&amp;amp;#62;替换了,可还不行!!!
 
数据量小这种办法可以
 
你的xsl中有两个错误:
1.取元素值必须写成'/.'例:(forum/page/start/.)
2.取出来的值为串型,要用Number function进行转换后才能运算.
 
但是这样forum/page/start我试过也能输出值.
Number function,请帮忙改一下好吗?
 
你这样写试试,其它的需要运算的地方都用Number函数进行转换
Number(forum/page/start/.)+Number(forum/page/range/.)&amp;lt;Number(forum/page/count/.)
应该是可以的[:)]
 
这样也不行!!!
--------------
<xsl:choose>
<xsl:when test="number(forum/page/start/.)&amp;amp;#62;number(forum/page/range/.)">
<xsl:value-of select="number(forum/page/star/.)-number(forum/page/range/.)"/>
</xsl:when>
<xsl:otherwise>
1
</xsl:otherwise>
</xsl:choose>
 
我已经试过了,是行的:
<xsl:choose>
  <xsl:when test="number(forum/page/start/.)&amp;gt;number(forum/page/range/.)">
    <xsl:value-of select="forum/page/start-forum/page/range/."/>
  </xsl:when>
  <xsl:otherwise>
    1
  </xsl:otherwise>
</xsl:choose>
 
PLEASE SEE THE CODE!!!
xml
-------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="a.xsl"?>
<forum>
<page>
<start>3</start>
<range>2</range>
<count>6</count>
</page>
</forum>
-------------------------------------------------------
xsl
------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:choose>
  <xsl:when test="number(forum/page/start/.)&amp;amp#62 number(forum/page/range/.)">
    <xsl:value-of select="forum/page/start/.-forum/page/range/."/>
  </xsl:when>
  <xsl:otherwise>
    1
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
 
邮件联系好吗?我给你发xml,xsl文件!
 
xsl:
<?xml version="1.0" encoding="gb2312"?>
<!-- edited with XML Spy v4.0.1 U (http://www.xmlspy.com) by whb (vstar) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:choose>
<xsl:when test="number(forum/page/start/.)&amp;gt;number(forum/page/range/.)">
<xsl:value-of select="forum/page/start-forum/page/range"/>
</xsl:when>
<xsl:otherwise>
1
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="number(forum/page/start/.)+number(forum/page/range/.)&amp;lt;number(forum/page/count/.)">
<xsl:value-of select="forum/page/start+forum/page/range"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="forum/page/count"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
xml:
<?xml version="1.0" encoding="gb2312"?>
<!-- edited with XML Spy v4.0.1 U (http://www.xmlspy.com) by whb (vstar) -->
<?xml-stylesheet type="text/xsl" href="E:/myPape/test.xsl"?>
<forum>
<page>
<start>1</start>
<range>2</range>
<count>10</count>
</page>
</forum>
 
真不想麻烦你!我的邮件liu_xiao_bo@hotmail.com。
给我发信吧,我把完整的代码发给你,帮我改改,谢谢!
 
后退
顶部