You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by MORAVEK Peter <mo...@pobox.sk> on 2000/01/05 14:13:30 UTC

XSL question

Hello, 

I'm using the XSLT to convert XML to HTML. Some of the same HTML output I
need to use on several places, so I have extracted it to one xsl:template
(say <xsl:template match="AAA">). Everyting work fine, until I need to
insert the template AAA dynamically according to some IF condition, example:

input:
-------
<root>ok</root>

xslt:
-----
<xsl:template match="root">
  <HTML>
    <HEAD>
    </HEAD>
    <BODY>
      <xsl:if test="root[.='ok']">
        <xsl:element name="AAA"/>
        <xsl:apply-templates select="AAA"/>
      </xsl:if>
    </BODY>
  </HTML>
</xsl:template>

<xsl:template match="AAA">
  <B>inside of the AAA template</B>
</xsl:template>

wrong output:
------------------
<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <AAA></AAA>
  </BODY>
</HTML>

correct output:
---------------------
<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <B>inside of the AAA template</B>
  </BODY>
</HTML>

I don't know, how to insert the <AAA> tag into XML while processing XSL and
to apply the template AAA to this tag.

Thans for help

Peter Moravek