XSLT 2.0 filtering attributes with the identity transform -


i using xslt 2.0 pull data out of xhtml files. want rid off attributes except href. version of identity transform removes attributes. note not copy attributes because @*is not used.

<xsl:template match="node()">   <xsl:copy>      <xsl:apply-templates select="node()"/>   </xsl:copy> </xsl:template> 

i tried using @* , filtering href not work.

<xsl:template match="node()|@*[href]">   <xsl:copy>      <xsl:apply-templates select="node()|@*"/>   </xsl:copy> </xsl:template> 

i message the child axis starting @ attribute node never select anything. have tried using other constructs @*[@href] , @*[href=@*] , same message. i'm using saxon 9.5.1.4.

can selectively copy specific attributes (and values) identity transform or have way?

try:

<xsl:template match="node()|@href">   <xsl:copy>      <xsl:apply-templates select="node()|@href"/>   </xsl:copy> </xsl:template> 

Comments