cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Pruy <Rainer.P...@Acrys.COM>
Subject Re: Strange XSLT transformer behaviour?
Date Tue, 22 Apr 2008 14:25:07 GMT
Hi Heather,
nothing strange here. It is eaxctly how XSLT works.

Your templat (fragment) says:

a) at the root of the document to be processed, start a "p" element.
b) then add anything form processing <xsl:apply-template..../> (*)
c) then end the "p" element opened above
d) then add the constant rest (<p>....</p>)

(*) This template will require the path "html/head/title" to be matched for applying.

Thus, if the template(s) that will match the apply-templates does not output anything the
"p" from steps (a and c)
will be empty (as you did observe).

Overall, it does not reference *itself*.
It is a template. It outputs any static parts and interprets the rest according XSLT semantics.

If you want to get the putput suppressed in case the apply-templates call does not match,
you might try the following:

<xsl:template match="/">
<xsl:if test="html/head/title">
<p><xsl:apply-templates select="html/head/title"></p>
<p>some more stuff</p>
</xsl:if>
</xsl:template>

Rainer


Heather Rankin schrieb:
> Hi,
> 
> I'm a newbie. Using Cocoon 2.1.11 and the following simple pipeline:
> 
> <map:match pattern="submit-url">       
> 	<map:generate src="{request-param:url}" type="html" />        
> 	<map:transform src="stylesheets/form-wrapper.xsl" type="xslt"/>
> 	<map:serialize type="xhtml" />
> </map:match>
> 
> I noticed some strange XSLT behaviour where, on a failed template match,
> the XSL appears to reference *itself* as the input XML doc. In other
> words, let's say I have this xsl template:
> 
> <xsl:template match="/">
> <p><xsl:apply-templates select="html/head/title"></p>
> <p>some more stuff</p>
> </xsl:template>
> 
> The apply-templates fails because I haven't included the xhtml namespace
> in my xpath. But instead of just producing nothing, I get a fragment of
> the xsl template in the serialised output that looks something like
> this:
> 
> </p>
> <p>some more stuff</p>
> 
> Bizarre? If I correct the template and reference the xhtml namespace
> properly - no problem. I just thought it was strange that the XSL would
> seemingly call itself like this... Maybe I've observed things wrong?
> Could anyone clarify?
> 
> Heather
> 
> http://www.bbc.co.uk/
> This e-mail (and any attachments) is confidential and may contain personal views which
are not the views of the BBC unless specifically stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in reliance on it and
notify the sender immediately.
> Please note that the BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
> 					
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Rainer Pruy
Geschäftsführer

Acrys Consult GmbH & Co. KG
Untermainkai 29-30, D-60329 Frankfurt
Tel: +49-69-244506-0 - Fax: +49-69-244506-50
Web: http://www.acrys.com -  Email: office@acrys.com
Handelsregister: Frankfurt am Main, HRA 31151

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message