Rose
Rose

Reputation: 1498

XSLT: How to avoid adding self closing tag in attributes in HTML

I am a newbie to XSLT. I am trying to debug a problem of XSLT(version 2.0) which was written few years back. The part of the XSLT code is as below:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
        <xsl:output indent="yes" doctype-public="-//W3C//DTD HTML 4.0//EN" use-character-maps="m1"/>
        <xsl:character-map name="m1">
            <xsl:output-character character="&#141;" string=" "/>
        </xsl:character-map>
        <xsl:strip-space elements="*"/>
...
...
        <xsl:template match="PARA|PARASTYLE">
            <xsl:choose>
                <xsl:when test="@style-name-escaped or (ancestor::TABLE and not(text())) or (not(*) and not(text()))">
                    <div>
                        <xsl:if test="@style-name-escaped">
                            <xsl:attribute name="class">
                                <xsl:value-of select="@style-name-escaped"/>
                            </xsl:attribute>
                        </xsl:if>
                        <xsl:if test="(ancestor::TABLE and not(text())) or (not(*) and not(text()))">
                            <xsl:attribute name="style">
                                <xsl:text>margin-bottom=10pt</xsl:text>
                            </xsl:attribute>
                            <xsl:text/>
                        </xsl:if>
                        <xsl:apply-templates />
                    </div>
                </xsl:when>
...
..

This XSLT is converting XML into HTML as below. It is basically adding an attribute with a self closing tag as below

<div class="Normal-Level">
  <div style="margin-bottom=10pt"/>
</div>

which is causing a problem in displaying in some browsers because of the self closing tag. What I want to do is the output to look like below with attribute having open and close tag:

   <div class="Normal-Level">
      <div style="margin-bottom=10pt">
      </div>
    </div>

I did my research online, but the syntax seems right for adding an attribute. Any help is appreciated

Upvotes: 0

Views: 842

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116982

Try adding method="html" to the xsl:output element.

Upvotes: 2

Related Questions