[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Commenting selected elements (parents) and keeping the
Hello all, Is there is a way to commenting some specific elements mostly parents while retaining the child elements in output. I know I am sounding bit stupid as far as the hierarchy of xml is concerns, but I need to restore the parents/grand parents (instead omitting them) along with their attribute values. As of now I am trying the following, but its omit them. <xsl:template match="root"> <xsl:copy> <xsl:attribute name="dummy">the_root</xsl:attribute> <xsl:apply-templates/> <xsl:apply-templates select=".//aaa"/> </xsl:copy> </xsl:template> <xsl:template match="root//aaa"> <xsl:copy> <xsl:attribute name="dummy">xxx</xsl:attribute> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <!-- omit these --> <xsl:template match="abc | bbb"/> Input ==== <root> <abc id="123"> <bbb> <aaa id="123">xxxxxx</aaa> </bbb> <abc> </root> Output ====== <root> <!--<abc id="123"><bbb>--> <aaa id="123">xxxxxx</aaa> <!--</bbb> <abc>--> </root> or may be something like =================== <root> <aaa id="123">xxxxxx</aaa> <!--<abc id="123"> <bbb>--><!--</bbb> <abc>--> </root> I've also tried to use the following but takes only text nodes of the <abc> and <bbb> and "not their markup". <xsl:template match="root"> <xsl:copy> <xsl:attribute name="dummy">the_root</xsl:attribute> <xsl:apply-templates/> <xsl:apply-templates select=".//aaa"/> <xsl:comment> <xsl:apply-templates select="./abc | .//bbb"/> </xsl:comment> </xsl:copy> </xsl:template> Hope I've made myself clear and any ideas in this regard will be highly appreciated. Best, Pankaj Chaturvedi ============================================================================ ================ Confidentiality Notice:" This message and any attachment(s) contained here are information that is confidential, proprietary to IDS Infotech Ltd. and its customers. Contents may be privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer."
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|