新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国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经典例子! 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 5622 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [原创]学习XSL经典例子! 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     adouleonshaw 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:76
      门派:XML.ORG.CN
      注册:2008/3/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给adouleonshaw发送一个短消息 把adouleonshaw加入好友 查看adouleonshaw的个人资料 搜索adouleonshaw在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看adouleonshaw的博客楼主
    发贴心情 [原创]学习XSL经典例子!




    一个初学者的例子

    catalog.xml
    <xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
    <catalog>
    <cd>
      <title>Empire Burlesque</title>
      <artist>Bob Dylan</artist>
      <country>USA</country>
      <company>Columbia</company>
      <price>10.90</price>
      <year>1985</year>
       </cd>
    <cd>
      <title>Hide your heart</title>
      <artist>Bonnie Tyler</artist>
      <country>UK</country>
      <company>CBS Records</company>
      <price>9.90</price>
      <year>1988</year>
       </cd>
    <cd>
      <title>Greatest Hits</title>
      <artist>Dolly Parton</artist>
      <country>USA</country>
      <company>RCA</company>
      <price>9.90</price>
      <year>1982</year>
      </cd>
    <cd>
      <title>Still got the blues</title>
      <artist>Gary Moore</artist>
      <country>UK</country>
      <company>Virgin records</company>
      <price>10.20</price>
      <year>1990</year>
      </cd>
    <cd>
      <title>Eros</title>
      <artist>Eros Ramazzotti</artist>
      <country>EU</country>
      <company>BMG</company>
      <price>9.90</price>
      <year>1997</year>
      </cd>
    <cd>
    <title>One night only</title>
      <artist>Bee Gees</artist>
      <country>UK</country>
      <company>Polydor</company>
      <price>10.90</price>
      <year>1998</year>
      </cd>
    <cd>
      <title>Sylvias Mother</title>
      <artist>Dr.Hook</artist>
      <country>UK</country>
      <company>CBS</company>
      <price>8.10</price>
      <year>1973</year>
      </cd>
    <cd>
      <title>Maggie May</title>
      <artist>Rod Stewart</artist>
      <country>UK</country>
      <company>Pickwick</company>
      <price>8.50</price>
      <year>1990</year>
      </cd>
    <cd>
      <title>Romanza</title>
      <artist>Andrea Bocelli</artist>
      <country>EU</country>
      <company>Polydor</company>
      <price>10.80</price>
      <year>1996</year>
      </cd>
    <cd>
      <title>When a man loves a woman</title>
      <artist>Percy Sledge</artist>
      <country>USA</country>
      <company>Atlantic</company>
      <price>8.70</price>
      <year>1987</year>
      </cd>
    <cd>
      <title>Black angel</title>
      <artist>Savage Rose</artist>
      <country>EU</country>
      <company>Mega</company>
      <price>10.90</price>
      <year>1995</year>
      </cd>
    <cd>
      <title>1999 Grammy Nominees</title>
      <artist>Many</artist>
      <country>USA</country>
      <company>Grammy</company>
      <price>10.20</price>
      <year>1999</year>
      </cd>
    <cd>
      <title>For the good times</title>
      <artist>Kenny Rogers</artist>
      <country>UK</country>
      <company>Mucik Master</company>
      <price>8.70</price>
      <year>1995</year>
      </cd>
    <cd>
      <title>Big Willie style</title>
      <artist>Will Smith</artist>
      <country>USA</country>
      <company>Columbia</company>
      <price>9.90</price>
      <year>1997</year>
      </cd>
    <cd>
      <title>Tupelo Honey</title>
      <artist>Van Morrison</artist>
      <country>UK</country>
      <company>Polydor</company>
      <price>8.20</price>
      <year>1971</year>
      </cd>
    <cd>
      <title>Soulsville</title>
      <artist>Jorn Hoel</artist>
      <country>Norway</country>
      <company>WEA</company>
      <price>7.90</price>
      <year>1996</year>
      </cd>
    <cd>
      <title>The very best of</title>
      <artist>Cat Stevens</artist>
      <country>UK</country>
      <company>Island</company>
      <price>8.90</price>
      <year>1990</year>
      </cd>
    <cd>
      <title>Stop</title>
      <artist>Sam Brown</artist>
      <country>UK</country>
      <company>A and M</company>
      <price>8.90</price>
      <year>1988</year>
      </cd>
    <cd>
      <title>Bridge of Spies</title>
      <artist>T`Pau</artist>
      <country>UK</country>
      <company>Siren</company>
      <price>7.90</price>
      <year>1987</year>
      </cd>
    <cd>
      <title>Private Dancer</title>
      <artist>Tina Turner</artist>
      <country>UK</country>
      <company>Capitol</company>
      <price>8.90</price>
      <year>1983</year>
      </cd>
    - <cd>
      <title>Midt om natten</title>
      <artist>Kim Larsen</artist>
      <country>EU</country>
      <company>Medley</company>
      <price>7.80</price>
      <year>1983</year>
      </cd>
       <cd>
      <title>Pavarotti Gala Concert</title>
      <artist>Luciano Pavarotti</artist>
      <country>UK</country>
      <company>DECCA</company>
      <price>9.90</price>
      <year>1991</year>
      </cd>
    <cd>
      <title>The dock of the bay</title>
      <artist>Otis Redding</artist>
      <country>USA</country>
      <company>Atlantic</company>
      <price>7.90</price>
      <year>1987</year>
      </cd>
    <cd>
      <title>Picture book</title>
      <artist>Simply Red</artist>
      <country>EU</country>
      <company>Elektra</company>
      <price>7.20</price>
      <year>1985</year>
      </cd>
    <cd>
      <title>Red</title>
      <artist>The Communards</artist>
      <country>UK</country>
      <company>London</company>
      <price>7.80</price>
      <year>1987</year>
      </cd>
    <cd>
      <title>Unchain my heart</title>
      <artist>Joe Cocker</artist>
      <country>USA</country>
      <company>EMI</company>
      <price>8.20</price>
      <year>1987</year>
      </cd>
      </catalog>


    catalog.xsl
    <?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" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
     <xsl:template match="/">
      <html>
       <title>CDCatalog List</title>
       <body>
        <h2 align="center">My CD Collection</h2>
        <table border="0" align="center">
         <tr bgcolor="#9acd32" align="center">
          <th>Title</th>
          <th>Artist</th>
          <th>Country</th>
          <th>Company</th>
          <th>Price</th>
             <th>Year</th>
         </tr>
         <xsl:for-each select="catalog/cd">
          <xsl:sort order="descending"/>
          <xsl:if test="year>1980">
          <tr align="center">
           <td>
            <xsl:value-of select="title"/>
           </td>
           <xsl:choose>        
           <xsl:when test="price>10">        
            <td bgcolor="red">        
            <xsl:value-of select="artist"/></td>        
           </xsl:when>        
           <xsl:when test="price&lt;9">        
            <td bgcolor="green">        
            <xsl:value-of select="artist"/></td>        
           </xsl:when>        
           <xsl:otherwise>        
            <td><xsl:value-of select="artist"/></td>        
           </xsl:otherwise>        
           </xsl:choose>
           <td>
            <xsl:value-of select="country"/>
           </td>
           <xsl:choose>        
           <xsl:when test="year>1990">         
            <td bgcolor="blue">         
            <xsl:value-of select="company"/></td>        
           </xsl:when>        
           <xsl:otherwise>         
            <td><xsl:value-of select="company"/></td>        
           </xsl:otherwise>        
           </xsl:choose>
           <td>
            <xsl:value-of select="price"/>
           </td>
           <td>
            <xsl:value-of select="year"/>
           </td>
          </tr>
          </xsl:if>
         </xsl:for-each>
        </table>
       </body>
      </html>
     </xsl:template>
    </xsl:stylesheet>


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/4/24 15:34:00
     
     907941727 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:14
      积分:103
      门派:XML.ORG.CN
      注册:2008/6/24

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给907941727发送一个短消息 把907941727加入好友 查看907941727的个人资料 搜索907941727在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看907941727的博客2
    发贴心情 
    不错
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/6/24 9:14:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/10/31 23:46:13

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

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