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

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → [讨论][求助]想用xslt转换香xml中把十六进制RGB转换为十进制该如何做? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 17291 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [讨论][求助]想用xslt转换香xml中把十六进制RGB转换为十进制该如何做? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客楼主
    发贴心情 [讨论][求助]想用xslt转换香xml中把十六进制RGB转换为十进制该如何做?

    源xml中
    <color val="FF0000"/>
    通过xslt转为
    <color>RGB(255,0,0)</color>

    想知道有什么办法可以做到,想不出,谢谢


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/24 11:42:00
     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客2
    发贴心情 
    自己顶一下
    在xsl中写一个进制转换的函数?xsl:function?
    用模版应该不行吧,糊涂中...
    有办法吗?谢拉
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/24 14:05:00
     
     Qr 帅哥哟,离线,有人找我吗?
      
      
      威望:9
      等级:博士二年级(版主)
      文章:4392
      积分:29981
      门派:XML.ORG.CN
      注册:2004/5/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Qr发送一个短消息 把Qr加入好友 查看Qr的个人资料 搜索Qr在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Qr的主页 引用回复这个贴子 回复这个贴子 查看Qr的博客3
    发贴心情 
    似乎没有函数直接转换,手工写XSL代码进行计算吧

    假设有一个十六进数 2AF5, 那么如何换算成10进制呢?
    用竖式计算:
    2AF5换算成10进制:

    第0位:  5 * 160 = 5

    第1位:  F * 161 = 240

    第2位:  A * 162 = 2560

    第3位:  2 * 163 = 8192  +

    -------------------------------------

                     10997  

    直接计算就是:

    5 * 160  + F * 161 + A * 162 + 2 * 163 = 10997

    (别忘了,在上面的计算中,A表示10,而F表示15)

    注意:160-163的第3位数实为上标,即16的0次方-16的3次方

    ----------------------------------------------
    没人帮忙,那就靠自己,自己才是最好的老师!本人拒绝回答通过站内短消息提出的问题!

    blog:http://Qr.blogger.org.cn

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/24 14:11:00
     
     Qr 帅哥哟,离线,有人找我吗?
      
      
      威望:9
      等级:博士二年级(版主)
      文章:4392
      积分:29981
      门派:XML.ORG.CN
      注册:2004/5/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Qr发送一个短消息 把Qr加入好友 查看Qr的个人资料 搜索Qr在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Qr的主页 引用回复这个贴子 回复这个贴子 查看Qr的博客4
    发贴心情 
    <xsl:template match="/">
    <color>
        RGB(
     <xsl:value-of select="number(substring(color/@val,1,1))*16+number(substring

    (color/@val,2,1))"/>,
     <xsl:value-of select="number(substring(color/@val,3,1))*16+number(substring

    (color/@val,4,1))"/>,
     <xsl:value-of select="number(substring(color/@val,5,1))*16+number(substring

    (color/@val,6,1))"/>
     )
    </color>
    </xsl:template>
    大概就是这样子啦,但因为val可能有A-F的字母,须要转换为相应的数字(即10-15)才能运算,否则就得到NaN。转换这一步你自己来处理吧,纯粹给个思路,可不是答案哦...呵呵

    ----------------------------------------------
    没人帮忙,那就靠自己,自己才是最好的老师!本人拒绝回答通过站内短消息提出的问题!

    blog:http://Qr.blogger.org.cn

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

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客5
    发贴心情 
    多谢Qr!
    刚看到你回的帖子,我又想了一下,思路大概和你一致,今早已搞定。只是需要加入对字母(A-F)的判断,不知是不是我的方法比较笨,有没有改进的可能。颜色转换模版文件代码大致如下:
    文件名:TransColor.xsl
    <xsl:template name="transColor">
          <xsl:call-template name="redA">
              <xsl:with-param name="red1" select="substring(./@w:val,1,1)"/>
              <xsl:with-param name="red2" select="substring(./@w:val,2,1)"/>
              <xsl:with-param name="gre1" select="substring(./@w:val,3,1)"/>
              <xsl:with-param name="gre2" select="substring(./@w:val,4,1)"/>
              <xsl:with-param name="blu1" select="substring(./@w:val,5,1)"/>
              <xsl:with-param name="blu2" select="substring(./@w:val,6,1)"/>
          </xsl:call-template>
    </xsl:template>

    <xsl:template name="redA">
          <xsl:param name="red1"/>
          <xsl:param name="red2"/>
          <xsl:param name="gre1"/>
          <xsl:param name="gre2"/>
          <xsl:param name="blu1"/>
          <xsl:param name="blu2"/>
          
          <xsl:choose>
              <xsl:when test="$red1='A'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="10*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:when test="$red1='B'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="11*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:when test="$red1='C'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="12*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:when test="$red1='D'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="13*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:when test="$red1='E'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="14*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:when test="$red1='F'">
                  <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="15*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                    <xsl:call-template name="redB">
                      <xsl:with-param name="R1" select="number($red1)*16"/>
                      <xsl:with-param name="red2" select="$red2"/>
                      <xsl:with-param name="gre1" select="$gre1"/>
                      <xsl:with-param name="gre2" select="$gre2"/>
                      <xsl:with-param name="blu1" select="$blu1"/>
                      <xsl:with-param name="blu2" select="$blu2"/>
                  </xsl:call-template>
              </xsl:otherwise>
          </xsl:choose>
    </xsl:template>

    <xsl:template name="redB">
          <xsl:param name="R1"/>
          <xsl:param name="red2"/>
          <xsl:param name="gre1"/>
          <xsl:param name="gre2"/>
          <xsl:param name="blu1"/>
          <xsl:param name="blu2"/>
              
              <xsl:choose>
         <xsl:when test="$red2='A'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+10"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:when test="$red2='B'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+11"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:when test="$red2='C'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+12"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:when test="$red2='D'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+13"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:when test="$red2='E'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+14"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:when test="$red2='F'">
             <xsl:call-template name="greA">
                 <xsl:with-param name="R" select="$R1+15"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
              <xsl:call-template name="greA">
                 <xsl:with-param name="R"select="$R1+number ($red2)"/>
                 <xsl:with-param name="gre1" select="$gre1"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                                              <xsl:with-param name="blu1" select="$blu1"/>
                                                              <xsl:with-param name="blu2" select="$blu2"/>
             </xsl:call-template>
         </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/25 10:09:00
     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客6
    发贴心情 
    以上是对R的判断,接上贴:对G的判断
    <xsl:template name="greA">
          <xsl:param name="R"/>
          <xsl:param name="gre1"/>
          <xsl:param name="gre2"/>
          <xsl:param name="blu1"/>
          <xsl:param name="blu2"/>
          
          <xsl:choose>
           <xsl:when test="$gre1='A'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="10*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre1='B'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="11*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre1='C'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="12*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre1='D'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="13*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre1='E'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="14*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre1='F'">
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="15*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
              <xsl:call-template name="greB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G1" select="number($gre1)*16"/>
                 <xsl:with-param name="gre2" select="$gre2"/>
                                      <xsl:with-param name="blu1" select="$blu1"/>
                                      <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    <xsl:template name="greB">
          <xsl:param name="R"/>
          <xsl:param name="G1"/>
          <xsl:param name="gre2"/>
          <xsl:param name="blu1"/>
          <xsl:param name="blu2"/>
          
          <xsl:choose>
           <xsl:when test="$gre2='A'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+10"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre2='B'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+11"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre2='C'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+12"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre2='D'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+13"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre2='E'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+14"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                </xsl:call-template>
           </xsl:when>
           <xsl:when test="$gre2='F'">
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+15"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                   </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
              <xsl:call-template name="bluA">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G1+number($gre2)"/>
                  <xsl:with-param name="blu1" select="$blu1"/>
                                       <xsl:with-param name="blu2" select="$blu2"/>
                                   </xsl:call-template>
           </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/25 10:11:00
     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客7
    发贴心情 
    再接帖:对B的判断
    <xsl:template name="bluA">
          <xsl:param name="R"/>
          <xsl:param name="G"/>
          <xsl:param name="blu1"/>
          <xsl:param name="blu2"/>
          
          <xsl:choose>
           <xsl:when test="$blu1='A'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="10*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu1='B'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="11*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu1='C'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="12*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu1='D'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="13*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu1='E'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="14*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu1='F'">
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="15*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
              <xsl:call-template name="bluB">
                 <xsl:with-param name="R" select="$R"/>
                 <xsl:with-param name="G" select="$G"/>
                 <xsl:with-param name="B1" select="number($blu1)*16"/>
                 <xsl:with-param name="blu2" select="$blu2"/>
              </xsl:call-template>
           </xsl:otherwise>
       </xsl:choose>
          
    </xsl:template>

    <xsl:template name="bluB">
          <xsl:param name="R"/>
          <xsl:param name="G"/>
          <xsl:param name="B1"/>
          <xsl:param name="blu2"/>
          
          <xsl:choose>
           <xsl:when test="$blu2='A'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+10"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu2='B'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+11"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu2='C'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+12"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu2='D'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+13"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu2='E'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+14"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:when test="$blu2='F'">
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+15"/>
              </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
              <xsl:call-template name="RGB">
                  <xsl:with-param name="R" select="$R"/>
                  <xsl:with-param name="G" select="$G"/>
                  <xsl:with-param name="B" select="$B1+number($blu2)"/>
              </xsl:call-template>
           </xsl:otherwise>
       </xsl:choose>
    </xsl:template>

    <xsl:template name="RGB">
           <xsl:param name="R"/>
           <xsl:param name="G"/>
           <xsl:param name="B"/>
           
           <color>
              <xsl:attribute name="value">
                  <xsl:text>RGB(</xsl:text><xsl:value-of select="$R"/><xsl:text>,</xsl:text><xsl:value-of select="$G"/><xsl:text>,</xsl:text><xsl:value-of select="$G"/><xsl:text>)</xsl:text>
              </xsl:attribute>
           </color>
    </xsl:template>
    </xsl:stylesheet>

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/25 10:13:00
     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客8
    发贴心情 
    对以上代码的解释;
    因为RGB十六进制表示为:aabbcc,其中aa-R,bb-G,cc-B;
    我把aabbcc中的每一个字符取出来为:red1,red2,gre1,gre2,blu1,blu2
    然后调用模版redA,redB,greA,greB,bluA,bluB,对每个字符判断,并计算,最后输出RGB( , , ,)的形式
    虽然能用,但是比较繁琐,不知有更好的办法没,谢谢
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/25 10:18:00
     
     Qr 帅哥哟,离线,有人找我吗?
      
      
      威望:9
      等级:博士二年级(版主)
      文章:4392
      积分:29981
      门派:XML.ORG.CN
      注册:2004/5/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Qr发送一个短消息 把Qr加入好友 查看Qr的个人资料 搜索Qr在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Qr的主页 引用回复这个贴子 回复这个贴子 查看Qr的博客9
    发贴心情 
    晕,用命名模板去递归,你可真有耐心去调试。
    <xsl:template match="//color">
    <xsl:variable name="n1" select="number(substring(@val,1,1))"/>
    <xsl:variable name="n2" select="number(substring(@val,2,1))"/>
    <xsl:variable name="n3" select="number(substring(@val,3,1))"/>
    <xsl:variable name="n4" select="number(substring(@val,4,1))"/>
    <xsl:variable name="n5" select="number(substring(@val,5,1))"/>
    <xsl:variable name="n6" select="number(substring(@val,6,1))"/>
    <color>
        RGB(
     <xsl:value-of select="$n1*16+$n2"/>,
     <xsl:value-of select="$n3*16+$n4"/>,
     <xsl:value-of select="$n5*16+$n6"/>
     )
    </color>
    </xsl:template>
    这样不就搞掂了吗?
    只须在xsl:variable用<xsl:when>进行判断和处理A-F就可以了。

    ----------------------------------------------
    没人帮忙,那就靠自己,自己才是最好的老师!本人拒绝回答通过站内短消息提出的问题!

    blog:http://Qr.blogger.org.cn

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/27 12:28:00
     
     lylyjiejie 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:30
      积分:192
      门派:XML.ORG.CN
      注册:2008/4/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给lylyjiejie发送一个短消息 把lylyjiejie加入好友 查看lylyjiejie的个人资料 搜索lylyjiejie在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看lylyjiejie的博客10
    发贴心情 
    不好意思,请问在varible处怎么用choose判断,每个字符都是A-F,变量又不能重新赋值,这样该如何判断?能否给个例子,谢谢
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/28 16:29: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/5/13 15:51:37

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

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