新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   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的几个问题? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2403 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 初学xsl的几个问题? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     fxbird 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:6
      积分:73
      门派:XML.ORG.CN
      注册:2004/10/1

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

    且看如下的xml和xsl:
    xml:
    <Catalog>
     <Publisher isbn = "186100">
     <!--出版社名-->
      <CorporateName>Wrox Press Ltd</CorporateName>
    <!--出版社的地址,可以有多个-->
      <Address headquarters = "yes">
       <Street>Arden House</Street>
       <Street>1102 Warwick Road, Acocks Green</Street>
       <City>Birmingham</City>
       <Country>UK</Country>
       <PostalCode>B27 6BH</PostalCode>
      </Address>
      <Address headquarters = "no">
       <Street>Suite 520</Street>
       <Street>29 S. Lasalle Street</Street>
       <City>Chicago</City>
       <PoliticalDivision>IL</PoliticalDivision>
       <Country>USA</Country>
       <PostalCode>60603</PostalCode>
      </Address>
      <!--出的书的类别-->
      <Imprints>
       <Imprint shortImprintName = "XML">XML and Scripting</Imprint>
       <Imprint shortImprintName ="Linux">GNU/Linux</Imprint>
       <Imprint shortImprintName  ="Java">Java</Imprint>
       <Imprint shortImprintName ="ASP">Active Server Pages</Imprint>
      </Imprints>
      <!--签约作者-->
      <Author authorCiteID = "smohr">
       <FirstName>Stephen</FirstName>
       <LastName>Mohr</LastName>
       <Biographical>Stephen Mohr is a senior systems architect...</Biographical>
      </Author>
      <Author authorCiteID = "nozu">
       <FirstName>Nikola</FirstName>
       <LastName>Ozu</LastName>
       <Biographical>Nikola Ozu is a systems architect and consultant...</Biographical>
      </Author> 
      <Author authorCiteID = "jond">
       <FirstName>Jon</FirstName>
       <LastName>Duckett</LastName>
       <Biographical>The brains behind the Dr Evil organization, Jon is...</Biographical>
      </Author>
      <Author authorCiteID = "mbirbeck">
       <FirstName>Mark</FirstName>
       <LastName>Birbeck</LastName>
       <Biographical>Mark Birbeck has been a professional programmer for...</Biographical>
      </Author> 
      <Author authorCiteID = "mkay">
       <FirstName>Michael</FirstName>
       <LastName>Kay</LastName>
       <Biographical>Michael Kay has spent most of ...</Biographical>
      </Author> 
      <Author authorCiteID = "scottwoo">
       <FirstName>Scott</FirstName>
       <LastName>Woodgate</LastName>
       <Biographical>Scott Woodgate, a Microsoft Certified Solution Developer, ...</Biographical>
      </Author>       
     </Publisher>
     <!--书的线索-->
     <Thread threadID = "coreXML">Core XML</Thread>
     <Thread threadID ="proXML">Advanced Topics in XML</Thread>
     <Thread threadID ="msXML">Microsoft XML Products</Thread>
     <!--书-->
     <Book ISBN = "1861005059" level = "pro" pubdate = "06-01-2001" pageCount = "800" authors = "smohr mbirbeck nozu jond" threads = "coreXML proXML" imprint = "XML">
      <Title>Professional XML, 2nd Edition</Title>
      <!--概要-->
      <Abstract>An update to the wildly successful first edition, Pro XML covers the full ...</Abstract>
      <!--章节-->
      <RecSubjCategories>
       <Category>Internet</Category>
       <Category>Internet Programming</Category>
       <Category>XML</Category>
      </RecSubjCategories>
      <Price currency = "USD">49.99</Price>
     </Book>
     <Book ISBN = "1861003129" level = "pro" pubdate = "07-2000" pageCount = "780" authors = "mkay" threads = "proXML" imprint = "XML">
      <Title>XSLT Programmer's Reference</Title>
      <Abstract>The definitive guide to XSLT and XSLT programming ...</Abstract>
      <RecSubjCategories>
       <Category>Internet</Category>
       <Category>XML</Category>
       <Category>XSL</Category>
      </RecSubjCategories>
      <Price currency = "USD">34.99</Price>
     </Book>
     <Book ISBN = "1861003293" level = "pro" pubdate = "12-2000" pageCount = "700" authors = "smohr scottwoo" threads = "proXML msXML" imprint = "XML">
      <Title>Professional BizTalk</Title>
      <Abstract>The first comprehensive guide to using and programming Microsoft BizTalk Server ...</Abstract>
      <RecSubjCategories>
       <Category>XML</Category>
       <Category>E-Commerce</Category>
      </RecSubjCategories>
      <Price currency = "USD">49.99</Price>
     </Book>   
    </Catalog>
    根元素由出版社(Publisher),书的线索(Thread),书(Book)组成。
    在xsl求每本书的出版社名字的一段:
    <xsl:template match="Book">
       <xsl:apply-templates select="Title"/>
       <xsl:variable name="isbn" select="@ISBN"/>
       <xsl:element name="DIV">
          <xsl:attribute name="style">font-family:Verdana;font-size:10pt;color:black;font-weight:bolder</xsl:attribute>
          <xsl:value-of select="/Catalog/Publisher[contains($isbn,@isbn)]/CorporateName"/>//这个地方怎么有两个属性isbn,到底属于谁的,难道是模板匹配的当前属性ISBN(Book里的)优先考虑,@isbn匹配其指定的路径吗(Publisher里的)?属性名不同还好说,如果是同名的怎么办啊,如果是用到了三个这样的属性,又该如何匹配?
       </xsl:element>
       <xsl:variable name="by" select="@authors"/>
       <xsl:call-template name="fetch-authors">
          <xsl:with-param name="authors" select="/Catalog/Publisher/Author[contains($by,@authorCiteID)]"/>
       </xsl:call-template>
       .......
    另外一个问题和xpath有关:
    <xsl:apply-templates select="*[name() != 'Title']"/>
    这个模板从效果上看是匹配所有当前上下文节点的名字不为Title的子节点,可按照xpath的写法,我觉得前面应该加上child,才能表明是上子节点里去找,即:child::*[name()]!='Title',不知对不对,要不怎么知道到哪里去找呢?难道默认是到子节点里去找?我试了也可以,有点纳闷。

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/1 21:09:00
     
     AlongleeNet 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:34
      积分:194
      门派:XML.ORG.CN
      注册:2004/10/2

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给AlongleeNet发送一个短消息 把AlongleeNet加入好友 查看AlongleeNet的个人资料 搜索AlongleeNet在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看AlongleeNet的博客2
    发贴心情 
    是不是嫌我们的问题太简单了,没有人回答啊。

    ----------------------------------------------
    学习xml .net中

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/2 21:47:00
     
     fxbird 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:6
      积分:73
      门派:XML.ORG.CN
      注册:2004/10/1

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给fxbird发送一个短消息 把fxbird加入好友 查看fxbird的个人资料 搜索fxbird在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看fxbird的博客3
    发贴心情 
    我还以为有回答了
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/3 10:07:00
     
     AlongleeNet 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(高数修炼中)
      文章:34
      积分:194
      门派:XML.ORG.CN
      注册:2004/10/2

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给AlongleeNet发送一个短消息 把AlongleeNet加入好友 查看AlongleeNet的个人资料 搜索AlongleeNet在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看AlongleeNet的博客4
    发贴心情 
    不好意思
    我也是初学
    对所有有关的问题我都感兴趣,
    帮你顶

    ----------------------------------------------
    学习xml .net中

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/3 10:51:00
     
     doubleG 帅哥哟,离线,有人找我吗?
      
      
      威望:7
      等级:大三(面向对象是个好东东!)
      文章:591
      积分:4119
      门派:XML.ORG.CN
      注册:2004/5/27

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给doubleG发送一个短消息 把doubleG加入好友 查看doubleG的个人资料 搜索doubleG在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看doubleG的博客5
    发贴心情 
    <xsl:value-of select="/Catalog/Publisher[contains($isbn,@isbn)]/CorporateName"/>中的$isbn是指变量isbn-><xsl:variable name="isbn" select="@ISBN"/> @isbn是指属性。
    <xsl:template match="Book">
       <xsl:apply-templates select="Title"/>
    这里的apply-templates是指在book下面的子节点来匹配这些模版的,所以就不用child了。

    睡了几天头有些昏,回答的不好的话,请原谅。哈哈

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/10/6 9:11: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/12 16:20:53

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

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