You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by tc...@dff.st on 2000/08/09 18:17:43 UTC
default template
I know this is slightly OT since it is more
a XSLT question... please don't yell at me ;)
I've modified the default template in
my XSP page not to copy all nodes but
to leave out the ones with a specific
attribute. Unfortunately this doesn't
work and I don't know why...
<xsl:template match="*">
<xsl:choose>
<xsl:when test="@level">
<error/>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
--
Torsten
RE: default template
Posted by Torsten Curdt <tc...@dff.st>.
Got it! Tweaked a little with the mode attribute... :)
--
Torsten
RE: default template
Posted by Torsten Curdt <tc...@dff.st>.
Well, I already tried
<xsl:template match="*[@level]">
<xsp:logic>
if(somevar == "<xsl:value-of select="@level"/>"){
<xsl:apply-templates/>
} else {
<error/>
}
</xsp:logic>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="text">
<xsp:logic>
...get text from somewhere...
</xsp:logic>
</xsl:template>
I think I should explain first what I want to
do. I have a XML document
<content>
<text level="2"/>
other text
<content>
Now I want to decide via XSP whether text
at level 2 is supposed to show or not...
But <text> doesn't get matched because it
has been matched by @level before (I guess)
> You should try two templates instead. something like
>
> <xsl:template match="@level">
> <error/>
> </xsl:template>
>
> <xsl:template match="*">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
> >I know this is slightly OT since it is more
> >a XSLT question... please don't yell at me ;)
> >
> >I've modified the default template in
> >my XSP page not to copy all nodes but
> >to leave out the ones with a specific
> >attribute. Unfortunately this doesn't
> >work and I don't know why...
> >
> > <xsl:template match="*">
> > <xsl:choose>
> >
> > <xsl:when test="@level">
> > <error/>
> > </xsl:when>
> >
> > <xsl:otherwise>
> > <xsl:copy>
> > <xsl:copy-of select="@*"/>
> > <xsl:apply-templates/>
> > </xsl:copy>
> > </xsl:otherwise>
> >
> > </xsl:choose>
> > </xsl:template>
> >--
> >Torsten
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> >For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
RE: default template
Posted by Kirk Woerner <ki...@stoneseeker.com>.
You should try two templates instead. something like
<xsl:template match="@level">
<error/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
>-----Original Message-----
>From: tcurdt@dff.st [mailto:tcurdt@dff.st]
>Sent: Wednesday, August 09, 2000 10:18 AM
>To: cocoon-users@xml.apache.org
>Subject: default template
>
>
>I know this is slightly OT since it is more
>a XSLT question... please don't yell at me ;)
>
>I've modified the default template in
>my XSP page not to copy all nodes but
>to leave out the ones with a specific
>attribute. Unfortunately this doesn't
>work and I don't know why...
>
> <xsl:template match="*">
> <xsl:choose>
>
> <xsl:when test="@level">
> <error/>
> </xsl:when>
>
> <xsl:otherwise>
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:otherwise>
>
> </xsl:choose>
> </xsl:template>
>--
>Torsten
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>