delete node childs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lakumc
    New Member
    • Dec 2007
    • 1

    delete node childs

    Hi,
    i’m a beginner whit xslt then i need help.
    I want to delete all elementos 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?

    Code:
    <xsl:template match="*|/">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="//PubmedArticle/MedlineCitation/Article/*[name()!='PubModel'][name()!='ArticleDate']
    PLEASE HELP ME!!!
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    You already have the answer on another forum, but I propose this, due to simplicity and slightly increased performance vs the other solution.
    Code:
    <xsl:template match="*|/">
      <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates/>
      </xsl:copy>
    </xsl:template>

    Comment

    Working...