Subject: RE: [xsl] using xsl:with-param in apply-templates problem From: "Niki Dinsey" <niki.dinsey@xxxxxxxxx> Date: Tue, 27 Aug 2002 14:32:27 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] using xsl:with-param in a, David Carlisle | Thread | RE: [xsl] using xsl:with-param in a, Jarno . Elovirta |
Re: [xsl] Counting Characters and W, David Carlisle | Date | Re: [xsl] checking for element in C, Elliotte Rusty Harol |
Month |