2012-05-24 25 views
2

我不知道xsl:variable中的「step」。如果有人能解釋「步驟」,我將不勝感激。xsl:variable中<step>的含義是什麼?

下面的XSLT只是包括在根元件2層的元件。

xsl:output定義輸出格式; xsl:variable定義變量;

如何這段代碼解析?這個代碼代表什麼?

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:saxon="http://saxon.sf.net/" 
    version="2.0" 
    extension-element-prefixes="saxon"> 

    <xsl:output method="html" omit-xml-declaration="yes" 
    encoding="utf-8" indent="no"/> 

    <!-- <xsl:output method="xml" omit-xml-declaration="no" 
    encoding="utf-8" indent="no"/> --> 

    <xsl:variable name="processes"> 
    <!-- exclude elements with @specific-use='print-only' --> 
    <step>prep/jpub3-webfilter.xsl</step> 
    <!-- format citations in NLM/PMC format --> 
    <step>citations-prep/jpub3-PMCcit.xsl</step> 
    <!-- convert into HTML for display --> 
    <step>main/jpub3-html.xsl</step> 
    </xsl:variable> 

    <xsl:include href="main/shell-utility.xsl"/> 

</xsl:stylesheet> 

補編「殼utility.xsl」

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:saxon="http://saxon.sf.net/" 
    version="2.0" 
    extension-element-prefixes="saxon"> 

    <!-- This stylesheet does not stand alone! It is a component 
     to be called into XSLT 2.0 shell stylesheets. --> 

    <xsl:variable name="document" select="/" saxon:assignable="yes"/> 

    <xsl:param name="runtime-params"> 
    <base-dir> 
     <xsl:value-of 
     select="replace(base-uri(/), '/[^/]+$','')"/>  
    </base-dir> 
    </xsl:param> 

    <xsl:template match="/"> 
    <xsl:for-each select="$processes/step/concat('../',.)"> 
     <xsl:message> 
     <xsl:text>&#xA;... Applying </xsl:text> 
     <xsl:value-of select="."/> 
     </xsl:message> 
     <saxon:assign name="document" 
     select="saxon:transform(
        saxon:compile-stylesheet(doc(.)), 
        $document, 
        $runtime-params/*)"/> 
     <!-- A third argument to saxon:transform could specify 
      runtime parameters for any (or all) steps --> 
    </xsl:for-each> 
    <xsl:sequence select="$document"/> 
    <xsl:message>&#xA;... Done</xsl:message> 
    </xsl:template> 

</xsl:stylesheet> 

回答

3

的代碼只是創建一個名爲processes變量並分配它含有三個<step>元素的節點列表。就XSL解析器而言,<step>元素本身沒有任何意義。

+1

在XSLT2變量是非常普遍的,可以包含XML節點列表/樹片段。 –

1

請問這個代碼代表什麼?

<xsl:variable name="processes">  
    <!-- exclude elements with @specific-use='print-only' -->  
    <step>prep/jpub3-webfilter.xsl</step>  
    <!-- format citations in NLM/PMC format -->  
    <step>citations-prep/jpub3-PMCcit.xsl</step>  
    <!-- convert into HTML for display -->  
    <step>main/jpub3-html.xsl</step> 
</xsl:variable> 

這是名爲processesdocument-node()類型的全局變量的定義 - 它的值是一個包含有文檔節點的孩子3種step元素的臨時樹。

該變量的使用方式取決於所包含的樣式表模塊的代碼: main/shell-utility.xsl。由於未提供此代碼,因此無法說明變量的實際用法。

+0

感謝您answer.I有上傳殼utility.xsl代碼 –

+0

使用此XLST將XML由撒克遜爲HTML,在表達式$過程中的終端顯示錯誤的「錯誤/步/ CONCAT(‘../’,. ):路徑表達式中的意外標記[]「。這看起來有點不妥。 –

+0

$ processes/step/concat('../',.)'錯誤 - 'concat()'是一個函數,因此它不能用作路徑的一部分。我不確定這裏的預期結果是什麼,所以我不能說如何解決它。 – MiMo

相關問題