おかげでクリスは、私は将来的にこの問題を持つ人のために共有したいと思った私の要件に合わせてソリューションを編集しました。
注:これはアンカーの内部のテキストを移動し、テキストを外側に削除します。 HTMLではなく、テキストのみを含むように意図されたアンカーを修正しました。すなわち 私の解決策の修正このタグ:
<p><a name="anchor1" id="anchor1">Anchor text</a></p>
でもない。これに
<p><a name="anchor1" id="anchor1"></a>Anchor text</p>
:
<p><a name="anchor1" id="anchor1"></a><h1>Anchor text</h1></p>
をここに私のXSLです。うまくいけば、それは私はあなたが簡単に(私は私の解決策のためにこれを必要としない)次のタグを探すためにそれを更新する可能性が確信している、あなたのベースを与えるのに役立ちます。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" method="html" cdata-section-elements="script"/>
<xsl:template match="/ | node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- fixes Tridion bug when using interface button to insert anchor in rich text field -->
<!-- gets all empty anchor tags with an id and takes any following text and copies it inside anchor -->
<xsl:template match="a[(@id) and (count(node()) = 0)]">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:value-of select="normalize-space(following-sibling::text())"/>
</xsl:copy>
</xsl:template>
<!-- delete any text after an empty anchor (template above has already copied this text inside the anchor) -->
<xsl:template match="text()[preceding-sibling::a[(@id) and (count(node()) = 0)]]" ></xsl:template>
</xsl:stylesheet>
ここに私のテストXMLが
<?xml version ="1.0"?>
<?xml-stylesheet type="text/xsl" href="tridionhtmlfield.xsl"?>
<html>
<head></head>
<body>
<p><a id="anchorlink" name="anchorlink" title="Anchor link" href="#Anchor">Anchor link</a>Some text after</p>
<p><a name="broken-with-html-name" id="broken-with-html-id"></a><h1>Anchor - broken with html</h1></p>
<p><a name="broken-text-only-name" id="broken-text-only-id"></a>Anchor - broken text only</p>
<p><a name="broken-notext-name" id="broken-notext-id"></a></p>
<p><a name="correct-name" id="correct-id">Anchor - correctly rendered</a> Some text after</p>
</body>
</html>
だ後変換:
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
<body>
<p><a id="anchorlink" name="anchorlink" title="Anchor link" href="#Anchor">Anchor link</a>Some text after</p>
<p><a name="broken-with-html-name" id="broken-with-html-id"></a><h1>Anchor - broken with html</h1></p>
<p><a name="broken-text-only-name" id="broken-text-only-id">Anchor - broken text only</a></p>
<p><a name="broken-notext-name" id="broken-notext-id"></a></p>
<p><a name="correct-name" id="correct-id">Anchor - correctly rendered</a> Some text after</p>
</body>
</html>
希望これは
を助け、私はあなたが正しい@Domていると思う - 私は私のXSLTフィルターを変更しましたスキーマを使用して、推奨されたとおりに問題を処理します。他の人はこれが、この場合には回避策かもしれない –