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.
- 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.
- 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.
- How to disable some templates? Simple:
<xsl:template match="tag1_to_disable|tag2_to_disable" />
- How to write identity template?
<xsl:template match="*|@*|comment()|processing-instruction()|text()"> <xsl:copy> <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/> </xsl:copy> </xsl:template>
- What is copy templates?
<xsl:template match="tag1_to_copy|tag2_to_copy" > <xsl:copy-of select="." /> </xsl:template>Attention, this will copy it and its decendents.