Delete child of a path

Here should go questions about transforming XML with XSLT and FOP.
lakumc
Posts: 1
Joined: Sun Dec 09, 2007 3:51 am

Delete child of a path

Post 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']

:?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post 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
Post Reply