cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ed Staub" <est...@mediaone.net>
Subject RE: xsl matching
Date Wed, 19 Jul 2000 14:12:47 GMT
Torsten,

I like MarkW's "mode" solution, but if you really want to do this in the way
you're thinking...

While you didn't include the context in your mail, I suspect that the
problem is that you're in the wrong context.

<xsl:template match="navigation/item"> will work when triggered from an
apply-template at the <page> level.  If you are attempting to trigger it
from an apply-template at the <navigation> level, you need to use something
like:
	match="item[parent::navigation]"
instead.

-Ed Staub

-----Original Message-----
From: Torsten Curdt [mailto:tcurdt@dff.st]
Sent: Wednesday, July 19, 2000 6:54 AM
To: cocoon-users@xml.apache.org
Subject: RE: xsl matching


> > just a simple question...
> > ....don't know if got it right from book.
> > Doesn't seem to work in real life.
> >
> > I have a XML file:
> > <page>
> > <navigation>
> > <item/>
> > <item/>
> > </navigation>
> > <menu>
> > <item/>
> > <item/>
> > </menu>
> > </page>
> >
> > Now I have two different items but wanna
> > match them differently. Thought it was:
> >
> > <xsl:template match="navigation/item">
> > </xsl:template>
> >
> > <xsl:template match="menu/item">
> > </xsl:template>
> >
> > ...but it doesn't seem to work.
> what's the context?

Well, if I see it from a OOP point of view:
I have an object navigation and an object menu.
Both have an attribute named item. But since
they are items from different objects (which
is reflected in the hierachic DOM structure)
they are also wanted to be displayed differently.

> Within
> <xsl:template match="page">
>     <xsl:apply-templates/>
> </xsl:template>
>
>  <xsl:template match="navigation">
>     <xsl:apply-templates select="item" mode="navigation"/>
>  </xsl:template>
>
>  <xsl:template match="item" mode="navigation">
>    ...
>  </xsl:template>
>
>
> you can use mode="navigation", mode="menu" if you want different
> templates:

This will works... but actually I think it's a bit
of a work around.
Shouldn't I be able to match it like I can match
top level objects via:

<xsl:template match="/toplevelobject">

This is a match that reflects the hierachic position
of the object. If not relative... shouldn't it work
absolute like this ?

<xsl:template match="/page/navigation/item"/>

<xsl:template match="/page/menu/item"/>

But actually I'd like to have it to match
for any menu or navigation item - not just
those exactly inside the page object.

This is why I thought...

<xsl:template match="navigation/item"/>
<xsl:template match="menu/item"/>

..should do it

(Hope this is not too off topic)
--
Torsten

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


Mime
View raw message