XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Shane McRobertsSubject: Tags not getting closed when generating HTML from XSLT
Author: Shane McRoberts
Date: 27 Sep 2005 12:09 PM
I'm trying to generate HTML from XML using XSLT, and I'm having trouble doing the simplest thing. For some reason my tags aren't getting closed for empty tags.

This XSL file:
================
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
</head>
<body>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
=======================
generates this output file:
=======================
<html><head><META http-equiv="Content-Type" content="text/html"></head><body></body></html>
=======================

Note that the closing / is missing from the META tag. I've tried it with the built-in processor and with Saxon (I ran into this on a 2.0 stylesheet, but it doesn't seem to matter). If you try inserting a <link rel="stylesheet"/> element, the same thing happens. In fact none of my empty tags are terminated.

What am I doing wrong?

Thanks,

Shane


Documenttest(1).xslt
sample xslt with link element

Postnext
Alberto MassariSubject: Tags not getting closed when generating HTML from XSLT
Author: Alberto Massari
Date: 27 Sep 2005 03:01 PM
Hi Shane,
your stylesheet is missing the xsl:output instruction, so it is assumed to generate an HTML page (because the root node is <html>).
According to the XSLT specs, "the html output method should not output an end-tag for empty elements. For HTML 4.0, the empty elements are area, base, basefont, br, col, frame, hr, img, input, isindex, link, meta and param. For example, an element written as <br/> or <br></br> in the stylesheet should be output as <br>."
If you want the XSLT to generate well-formed XML you should add the instruction <xsl:output method="xml"/> right after the <xsl:stylesheet> instruction.

Hope this helps,
Alberto

Postnext
Shane McRobertsSubject: Tags not getting closed when generating HTML from XSLT
Author: Shane McRoberts
Date: 28 Sep 2005 12:30 AM
Thanks Alberto. It *does* work if I use method="xml", but I don't understand why it doesn't work with method="xhtml" (that's what I originally started with before scaling back to try to narrow the problem). It's not xhtml if it's not valid or well-formed xml, right?

Cheers,

Shane

Postnext
Shane McRobertsSubject: Tags not getting closed when generating HTML from XSLT
Author: Shane McRoberts
Date: 28 Sep 2005 12:37 AM
One other side note. Isn't it weird that output method=xhtml causes the processor to emit a META tag rather than meta?

Postnext
Ivan PedruzziSubject: Tags not getting closed when generating HTML from XSLT
Author: Ivan Pedruzzi
Date: 28 Sep 2005 12:48 AM
xhtml method is only supported by XSLT 2.0.

XSLT 1.0 supports text, xml or html


Ivan Pedruzzi
Stylus Studio Team

Postnext
Shane McRobertsSubject: Tags not getting closed when generating HTML from XSLT
Author: Shane McRoberts
Date: 28 Sep 2005 05:23 PM
Originally Posted: 28 Sep 2005 04:28 PM
>xhtml method is only supported<br> >by XSLT 2.0.<br> <br> Yes, I realize that. And when I use it I get the same results--open tags and upper case META. If simply changing the "1.0" to "2.0" and using Saxon 8.4 isn't sufficient to make the processor use XSLT 2.0, then that might be part of my problem.

Postnext
Tony LavinioSubject: Tags not getting closed when generating HTML from XSLT
Author: Tony Lavinio
Date: 12 Oct 2005 12:17 AM
We have identified the trouble with the XSLT 2.0 xhtml output method.
The next release will resolve this.

Posttop
Shane McRobertsSubject: Tags not getting closed when generating HTML from XSLT
Author: Shane McRoberts
Date: 21 Oct 2005 02:45 PM
Originally Posted: 21 Oct 2005 12:23 PM
you're welcome

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.