Page 1 of 1
Missing closing /link and /meta tags in output?
Posted: Mon Apr 25, 2011 8:25 pm
by sderrick
I am generating xhtml files, my xsl file has output defined as so:
Code: Select all
<xsl:output method="xhtml" name="xhtml"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"/>
The main template has this html code with a meta tag and link tag, both with closing </tags>
Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;"> </meta>
<title> <xsl:value-of select="$title"></xsl:value-of></title>
<link rel="stylesheet" href="csps.css" type="text/css"> </link>
</head>
The output is
Code: Select all
<html xmlns:num="http://csps/numbers">
<head>
<meta http-equiv="Content-Type" content="text/html; >
<title>The Title</title>
<link rel="stylesheet" href="csps.css" type="text/css" >
</head>
notice the missing closing meta and link tags are gone.
I've tried output types of xml, html and xhtml, nothing changes. Its killing me because I need to do post processing on the html and the saxon parser barfs out an error about the missing closing link tag.
Scott
Re: Missing closing /link and /meta tags in output?
Posted: Mon Apr 25, 2011 9:43 pm
by adrian
Hello,
So how are you copying the HTML template to the output? What does the stylesheet(XSLT template) look like?
Regards,
Adrian
Re: Missing closing /link and /meta tags in output?
Posted: Mon Apr 25, 2011 9:57 pm
by sderrick
Adrian,
The html post processing script. At this point its just a character map. I will be adding a few other things later.
Here its..
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs xd"
version="2.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Apr 17, 2011</xd:p>
<xd:p><xd:b>Author:</xd:b> scott derrick</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>
<xsl:output method="html"
use-character-maps="cm1"/>
<xsl:character-map name="cm1">
<xsl:output-character character="-" string="-"/> <!-- hyphen -->
<xsl:output-character character="®" string="®"/> <!-- registered trademark -->
<xsl:output-character character=" " string=" "/> <!-- non-breaking space -->
<xsl:output-character character="·" string="·"/> <!-- middle dot -->
<xsl:output-character character="é" string="é"/> <!-- latin small letter 'e' with acute -->
<xsl:output-character character="ë" string="ë"/> <!-- latin small letter 'e' with acute diaeresis -->
<xsl:output-character character="ö" string="ö"/> <!-- latin small letter 'o' with acute diaeresis -->
<xsl:output-character character=" " string=" "/> <!-- en space -->
<xsl:output-character character=" " string=" "/> <!-- em space -->
<xsl:output-character character=" " string=" "/> <!-- thin space -->
<xsl:output-character character="‐" string="-"/> <!-- hyphen -->
<xsl:output-character character="–" string="–"/> <!-- en dash -->
<xsl:output-character character="—" string="—"/> <!-- em dash -->
<xsl:output-character character="℅" string="℅"/> <!-- care of symbol -->
<xsl:output-character character="‘" string="‘"/> <!-- single opening(left) quote -->
<xsl:output-character character="’" string="’"/> <!-- single closing(right) quote -->
<xsl:output-character character="“" string="“"/> <!-- double opening(left) quote -->
<xsl:output-character character="”" string="”"/> <!-- double closing(right) quote -->
</xsl:character-map>
<!-- IdentityTransform -->
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<xsl:message>"foo"</xsl:message>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I think this is what you were asking for?
Scott
Re: Missing closing /link and /meta tags in output?
Posted: Tue Apr 26, 2011 11:44 am
by adrian
Hi,
No, I was asking for the XHTML generation stylesheet. I understood that you have two steps: XHTML generation and HTML post-processing.
The HTML post processing script will fail if its input is not XML(XHTML) and in your case it's HTML(missing end tags).
But now I see where the problem is. In the XHTML generation stylehseet you are using a named output definition(<xsl:output method="xhtml" name="xhtml"). This is only used when you specify the format attribute for xsl:result-document.
http://www.w3.org/TR/xslt20/#element-output
What you need is an unnamed output definition.
Code: Select all
<xsl:output method="xhtml"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"/>
Regards,
Adrian
Re: Missing closing /link and /meta tags in output?
Posted: Tue Apr 26, 2011 4:33 pm
by sderrick
That did it!
I am using xsl:result-document to split the result document into pieces. I call that function like this
<xsl:result-document href="{$filename}">
.....
</xsl:result-document>
and not pass in a named output. Any problems with that?
Scott
Re: Missing closing /link and /meta tags in output?
Posted: Tue Apr 26, 2011 5:00 pm
by adrian
No problems, it's just that the named xsl:output is pointless and somewhat misleading if it's not referred from anywhere. It already gave you the false impression that it controlled the output.
I would recommend removing it if it's unused.
Regards,
Adrian
Re: Missing closing /link and /meta tags in output?
Posted: Thu Apr 28, 2011 6:47 pm
by sderrick
I spoke too soon!
If I remove the name attribute from
Code: Select all
<xsl:output name="csps-xhtml" method="xhtml"/>
like so
and call result-document without a format="csps-xhtml" attribute like so
Code: Select all
<xsl:result-document href="{$filename}" >
the resulting documents are not well formed xhtml
If I name the output like so
Code: Select all
<xsl:output name="csps-xhtml" method="xhtml"/>
and call result-document like so
Code: Select all
<xsl:result-document href="{$filename}" format="csps-xhtml">
the resulting multiple documents are well formed but the generation of single documents(not using result-document) with this style sheet is now broken like the multiple document output was!
I tried this call
Code: Select all
<xsl:result-document format="csps-xhtml"/>
in the non result-document generation template but I get this error
Severity: fatal
Description: Cannot write an implicit result document if an explicit result document has been written to the same URI: file:/home/scott/workspace/books_changes2/build/ebook/sh-tei.html
WHy does using the name attribute on the <output tag break things so?
Can I use result-document and coerce it to generate xhtml without using the format attribute?
Scott
Re: Missing closing /link and /meta tags in output?
Posted: Thu Apr 28, 2011 7:25 pm
by sderrick
Oooppss!!
Disregard, pilot error...
Working now as expected....
thanks,
Scott