Re: [xsl] [Fwd: Unwanted xmlns attributes in ouput html tags]

Subject: Re: [xsl] [Fwd: Unwanted xmlns attributes in ouput html tags]
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 26 Sep 2003 09:40:44 +0100
Hi Dinesh,

> I am hoping someone may have some ideas to help resolve a problem
> that I am currently experiencing. It seems rather unique and
> specific. I am getting unwanted xmlns attributes appearing in output
> html tags in a two-stage transform process and it appears to be due
> to the use of includes in the first pass. It also seems to be an
> xsl-processor-specific problem.

I'm afraid that it looks as though this problem is down to a bug in
the XSLT processor that you're using. The best course of action would
be to upgrade to a processor that doesn't exhibit the bug, for example
Xalan 2.5.1, but I understand that you can't do that...

To work around the bug, you could try adding
exclude-result-prefixes="xsl" to the <xsl:stylesheet> element in
inc.ixsl to see if that has any effect.

Or you could try generating the elements using <xsl:element> rather
than literal result elements; i.e. use:

<ixsl:template name="my_step_one_template">
  <ixsl:element name="tr">
    <ixsl:element name="td">
      <ixsl:attribute name="bgcolor">#666699</xsl:attribute>
      <ixsl:element name="b">
        Some text output by step one
      </ixsl:element>
    </ixsl:element>
  </ixsl:element>
</ixsl:template>

Or you could try generating <xsl:element> instructions in
intermediate.xsl:

<ixsl:template name="my_step_one_template">
  <xsl:element name="tr">
    <xsl:element name="td">
      <xsl:attribute name="bgcolor">#666699</xsl:attribute>
      <xsl:element name="b">
        Some text output by step one
      </xsl:element>
    </xsl:element>
  </xsl:element>
</ixsl:template>

> Getting to the final transform (intermediate.xsl + test_data.xml =>
> final.html), it produces:
>
> ***** final.html ***********
> <html>
> <tr xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias";>
> <td bgcolor="#666699"><b>
>             Some text output by step one
>           </b></td>
> </tr>
> <tr></tr><p></p></html>
> ***** end file *************
>
> Notice that "my_step_two_template" didn't get called, or at least
> there is no output from that template in "final.html". My
> interpretation is that because of the pesky "xmlns" attribute
> appearing on the <tr> (with the ".../TransformAlias" URI), the
> processor reads the "xsl:call-template" as being in the
> "TransformAlias" namespace, hence does not process it, and hence the
> xsl template is not called.

The my_step_two_template *is* being called here -- otherwise you
wouldn't get the <p> element after the second <tr> element. You might,
though, get problems if you have XSLT instructions within the <tr>
element -- it depends on what the buggy processor outputs when you
generate XSLT instructions within the <tr> element as generated by
my_step_one_template in inc.ixsl.

By the way, why are you using disable-output-escaping in:

>         <xsl:template name="my_step_two_template">
>           <xsl:param name="text" />
>           <xsl:text disable-output-escaping="yes">&lt;p&gt;</xsl:text>
>             <xsl:value-of select="$text" />
>           <xsl:text disable-output-escaping="yes">&lt;/p&gt;</xsl:text>
>         </xsl:template>

When you would get exactly the same output from a literal result
element:

<xsl:template name="my_step_two_template">
  <xsl:param name="text" />
  <p>
    <xsl:value-of select="$text" />
  </p>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread