cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skoech...@n-soft.com (Sebastien Koechlin I-VISION)
Subject Re: XSLT questions.
Date Tue, 18 Apr 2000 09:42:10 GMT
Peter Kharchenko wrote :

>   I have a couple of rather basic questions on associating XSLT stylesheets with XML
> documents. I've read the w3c recommendation on that subject
> (http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/), but couldn't find an
> answer. I hope one of you guys can help me out.

I did not find any good documentation about XSLT. It's really painful. 
(And it's the same for XSP and taglib, Cocoon is an hard way !)

>  I was wondering if it's possible to associate stylesheet with a particular XML node
> instead of a whole document. For example if I have the following document,
> --------------------
> <book>
>   <index> ... </index>
>   <chapter> ... </chapter>
>   <chapter> ... </chapter>
> </book>
> --------------------
>  I would like to associate a different stylesheet with each of the <chapter> nodes
> (because chapters might differ in their formats).

You can associate a template with a particular element using XPath using
something
like :

<xsl:template match="book">
	(...)
		<xsl:apply-templates select="index">
		<xsl:apply-templates select="chapter[1]" mode="style1" />
		<xsl:apply-templates select="chapter[2]" mode="style2" />
	(...)
</xsl:template>

<xsl:template match="chapter" mode="style1">
	(...)
</xsl:template>

<xsl:template match="chapter" mode="style2">
	(...)
</xsl:template>

With XPath, you can select a particular chapter, on it's position (for
example every other
chapter), or on an chapter attribute (better), using
select="chapter[@style='value']"

-- 
Seb

Mime
View raw message