how to generate xml file with only some elements of another xml file using xsl file. I have an xml file.Now i have to write an xsl file so that,it should copy only some elements of the input xml file. please help me.this is urgent

Roseanne Zhang

This is a summary. It just depends how many you want to copy over.

  1. If you only want to copy a few, then disable all default templates and only write the copy templates for those you want to copy.
  2. If you want to copy all but exclude a few, then use identity template, and only disable a few templates for those you want not to copy.
  3. How to disable some templates? Simple:
    <xsl:template match="tag1_to_disable|tag2_to_disable" />
  4. How to write identity template?
      <xsl:template match="*|@*|comment()|processing-instruction()|text()">
          <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
  5. What is copy templates?
    <xsl:template match="tag1_to_copy|tag2_to_copy" >
      <xsl:copy-of select="." />
    Attention, this will copy it and its decendents.
Jan Matèrne also gave a good example here.
About | Sitemap | Contact