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

RE: using xsl:with-param in apply-templates problem

Subject: RE: using xsl:with-param in apply-templates problem
From: "Niki Dinsey" <niki.dinsey@xxxxxxxxx>
Date: Tue, 27 Aug 2002 14:32:27 +0100
dinsey
Hey Jeni ;)

> You're probably losing the parameter en-route from the document
> element of the document you're processing to the ATITLE, BTITLE etc.
> elements in the body of the document. The built-in template, used for
> the document element of that document, is:
> 
> <xsl:template match="*" mode="file">
>   <xsl:apply-templates mode="file" />
> </xsl:template>
>
 
I never knew about built in templates, I guess it makes a lot of sense
really when you think of it!

> As you can see, the parameter doesn't get passed through this built-in
> template. So try overriding it so that the parameter gets passed
> through to the children of the element:
> 
> <xsl:template match="*" mode="file">
>   <xsl:param name="filename" />
>   <xsl:apply-templates mode="file">
>     <xsl:with-param name="filename" select="$filename" />
>   </xsl:apply-templates>
> </xsl:template>
> 

I've made the addition and now it works fine, thanks very much for your
help. That had me stumped completely, I was writing regex hacks in
python to get round the problem! (it only need to be produced once)

> Also note what David said about match patterns -- they never need to
> start with '//' -- //foo matches "foo elements that are descendants of
> the root node" but *all* foo elements must be descendants of a root
> node, so there's no point testing that. Your template:
> 
> <xsl:template
> match="//ATITLE|//BTITLE|//CTITLE|//DTITLE|//ETITLE|//FTITLE"

Yes sorry, I did feel a little foolish sending this code fragment just
after David had explained that before! I've made the changes and taken
note, honest ;)


> [I've also used attribute value templates here just 'cos they're
> shorter, and note that "ancestor::*[last()]/attribute::ID" is
> equivalent to "/*/@ID" -- the ID attribute of the document element.

It's certainly a lot more elegant than my xpath, I've made the changes

> (Is
> that what you meant to do, or did you want "../@ID", the ID attribute
> of the element's parent?)]

in this case I'm after the root element's (chapters) ID, I've also been
using parent::*/@ID on another select, which I guess can be changed to
../@ID

Thanks both of you for your help this morning, thanks Jeni for
explaining it so well to a noddy like me!

Cheers

Niki



 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.