cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers" <a.schrijv...@hippo.nl>
Subject RE: Named queries in SQLTransformer
Date Fri, 11 Nov 2005 08:37:15 GMT
Hello Oleg, 

since you saw your xsl becoming unclear and you did not find an easy way to find where it
went wrong, try to do the following in your xsl:

Using apply-templates instead of for-each. This makes your xsl cleaner and re-use of code
is simple.

So, make your xsl someting like:

<xsl:template match="/">
	<foo>
	    <xsl:apply-templates select="/page/content/sql:rowset[@sql:name='query1']/child::node()"/>
	</foo>
</xsl:templates>

<!-- since child:nodes match to sql:row we need template which matches this, so -->

<xsl:template match="sql:row">
	<yi>
		<xsl:apply-templates select="child::node()"/>
	</yi>
</xsl:template>

<!-- the child::node() can be any col1....coln in the sql result...so -->

<xsl:template match="sql:col1">
	<bar>
		<xsl:value-of select="."/>
	<bar>	
</xsl:template>
<xsl:template match="sql:col2">
	<bar2>
		<xsl:value-of select="."/>
	<bar2>	
</xsl:template>


Now, when you only see in the output foo, then your xpath /page/content/sql:rowset[@sql:name='query1']/child::node()
 is not correct. When you see <yi> but not <bar> etc etc....

Just play around with apply-templates, they are very powerful...you also can include "mode"
for apply-templates to let the template be applied to a specific matcher, etc etc. Better
forget xsl:for-each since you can almost always do withthout. 

AS







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


Mime
View raw message