私はこれに対する答えを高くも低くも見て、何百もの順列を試しましたが、何もうまくいきませんでした。
最初のノードを除いて、単純なXMLドキュメントのすべてのノードを処理しようとしてい<title>
ます。基本的に、私は正確なINVERSEを達成するxslt命令を見つけようとしています。
<xsl:apply-templates select="/topic/title"/>
これが私のソースXMLです:
<topic>
<title>Name of the Document</title>
<p>Document body</p>
<topic>
<title>First Document Subtopic</title>
<p>Body text for first document subtopic</p>
</topic>
<p>Body text continued for document</p>
<topic>
<title>Second Document Subtopic</title>
<p>Body text for document subtopic</p>
<topic>
<title>First Document Sub-subtopic</title>
<p>Body text for first document sub-subtopic</p>
</topic>
</topic>
<p>Body text continued a second time for document</p>
</topic>
これが私のXSLTです(apply-templatesの呼び出しで最初に機能すると思っていたものを使用):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output omit-xml-declaration="yes" encoding="UTF-8" method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<BOX>
<TEXTFLOW>
<xsl:apply-templates select="*[not(/topic/title)]"/>
</TEXTFLOW>
</BOX>
</xsl:template>
<xsl:template match="topic">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="title">
<PARA STYLE="Title"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="p">
<PARA STYLE="BodyText"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()">
<FORMAT>
<xsl:value-of select="."/>
</FORMAT>
</xsl:template>
</xsl:stylesheet>
そして、これが私が見たいものです(最初の問題がないことに注意してください<title>
):
<BOX>
<TEXTFLOW>
<PARA STYLE="BodyText"/>
<FORMAT>Document body</FORMAT>
<PARA STYLE="Title"/>
<FORMAT>First Document Subtopic</FORMAT>
<PARA STYLE="BodyText"/>
<FORMAT>Body text for first document subtopic</FORMAT>
<PARA STYLE="BodyText"/>
<FORMAT>Body text continued for document</FORMAT>
<PARA STYLE="Title"/>
<FORMAT>Second Document Subtopic</FORMAT>
<PARA STYLE="BodyText"/>
<FORMAT>Body text for document subtopic</FORMAT>
<PARA STYLE="Title"/>
<FORMAT>First Document Sub-subtopic</FORMAT>
<PARA STYLE="BodyText"/>
<FORMAT>Body text for first document sub-subtopic</FORMAT>
<PARA STYLE="BodyText"/>
<FORMAT>Body text continued a second time for document</FORMAT>
</TEXTFLOW>
</BOX>
これを実現するためにどのselect式を使用できますか?