XSLT関数——function-available()

14902 ワード

function-available(string)関数は、XSLTプロセッサによって解析できるかどうかをテストするために使用されます.パラメータstringは、テストする関数名を指定します.
構文:function-available(string)
パラメータ:string文字列、必須
戻り値:ブール
例:
xml:
<?xml version="1.0" encoding="UTF-8"?>
<books>
   <book id="1">
        <name>XSLT</name>   
   </book>
</books>


.src_container{background-color:#e7e5dc; width:99%; overflow:hidden; margin:12px 0 12px 0 !important; padding:0px 3px 3px 0px}
.src_container .titlebar{ background-color:#d4dfff; border:1px solid #4f81bd; border-bottom:0; padding:3px 24px; margin:0; width:auto; line-height:120%; overflow:hidden; text-align:left; font-size:12px}
.src_container .toolbar{ display:inline; font-weight:normal; font-size:100%; float:right; cursor:hand; color:#00f; text-align:left; overflow:hidden}
.toolbar span.button{ display:inline; font-weight:normal; font-size:100%; cursor:hand; color:#00f; text-align:left; overflow:hidden; cursor:pointer;}
.src_container div.clientarea{ background-color:white; border:1px solid #4f81bd; margin:0; width:auto !important; width:100%; height:auto; overflow:auto; text-align:left; font-size:12px; font-family: "Courier New","Consolas","Fixedsys",courier,monospace,serif}
.src_container ol.mainarea{ padding:0 0 0 52px; margin:0; background-color:#f7f7ff !important}
.number_show{ padding-left:52px !important; list-style:decimal outside !important}
.number_show li{ list-style:decimal outside !important; border-left:1px dotted #4f81bd}
.number_hide{ padding-left:0px !important; list-style-type:none !important}
.number_hide li{ list-style-type:none !important; border-left:0px}
ol.mainarea li{ display:list-item !important; font-size:12px !important; margin:0 !important; line-height:18px !important; padding:0 0 0 0px !important; background-color:#f7f7ff !important; color:#4f81bd}
ol.mainarea li pre{color:black; line-height:18px; padding:0 0 0 12px !important; margin:0em; background-color:#fff !important}
.linewrap ol.mainarea li pre{white-space:pre-wrap; white-space:-moz-pre-wrapwhite-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word}
ol.mainarea li pre.alt{ background-color:#f7f7ff !important}

function CopyCode(key){var codeElement=null;var trElements=document.all.tags("ol");var i;for(i=0;i<trelements.length;++i){if(key.parentelement.parentelement.parentelement==trelements[i].parentelement.parentelement){codeelement=trelements[i];break}}if(codeelement!=null){var content="codeElement.innerText;if(window.clipboardData==null){window.alert("ブラウザではスクリプトのコピーはサポートされていません.手動でコピーしてみてください.")}else{window.clipboardData.setData("Text", content);window.alert("ソースコードがクリップボードにコピーされている.")}}}function"LineNumbberVisible(key){var codeelement="null;var"trelements="document.all.tags("ol");var"i;for(i="0;i<trElements.length;++i){if(key.parentement.parparparente.parparparparparparente.parparparparpart.")"""""")}else}}else{else{window.else{wientElement.parentElement=trElements[i].parentElement.parentElement){codeElement=trElements[i];break}}if(codeElement!=null)(codeElement.classname="mainarea"number_hide"){codeElement.classname="mainarea number_show";key.innertext="非表示行番号"}else{codeElement.classname="mainarea number_hide";key.innertext="表示行番号"}}function ChangeIcon(key,isHover){if(isHover)key.style.style.color='d';else key.styly.styly.style.e.color='blue'}function CopyCode_CheckKey(key){if(window.event.keycode="=13)CopyCode(key)}function「AboutMe(){window.alert(」このコードボックスは、CodePaste for Windows Live Writerによって生成されます.r
r
Author:範伝根r
Email:[email protected]\r
Website: http://chuangen.name\r
Blog: http://blog.csdn.net/chuangen");}
xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">     <xsl:output method="html" version="1.0" encoding="gb2312" indent="yes"/>    
    <xsl:template match="/books">
       <xsl:choose>
            <xsl:when test="function-available('current')">
               <xsl:copy-of select="."/>
            </xsl:when>
            <xsl:otherwise>
               <xsl:text>current </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>


.src_container{background-color:#e7e5dc; width:99%; overflow:hidden; margin:12px 0 12px 0 !important; padding:0px 3px 3px 0px}
.src_container .titlebar{ background-color:#d4dfff; border:1px solid #4f81bd; border-bottom:0; padding:3px 24px; margin:0; width:auto; line-height:120%; overflow:hidden; text-align:left; font-size:12px}
.src_container .toolbar{ display:inline; font-weight:normal; font-size:100%; float:right; cursor:hand; color:#00f; text-align:left; overflow:hidden}
.toolbar span.button{ display:inline; font-weight:normal; font-size:100%; cursor:hand; color:#00f; text-align:left; overflow:hidden; cursor:pointer;}
.src_container div.clientarea{ background-color:white; border:1px solid #4f81bd; margin:0; width:auto !important; width:100%; height:auto; overflow:auto; text-align:left; font-size:12px; font-family: "Courier New","Consolas","Fixedsys",courier,monospace,serif}
.src_container ol.mainarea{ padding:0 0 0 52px; margin:0; background-color:#f7f7ff !important}
.number_show{ padding-left:52px !important; list-style:decimal outside !important}
.number_show li{ list-style:decimal outside !important; border-left:1px dotted #4f81bd}
.number_hide{ padding-left:0px !important; list-style-type:none !important}
.number_hide li{ list-style-type:none !important; border-left:0px}
ol.mainarea li{ display:list-item !important; font-size:12px !important; margin:0 !important; line-height:18px !important; padding:0 0 0 0px !important; background-color:#f7f7ff !important; color:#4f81bd}
ol.mainarea li pre{color:black; line-height:18px; padding:0 0 0 12px !important; margin:0em; background-color:#fff !important}
.linewrap ol.mainarea li pre{white-space:pre-wrap; white-space:-moz-pre-wrapwhite-space:-pre-wrap; white-space:-o-pre-wrap; word-wrap:break-word}
ol.mainarea li pre.alt{ background-color:#f7f7ff !important}

function CopyCode(key){var codeElement=null;var trElements=document.all.tags("ol");var i;for(i=0;i<trElements.length;++i){if(key.parentElement.parentElement.parentElement==trElements[i].parentElement.parentElement){codeElement=trElements[i];break}}if(codeElement!=null){var content=codeElement.innerText;if(window.clipboardData==null){window.alert(「ブラウザではスクリプトのコピーはサポートされていません.手動でコピーしてみてください」).Else{window.clipboardData.setData("Text",content);window.alert("ソースコードはクリップボードにコピーされました")}}}}function LineNumberVisible(key){var codeElement=null;var trElements=document.all.tags("ol");var i;for(i=0;i<trElements.length;++i){if(key.parentElement.parentElement.parentElement==trElements[i].parentElement.parentElement){codeElement=trElements[i];break}}if(codeElement!=null){if(codeElement.className=="mainarea number_hide"){codeElement.className="mainarea number_show";key.innerText="行番号を隠す"}else{codeElement.className="mainarea number_hide";key.innerText="行番号を表示"}}function ChangeIcon(key,isHover){if(isHover)key.style.color='red';else key.style.color='blue'}function CopyCode_CheckKey(key){if(window.event.keyCode==13)CopyCode(key)}function AboutMe(){window.alert("このコードボックスはCodePaste for Windows Live Writerによって生成されます.r
r
Author:範伝根r
Email:[email protected]\r
Website: http://chuangen.name\r
Blog: http://blog.csdn.net/chuangen");}
結果:
XSLT