xsl-list
[Top] [All Lists]

RE: self closing elements with attributes

2004-01-06 14:06:17
From: annirack(_at_)shaw(_dot_)ca [mailto:annirack(_at_)shaw(_dot_)ca]
Sent: Tuesday, January 06, 2004 1:22 PM
Subject: [xsl] self closing elements with attributes

I have a template like this:

<xsl:element name="foo">
<xsl:attribute name="bar">
some foo
</xsl:attribute>
</xsl:element>

I have also tried:

<foo>
<xsl:attribute name="bar">
some foo
</xsl:attribute>
</foo>

Both give the same result:

<foo bar="some foo">

Which is a problem since it does not close the tag.

Unless something is horribly broken in your XSLT processor, I believe you're
misreading your output.  If your output is set to XML (the default if you
don't specify an xsl:output element), you should get a minimized empty
element:

<foo bar="some foo" /> (note the slash before the greater-than bracket)

Saxon omits the space between the attribute value and the slash:

<foo bar="some foo"/>

Either result is valid XML.

cheers,
b.

| brian martinez                           
brian(_dot_)martinez(_at_)cendant(_dot_)com |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

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