新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → 一个XSL的问题, 谢谢各位了 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 1876 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 一个XSL的问题, 谢谢各位了 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     thomascheung 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:62
      门派:XML.ORG.CN
      注册:2006/4/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给thomascheung发送一个短消息 把thomascheung加入好友 查看thomascheung的个人资料 搜索thomascheung在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看thomascheung的博客楼主
    发贴心情 一个XSL的问题, 谢谢各位了

    这是XML:

    <?xml version="1.0" encoding="ISO-8859-1"?>


     <records name="offerlist">
      <record>
       <country>HK</country>
       <name>hk offer1</name>
      </record>
      <record>
       <country>HK</country>
       <name>hk offer2</name>
      </record>
      <record>
       <country>HK</country>
       <name>hk offer3</name>
      </record>
      <record>
       <country>HK</country>
       <name>hk offer4</name>
      </record>
      <record>
       <country>SG</country>
       <name>sg offer1</name>
      </record>
      <record>
       <country>SG</country>
       <name>sg offer2</name>
      </record>
      <record>
       <country>SG</country>
       <name>sg offer3</name>
      </record>
      <record>
       <country>TW</country>
       <name>tw offer1</name>
      </record>
      <record>
       <country>TW</country>
       <name>tw offer2</name>
      </record>
      <record>
       <country>TW</country>
       <name>tw offer3</name>
      </record>
     </records>
     
     <records name="countrylist">
      <record>
       <country>HK</country>
       <name>Hong Kong</name>
      </record>
      <record>
       <country>CN</country>
       <name>China</name>
      </record>
      <record>
       <country>SG</country>
       <name>Singapor</name>
      </record>
     </records>

    这是XSL:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
      <html>
      <body>
        <h2>Country Offer</h2>
        <table border="1">
          <xsl:for-each select="records[@name='offerlist']/record">
           <xsl:call-template name="displayCountry" />      
           <xsl:call-template name="displayName" />      
          </xsl:for-each>
      </table>
      </body>
      </html>
    </xsl:template>


    <xsl:template name="displayCountry">    
     <xsl:variable name="currentCountry">
          <xsl:value-of select="country"/>
     </xsl:variable>           
     <xsl:variable name="prevpos" select="position()-1"/>
     <xsl:variable name="previousCountry">    
         <xsl:choose>
             <xsl:when test="$prevpos &gt; 0">
                  <xsl:value-of select="../record[$prevpos]/country"/>              
             </xsl:when>
      <xsl:otherwise>
         <xsl:value-of select="''"/>
      </xsl:otherwise>
         </xsl:choose>             
     </xsl:variable>            
     <xsl:if test="$currentCountry != $previousCountry"> 
      <tr><td><b>Country: <xsl:value-of select="$currentCountry"/></b></td></tr>
     </xsl:if>
    </xsl:template>

    <xsl:template name="displayName">   
     <xsl:for-each select="name">
          <tr><td><xsl:value-of select="."/></td></tr>
         </xsl:for-each>
    </xsl:template>

    </xsl:stylesheet>

    我想在XSL原有的基础上做些改动, 使得"offerlist"里面的"country"可以跟"countrylist"里面的"country"做比较, 然后把"countrylist"里面的"country"显示出来


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/4/28 11:30:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/9/22 6:43:47

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    62.500ms