cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MORAVEK Peter <mora...@pobox.sk>
Subject XSL question
Date Wed, 05 Jan 2000 13:13:30 GMT
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

Mime
View raw message