cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject AW: Hopefully simple and stupid problem about dynamically adding element
Date Tue, 13 Jun 2000 13:33:27 GMT
This is an excerpt of my test tag library which adds the <auth> element to
each page.
Perhaps its a little overkill for your problem, but it should work:

###########CODE-SNIPPED###############

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>
  <xsl:template match="xsp:page">
    <xsp:page>

      <xsl:copy>
        <xsl:apply-templates select="@*"/>
      </xsl:copy>
      <xsp:logic>
        /* Auth-Logic, implement this: */
        private static String authTest() { return "false"; // or "true"}
      </xsp:logic>
      <xsl:apply-templates/>

    </xsp:page>
  </xsl:template>

  <xsl:template match="page">
     <page>
       <xsl:copy>
        <xsl:apply-templates select="@*"/>
       </xsl:copy>
       <xsl:apply-templates/>
       <auth>
         <xsp:expr>
           authTest()
         </xsp:expr>
       </auth>
     </page>
  </xsl:template>

  <xsl:template match="@*|node()" priority="-1">
    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  </xsl:template>

</xsl:stylesheet>

###########END CODE-SNIPPED###############

- Carsten

------------------------------------------------------------------------------------------
...this mail was scanned for viruses by mailserver...

Mime
View raw message