Writing void tags in HTML5
Writing void tags in HTML5
Hi all,
I'm trying to generate HTML5 (oXygen Developer 13.2, Saxon-EE 9.3.0.5), and my transform is turning void tags into end-tag style, which breaks things like <link/> and <meta/>. Is there an elegant way to get it to stop doing that, or am i stuck with something like to hide these tags from whatever postprocessing is happening?
(In case this is relevant, i'm using result-document method="xhtml", and the trick to get the doctype right.)
TIA,
--alex.
I'm trying to generate HTML5 (oXygen Developer 13.2, Saxon-EE 9.3.0.5), and my transform is turning void tags into end-tag style, which breaks things like <link/> and <meta/>. Is there an elegant way to get it to stop doing that, or am i stuck with something like
Code: Select all
<xsl:text disable-output-escaping='yes'>
<link rel="stylesheet" type="text/css" href="</xsl:text>
<xsl:value-of select="."/>
<xsl:text disable-output-escaping='yes'>" /></xsl:text>
(In case this is relevant, i'm using result-document method="xhtml", and the
Code: Select all
<xsl:text disable-output-escaping='yes'><!DOCTYPE html>
</xsl:text>
TIA,
--alex.
Re: Writing void tags in HTML5
OK, looks like the easiest way to solve this is xsl:result-document method="xml", which turns off Trying-To-Be-Helpful Mode and gives you what you'd expect. So, this works:
...and i'm a happy boy.
Code: Select all
<xsl:template match="page">
<xsl:result-document method="xml" href="{@href}" omit-xml-declaration="yes" indent="yes">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html>
</xsl:text>
<html> and so on... </html>
</xsl:result-document>
</xsl:template>
<xsl:template match="stylesheet-file>
<link rel="stylesheet" type="text/css" href="{.}" />
</xsl:template>
<xsl:template match="script-file>
<script src="{.}"><xsl:text> </xsl:text></script>
</xsl:template>
Re: Writing void tags in HTML5
Hi Alex,
I think that your first approach was the correct one.
But in the stylesheet you should have set the namespace on the parent <html> element like:
You can also add this additional attribute on the <xsl:stylesheet>:
xpath-default-namespace="http://www.w3.org/1999/xhtml"
in order to keep XPath expressions in the stylesheet unprefixed and simple.
Regards,
Radu
I think that your first approach was the correct one.
But in the stylesheet you should have set the namespace on the parent <html> element like:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml">.....
xpath-default-namespace="http://www.w3.org/1999/xhtml"
in order to keep XPath expressions in the stylesheet unprefixed and simple.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Re: Writing void tags in HTML5
Tried that, thanks, but made no difference -- still resulted in stray end tags for <link> and <meta>. Fortunately, method="xml" is working fine.
Is there any documentation around on the ugly details of method="xhtml"? My XSLT books are pretty reticent on the subject, and it's always seemed like a sort of mysterious black box to me. --alex.
Is there any documentation around on the ugly details of method="xhtml"? My XSLT books are pretty reticent on the subject, and it's always seemed like a sort of mysterious black box to me. --alex.
Re: Writing void tags in HTML5
Hi Alex,
The stylesheet I tested with was like this:
and it produced in the result document the empty <meta> and <link> tags in the correct collapsed form.
I think that it is best for you to make small stylesheet examples and see how the behavior changes when the output method gets changed or when the HTML elements which are output do not have a namespace set to them.
Basically when the XSLT processor outputs in XHTML mode it should respect the XHTML compatibility guidelines:
http://www.w3.org/TR/xhtml1/guidelines.html
Regards,
Radu
The stylesheet I tested with was like this:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<xsl:result-document method="xhtml" href="test.html" omit-xml-declaration="yes" indent="yes">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html>
</xsl:text>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="abc"/>
<link rel="stylesheet" type="text/css" href="a.b" />
</head>
<body>
<br/>
</body>
</html>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
I think that it is best for you to make small stylesheet examples and see how the behavior changes when the output method gets changed or when the HTML elements which are output do not have a namespace set to them.
Basically when the XSLT processor outputs in XHTML mode it should respect the XHTML compatibility guidelines:
http://www.w3.org/TR/xhtml1/guidelines.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service