[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Newbie question--applying templates, selecting par

Subject: Re: Newbie question--applying templates, selecting paragraphs
From: Grant-Kathryn@xxxxxxxxxxxxxxxxx
Date: Thu, 23 May 2002 17:09:48 -0700
selecting and applying a template
Joerg,

Thanks for your reply!  I tried what you suggested, but unfortunately it
still copied all the paragraphs, including the paragraphs in the <div
class="mgronly"> tags.  This is the XSL file I ended up with . . .

---------------------- XSL file-----------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="xml" encoding="UTF-8"/>

	<xsl:template match="*|@*|text()|comment()">
		<xsl:copy>
			<xsl:apply-templates
select="*|@*|text()|comment()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="div[@class='mgronly']">
   		<!-- 'mgronly' div's won't be copied -->
	</xsl:template>

</xsl:stylesheet>
---------------------- XSL file-----------------------------------

Did I misunderstand what you meant?

Thanks again for your help!

Kathryn

Date: Thu, 23 May 2002 21:34:16 +0200
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Subject: Re:  Newbie question--applying templates, selecting paragraphs

Hello Kathryn,

> ---------------------- XSL file-----------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> 
> 	<xsl:output method="xml" encoding="UTF-8"/>
> 
> 	<!-- Match the root node -->
> 	<xsl:template match="*">
> 		<xsl:apply-templates select="*"/>
> 	</xsl:template>

here is a little error. It has to be <xsl:template match="/">. But this 
template is not explicitely needed, you can remove it.

> 	<!-- Handle any node not yet matched -->
> 	<xsl:template match="*|@*|text()|comment()">
> 		<xsl:copy>
> 			<xsl:apply-templates
> select="*|@*|text()|comment()"/>
> 		</xsl:copy>
> 	</xsl:template>
> 
> </xsl:stylesheet>
> ---------------------- XSL file-----------------------------------

This stylesheet copies "all and everything". If you add other templates 
mathcing on <div>, with a special predicate and do nothing in these 
templates, those <div>s won't be copied.

example:

<xsl:template match="div[@class='mgronly']">
   <!-- 'mgronly' div's won't be copied -->
</xsl:template>

Regards,

Joerg

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.