2014-11-24 70 views
1

我必須將具有子節點的一些完整節點從XML文件插入到第二個XSLT樣式表中,我想使用第一個節點創建這些節點的所有屬性。將XSLT插入到第二個樣式表中的XML節點

這是XML的例子:

<?xml version="1.0" encoding="UTF-8"?> 
<data xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
     xmlns:fo="http://www.w3.org/1999/XSL/Format" 
     xmlns:xslout="it's replaced to xmlns:xsl within the transformation"> 

    <text-german> 

     <fo:block font-weight="bold" space-after.optimum="10mm"> 
      Ihr Coupon 
     </fo:block> 
     <fo:block space-after.optimum="10mm"> 
      <xsl:text>Guten Tag </xsl:text> 
      <xslout:value-of select="givenname"/> 
      <xslout:text> </xslout:text> 
      <xslout:value-of select="surname" /> 
      <xslout:text>,</xslout:text> 
     </fo:block> 
     <fo:block space-after.optimum="5mm"> 
      <xslout:text>Some text...</xslout:text> 
      <xslout:value-of select="issuerLong" /> 
      <xslout:text>Here more text...</xslout:text> 
     </fo:block> 
     <fo:block> 
      <fo:inline font-style="italic"> 
       <xslout:text>Coupon: </xslout:text> 
      </fo:inline> 
      <fo:inline font-weight="bold"> 
       <xslout:value-of select="code" /> 
      </fo:inline> 
     </fo:block> 
    </text-german> 

</data> 

我要插入的節點<text-german>的所有內容到輸出。之前,我試圖用命令<xsl:value of select="text-german"/>來做到這一點,但這隻會影響此特定節點的內容,而不會影響具有其內容和屬性的繼承子節點。

如何在輸出文件中插入節點的所有內容?

爲了更好地理解在這裏,我想在我的文本輸出:

<fo:block font-weight="bold" space-after.optimum="10mm"> 
    Ihr Coupon 
</fo:block> 
<fo:block space-after.optimum="10mm"> 
    <xsl:text>Guten Tag </xsl:text> 
    <xslout:value-of select="givenname"/> 
    <xslout:text> </xslout:text> 
    <xslout:value-of select="surname" /> 
    <xslout:text>,</xslout:text> 
</fo:block> 
<fo:block space-after.optimum="5mm"> 
    <xslout:text>Some text...</xslout:text> 
    <xslout:value-of select="issuerLong" /> 
    <xslout:text>Here more text...</xslout:text> 
</fo:block> 
<fo:block> 
    <fo:inline font-style="italic"> 
     <xslout:text>Coupon: </xslout:text> 
    </fo:inline> 
    <fo:inline font-weight="bold"> 
     <xslout:value-of select="code" /> 
    </fo:inline> 
</fo:block> 
+0

你可以用你試過的XSLT顯示你的完整輸出XML – 2014-11-24 10:51:28

回答

1

看來你需要使用xsl:copy-of

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:output method="xml" indent="yes"/> 
    <xsl:template match="/data/text-german"> 
     <xsl:copy-of select="./*"/> 
    </xsl:template> 
</xsl:stylesheet> 

您可能需要修改上述內容以滿足您的需求。

+1

非常感謝! :) – FluepkeSchaeng 2014-11-24 12:36:56