私はかなりばかげた質問をしています。XML 混合コンテンツ ノードが混同されないようにするにはどうすればよいですか? たとえば、これに似た XML 構造があります。
<root>
<book>
<title>Stuff</title>
<description> This book is <i>great</i> if you need to know about stuff.
I suggest <link ref="Things">this one</link> if you need to know
about things. </description>
</book>
[other books]
</root>
このように見える最終的なコンテンツが必要です
<h1>List of books</h1>
<h2><a name="Stuff"/>Stuff</h2>
<p> This book is <i>great</i> if you need to know about stuff.
I suggest <a href="#Things">this one</a> if you need to know
about things. </p>
しかし、テキスト ノードの一部を抽出することはできません。常に全体を取得します。子孫軸を使用しています。私が間違っていることの手がかりはありますか?
これが私のxsltです:
<xsl:template match="description/*">
<xsl:for-each select="following-sibling::*">
<xsl:choose>
<xsl:when test="name(.)='link'">
<a href="{@ref}"><xsl:value-of select="."/></a>
</xsl:when>
<xsl:when test="name(.)='em'">
<em><xsl:value-of select="."/></em>
</xsl:when>
<xsl:otherwise><p><xsl:value-of select="."/></p></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
含まれている XML と結果の html は単なる例であることに注意してください。わかりやすくするために、含まれていないより大きな構造を扱う必要があります。