xsl-list
[Top] [All Lists]

RE: Outputting closing-slash in XHTML tags

2003-03-30 14:53:19
From: Gan Uesli Starling [mailto:alias(_at_)starling(_dot_)us]
Sent: Sunday, March 30, 2003 2:04 PM
Subject: [xsl] Outputting closing-slash in XHTML tags

I have templates like so...

<xsl:template match="head">
   <head>
     <meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8"/>
     <xsl:apply-templates select="title"/>
     <meta name="author" content="Gan Uesli Starling"/>

   ...and so on...

</xsl:template>

...but the output looks like so...

<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <xsl:apply-templates select="title">
   <meta name="author" content="Gan Uesli Starling">

...such that the closing slashes are gone. So the XHTML will
not validate. I am using Xalan for this.

How may I fix that, please?

The most likely reason (without seeing your stylesheet) is that your
xsl:output element is set to method="html", which will serialize the result
tree as HTML.  Set your output to "xml" and you should get much closer to
your intended output, although you will run into problems with empty element
minimization (i.e., an empty <textarea> tag may be written as <textarea/>,
which plays havoc on most browsers).  Note that XHTML is not a native
processor output in XSLT 1.0, but will be in XSLT 2.0.

cheers,
b.

| brian martinez                              
brian(_dot_)martinez(_at_)trip(_dot_)com |
| lead gui programmer                                    303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

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



<Prev in Thread] Current Thread [Next in Thread>