Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2007, 02:54 AM
Authorized User
 
Join Date: Jul 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Removing Comments in one go

Hi,

Is there a way of removing all comments from XML, using XSLT, like we do it for removing specific element/attribute in one go.

Thanks in advance for suggestions.

Pankaj

__________________
Pankaj
 
Old September 9th, 2007, 03:56 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Use the standard design pattern of an identity template plus an overriding template:

<xsl:template match="node()">
  <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="comment()" priority="2"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 9th, 2007, 05:14 AM
Authorized User
 
Join Date: Jul 2007
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael again.

I will try it and let you know.

Though I've little confused about attribute "priority". I've just gone thru the documentation, which says the higher the priority number the higher the importance for a template.

Q: DID "Importance of template" the importance of processing a particular element/node?

Thanks anyway.

Pankaj

 
Old September 9th, 2007, 07:05 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you have two template rules that both match a particular node, then the one with the higher priority wins. In most cases you can rely on the default priority - in fact I think you can here - but the rules are complicated, so it's easier to make it explicit.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Comments janees ASP.NET 1.0 and 1.1 Professional 1 April 8th, 2007 09:27 PM
Comments in my javascripts 4 xristina Javascript 1 November 4th, 2004 10:31 AM
Comments in my javascripts 2 xristina Javascript 1 November 3rd, 2004 09:17 AM
Graph and Comments Wall st Guru Excel VBA 2 July 3rd, 2004 02:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.