何もしないXSLT part.2
最近、また同じようなXSLTを書いたので、前に書いたのと見比べてみた。
前のもの
<xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="*|@*|text()" /> </xsl:copy> </xsl:template> <xsl:template match="@*"> <xsl:copy /> </xsl:template>
新しいもの
<xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()|attribute::*" /> </xsl:copy> </xsl:template> <xsl:template match="attribute::*"> <xsl:copy /> </xsl:template>
node()になっている方がコメントノードとかもコピーできて良いような気がする。
以前に書いたものはtext()を宣言しているが、これは必要なんだっけ?
…「*」ではテキストノードにマッチしないからか。
「attribute::*」より「@*」の方が文字数が少ない分「正義」かもしれない(笑)