首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

xslt解析xml文件 哪位高手个帮忙

2012-02-05 
xslt解析xml文件 谁个帮忙projects.xmlXML code?xml version1.0??xml-stylesheet typetext/xsl h

xslt解析xml文件 谁个帮忙
projects.xml

XML code
<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="projects.xsl"?><projects>    <project>        <Name>Project 1</Name>            </project>    <project>        <Name>Project 2</Name>    </project>    <project>        <Name>Project 3</Name>    </project>        <project>        <Name>Project 4</Name>    </project>    <project>        <Name>Project 5</Name>    </project>    <project>        <Name>Project 6</Name>    </project>        <project>        <Name>Project 7</Name>    </project>        <project>        <Name>Project 8</Name>    </project>    <project>        <Name>Project 9</Name>    </project></projects>


  我现在需要对projects文件遍历,需要每4条数据一组显示在页面上,如果projects.xml文件中project不超过足8个,则以空白project补充 超过8个project只显示前8个project数据

XML code
            <div class="panel">                <xsl:for-each select="projects/project[position()&lt;5]">                 <div class="tab2" id="tab{position()}">                               <p class="tab_content_top"><xsl:value-of select="Name"/></p>                    <p class="tab_content"><xsl:number value="position()" format="1"/></p>                    <a href="http://www.865171.cn" class="read_more"><img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0" /></a> </div>                </xsl:for-each>            </div>            <div class="panel">                            <xsl:for-each select="projects/project[position() &gt; 4]">                <xsl:choose>                    <xsl:when test="position()+4 &gt; 8">                    </xsl:when>                    <xsl:otherwise>                    <div class="tab2" id="tab{position()+4}">                               <p class="tab_content_top"><xsl:value-of select="Name"/></p>                    <p class="tab_content"><xsl:number value="position()+4" format="1"/></p>                    <a href="http://www.865171.cn" class="read_more"><img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0" /></a> </div>                    </xsl:otherwise>                </xsl:choose>                    </xsl:for-each>                        </div>    

  页面是用js控制的 点击会显示下一组(4条数据)

[解决办法]
XML code
<xsl:for-each select="project[position() &gt; 0 and position() &lt; 9]">    <div><span><xsl:number value="position()" format="1"/></span><span><xsl:value-of select="Name"/></span></div>    <xsl:if test="position() div $group"><p/></xsl:if></xsl:for-each>
[解决办法]
可参考这个
http://dotnet.aspx.cc/article/00000000-0000-0000-0000-000000000004/read.aspx


[解决办法]

XML code
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">    <xsl:output method="html"/>    <xsl:template match="/">        <div class="panel">            <xsl:for-each select="projects/project[position()&lt;9]">                <div class="tab2" id="tab{position()}">                    <p class="tab_content_top">                        <xsl:value-of select="Name"/>                    </p>                    <p class="tab_content">                        <xsl:number value="position()" format="1"/>                    </p>                    <a href="http://www.865171.cn" class="read_more">                        <img src="../resource/html_template/images/read_more.gif" alt="" title="" border="0"/>                    </a>                </div>                <xsl:if test="position()=4">                    <xsl:text disable-output-escaping="yes">                     &lt;/div&gt;&lt;div class="panel"&gt;                   </xsl:text>                </xsl:if>            </xsl:for-each>            <xsl:for-each select="count(projects/project) to 7">                <div class="tab2"/>            </xsl:for-each>        </div>    </xsl:template></xsl:stylesheet> 

热点排行