2012-01-09 14 views
0

処理するテキストとxmlタグが混在するタグがあります。私はxsl:templatesが定義されているタグについて、xslをどのように構築すれば、変換結果が元の文書と同じ順序でテキストフラグメントとタグ置換の結果になるのでしょうか?ここでXSL:テキストとタグ処理の結果を組み合わせる

は、ソースXMLです:

<diagnosis> 
    Line 1 
    Line 2 
    <terminology code="1234"/> 
    Line 3 
</diagnosis> 

出力はこのようなものでなければなりません:

Line 1 Line 2 Description1234 Line 3 

Description1234が、私は心配していないです、今のコード1234のルックアップの結果であり、どのようにしてそれをすべて一緒にスプライスするのかということについて、

+1

例を掲載する必要があります。サンプルXML入力と、その入力に対する* exact * expectedの結果を表示します。これを行うとすぐに回答が得られます。さもなければ、人々はあなたの心を読むよう誘惑します。 –

答えて

1

私はどのように<terminology/>マップ「説明」に、私は次のことを想定しわからない:ここで私はxsltprocのを通して、あなたの例のXML(「so.xml」)を実行したときに、私は何を得るのです

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="text"/> 
    <xsl:template match="/"> 
    <xsl:apply-templates/> 
    <!-- Final newline --> 
    <xsl:text> 
</xsl:text> 
    </xsl:template> 
    <xsl:template match="terminology"> 
    <!-- Spaces are added at the front and... --> 
    <xsl:text> Description</xsl:text> 
    <xsl:value-of select="@code"/> 
    <!-- at the end of attribute --> 
    <xsl:text> </xsl:text> 
    </xsl:template> 
    <xsl:template match="text()"> 
    <!-- Strip all white space, specifically the newlines --> 
    <xsl:value-of select="normalize-space(.)"/> 
    </xsl:template> 
</xsl:stylesheet> 

~ zacharyyoung$ xsltproc so.xsl so.xml 
Line 1 Line 2 Description1234 Line 3 
関連する問題