したがって、このXMLを検討します。
<root>
<table>
<tr>
<td>asdf</td>
<td>qwerty</td>
<td>1234 <p>lorem ipsum</p> 5678</td>
</tr>
</table>
<root>
...どうすればこのように変換できますか?
<root>
<table>
<tr>
<td><BLAH>asdf</BLAH></td>
<td><BLAH>qwerty</BLAH></td>
<td><BLAH>1234 <p>lorem ipsum</p> 5678</BLAH></td>
</tr>
</table>
</root>
その場合、のすべてのインスタンスに 要素<td>
が含まれ、 <BLAH>
それぞれのコンテンツが <td>
新しいノード内に含まれます。
...これまでのところ、各
<td>
要素を新しいノードでラップしているこのXSLがありますが、内側ではなく外側にあります:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>
<!-- identity rule -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="table//td">
<BLAH>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</BLAH>
</xsl:template>
</xsl:stylesheet>
...これはこの望ましくない結果
を生み出しています:
<root>
<table>
<tr>
<BLAH><td>asdf</td></BLAH>
<BLAH><td>qwerty</td></BLAH>
<BLAH><td>1234 <p>lorem ipsum</p> 5678</td></BLAH>
</tr>
</table>
</root>
http://xslt.online-toolz.com/tools/xslt-transformation.php
でテスト済み