2017-06-19 4 views
0

属性の綴りを訂正するXSL変換があります。これは正常に動作します。しかし、訂正をスキップすると(訂正された属性がすでに存在するため)、別のファイルに記録します。XMLファイルの内容をコピーし、別のファイルにXSLT処理のログ出力を書き込む

これらの2つのタスクは別々に動作しますが、それらを一緒にしようとするとログファイルだけが書き込まれますが、結果として得られるXMLとログファイルの両方が必要になります。それを修正するには?

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
<xsl:strip-space elements="*"/> 
<xsl:variable name="processingFileName" select="base-uri()" /> 


<!------- This corrects the spelling in the XML ----------> 
<xsl:template match="node()|@*" >  
    <xsl:copy> 
     <xsl:apply-templates select="node()|@*" /> 
    </xsl:copy> 
</xsl:template> 

<xsl:template match="Attribute[@Name = 'Clor']" > 
    <xsl:if test="not(../Attribute[@Name = 'Color'])"> 
     <Attribute Name="Color" Value="{@Value}" /> 
    </xsl:if>  
</xsl:template> 


<!------- This logs skipped parts in a log file ----------> 
<xsl:template match="/" > 
    <xsl:result-document method="text" href="{$processingFileName}.log"> 
     <xsl:apply-templates mode="logging" select="/export/parts/part/Attribute" /> 
    </xsl:result-document>  
</xsl:template> 

<xsl:template match="Attribute[@Name = 'Clor']" mode="logging">   
    <xsl:if test="(../Attribute[@Name = 'Color'])"> 
     <xsl:value-of select="../@PartNo" /> 
     <xsl:text>&#13;&#10;</xsl:text> 
    </xsl:if>  
</xsl:template>  

答えて

1

デフォルトモードは

<xsl:template match="/" > 
    <xsl:apply-templates/> 
    <xsl:result-document method="text" href="{$processingFileName}.log"> 
     <xsl:apply-templates mode="logging" select="/export/parts/part/Attribute" /> 
    </xsl:result-document>  
</xsl:template> 

<xsl:template match="/" > 
    <xsl:result-document method="text" href="{$processingFileName}.log"> 
     <xsl:apply-templates mode="logging" select="/export/parts/part/Attribute" /> 
    </xsl:result-document>  
</xsl:template> 

を変更することで、ドキュメントの子孫のためにも使用されていることを確認します

関連する問題