国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

將XSLT作為HTML的樣式表的使用方法示例

2024-07-11 08:30:02
字體:
供稿:網(wǎng)友

 簡介  

當(dāng)聽到樣式表這個(gè)詞時(shí),您可能會想到 CSS 樣式表。XSLT 樣式表通常用于 XML 轉(zhuǎn)換,比如在 Web 服務(wù)之間映射數(shù)據(jù)。因?yàn)?XSLT 非常適合此用途,所以創(chuàng)建了頂層元素 <stylesheet> 的 <xsl:transform> 別名,雖然這很少使用。這種 XSLT 轉(zhuǎn)換的輸入結(jié)構(gòu)與輸出結(jié)構(gòu)有很大的不同。最重要的是,命名空間的不同。

  XSLT 樣式表的輸入結(jié)構(gòu)與輸出結(jié)構(gòu)相似,但卻更簡單些。其中已經(jīng)擴(kuò)充了一些標(biāo)記,但大部分標(biāo)記只是原樣復(fù)制到輸出。輸入和輸出的命名空間是相同的 (HTML)。輸入文檔也可以包含樣式表指令(比如創(chuàng)建腳注),這些指令屬于另一個(gè)命名空間,不會傳遞到輸出中。
常用縮略語

    CSS:級聯(lián)樣式表
    XHTML:可擴(kuò)展超文本標(biāo)記語言
    XPath:XML 路徑語言
    XSLT:可擴(kuò)展樣式表語言轉(zhuǎn)換

  在本文中,我們將學(xué)習(xí)如何使用 XSLT 樣式表擴(kuò)充 XHTML 文檔。文中的示例展示了如何使用指令,如何引用其他源文檔的部分,以及如何使用鏈接在主文檔中導(dǎo)航。此外,我們還探索了頁面的解釋和編譯之間的區(qū)別。
CSS 樣式表的局限性

  XSLT 樣式表不會阻止您使用其他技術(shù),比如 JavaScript 或 CSS。CSS 適用于字體、加粗、顏色、間距等。它不適合將來自不同位置的信息組合在一起,比如腳注、模塊或生成一個(gè)目錄。這正是 XSLT 的用武之地,它補(bǔ)充而不是替代了 CSS。
XSLT 用途示例

  實(shí)際上,您可以將 XSLT 代碼集中在一個(gè)文件中。為了簡單起見,本文中的每個(gè)示例均位于一個(gè)獨(dú)立的 XSLT 文件中,除了一些必要的代碼。清單 1 給出了必需的代碼。

  清單 1. 必需的代碼(位于 samples/common.xml 中)

 

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <s:stylesheet       <span style="width: auto; height: auto; float: none;" id="24_nwp"><a style="text-decoration: none;" mpid="24" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=d14555d819ab7000&k=xml&k0=xml&kdi0=0&luki=10&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=70ab19d85545d1&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F1117%2Ehtml&urlid=0" id="24_nwl"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">xml</span></a></span>ns="http://www.w3.org/1999/xhtml"  
  2.     xmlns:h="http://www.w3.org/1999/xhtml"       xmlns:a="http://sourceforge.net/projects/arbalo/"  
  3.     xmlns:s="http://www.w3.org/1999/XSL/Transform"       exclude-result-prefixes="a h"  
  4.     version="1.0"   >  
  5.     <s:template match="h:<span style="width: auto; height: auto; float: none;" id="25_nwp"><a style="text-decoration: none;" mpid="25" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=d14555d819ab7000&k=head&k0=head&kdi0=0&luki=9&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=70ab19d85545d1&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F1117%2Ehtml&urlid=0" id="25_nwl"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">head</span></a></span>">           <s:copy>  
  6.             <s:apply-templates select="@*|node()"/>               <meta  
  7.                 http-equiv="content-type"                   content="text/html;charset=UTF-8" />  
  8.             <link                   href="common.<span style="width: auto; height: auto; float: none;" id="26_nwp"><a style="text-decoration: none;" mpid="26" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=d14555d819ab7000&k=css&k0=css&kdi0=0&luki=8&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=70ab19d85545d1&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F1117%2Ehtml&urlid=0" id="26_nwl"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">css</span></a></span>"   
  9.                 rel="stylesheet"                   type="text/css" />  
  10.         </s:copy>       </s:template>  
  11.              <s:template match="*">  
  12.         <s:copy>               <s:copy-of select="@*"/>  
  13.             <s:apply-templates/>           </s:copy>  
  14.     </s:template>   </s:stylesheet>  
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 通山县| 普兰县| 永年县| 旬阳县| 廉江市| 桑植县| 芮城县| 五原县| 平远县| 丽水市| 洪雅县| 曲靖市| 五家渠市| 卢氏县| 胶南市| 通河县| 广水市| 吉安县| 南陵县| 商都县| 从江县| 蒙自县| 明溪县| 都兰县| 南雄市| 望城县| 施甸县| 禄劝| 井冈山市| 崇义县| 义马市| 石台县| 平阴县| 枣强县| 毕节市| 来安县| 东阿县| 本溪市| 万盛区| 罗山县| 曲麻莱县|