Page 1 of 1

Delete child of a path

Posted: Sun Dec 09, 2007 3:53 am
by lakumc
Hi,
i’m a beginner whit xslt then i need help.
I want to delete all elements son of the node Article that they aren’t except ‘PubModel’ and ‘ArticleDate’. I used the following code. It works but it doesn’t keep attributes in the resulting XML. Why? How can I do?

<xsl:template match="*|/">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="//PubmedArticle/MedlineCitation/Article/*[name()!='PubModel'][name()!='ArticleDate']

:?

Posted: Mon Dec 10, 2007 12:53 pm
by sorin_ristache
Hello,

You did not specify in the XSLT stylesheet that you want to keep the attributes:

Code: Select all


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

Regards,
Sorin