Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT not closing my div tags properly

Status
Not open for further replies.

abienz

Programmer
Aug 13, 2001
53
0
0
GB
Hi there,

I've got a strange problem where when I perform a transformation on my XML to an XHTML document using an XSL file certain tags are closed incorrectly.

for example I've got this line in my XSL
Code:
<xsl:template match="/">
  <xsl:text disable-output-escaping="yes">
    <div id="topBar">
    </div>
    <xsl:apply-templates />
  </xsl:template>
When I run the transformation in my code I instead of getting
Code:
<div id="topBar">
</div>
I get
Code:
<div id="topBar"/>
I've noticed that this also happens with textareas, has anyone else noticed this, and or found a work around?

Any advice or guidance would be much appreciated.

Cheers,

Blaise
 
Blaise,

What xsl processor are you using? It can be different among processors. Some have a setting regarding empty elements.

Is there a particular reason you want/need <div id="topBar"></div>?

You can try one of these with your processor:

Code:
<xsl:element name="div">
  <xsl:attribute name="id">topBar</xsl:attribute>
  <xsl:text/>
</xsl:element>

Code:
<xsl:element name="div">
  <xsl:attribute name="id">topBar</xsl:attribute>
  <xsl:comment> empty <xsl:comment>
</xsl:element>

Code:
<xsl:text disable-output-escaping="yes"><![CDATA[<div id="topBar"></div>]]></xsl:text>

- mb
 
What is your output type? With an output type of xml, the translation engine makes empty tags out of <div id="topBar"></div>. Have you tried changing the output type to html instead?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top