Missing closing /link and /meta tags in output?

Here should go questions about transforming XML with XSLT and FOP.
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Missing closing /link and /meta tags in output?

Post 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. :cry:

Scott
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Missing closing /link and /meta tags in output?

Post by adrian »

Hello,

So how are you copying the HTML template to the output? What does the stylesheet(XSLT template) look like?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Missing closing /link and /meta tags in output?

Post 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="&#x2d;" string="-"/> <!-- hyphen -->
<xsl:output-character character="&#xae;" string="&reg;"/> <!-- registered trademark -->
<xsl:output-character character="&#xa0;" string="&nbsp;"/> <!-- non-breaking space -->
<xsl:output-character character="&#xb7;" string="&middot;"/> <!-- middle dot -->
<xsl:output-character character="&#xe9;" string="&eacute;"/> <!-- latin small letter 'e' with acute -->
<xsl:output-character character="&#xeb;" string="&euml;"/> <!-- latin small letter 'e' with acute diaeresis -->
<xsl:output-character character="&#xf6;" string="&ouml;"/> <!-- latin small letter 'o' with acute diaeresis -->
<xsl:output-character character="&#x2002;" string="&ensp;"/> <!-- en space -->
<xsl:output-character character="&#x2003;" string="&emsp;"/> <!-- em space -->
<xsl:output-character character="&#x2009;" string="&nbsp;"/> <!-- thin space -->
<xsl:output-character character="&#x2010;" string="-"/> <!-- hyphen -->
<xsl:output-character character="&#x2013;" string="&ndash;"/> <!-- en dash -->
<xsl:output-character character="&#x2014;" string="&mdash;"/> <!-- em dash -->
<xsl:output-character character="&#x2105;" string="&incare;"/> <!-- care of symbol -->
<xsl:output-character character="&#x2018;" string="&lsquo;"/> <!-- single opening(left) quote -->
<xsl:output-character character="&#x2019;" string="&rsquo;"/> <!-- single closing(right) quote -->
<xsl:output-character character="&#x201c;" string="&ldquo;"/> <!-- double opening(left) quote -->
<xsl:output-character character="&#x201d;" string="&rdquo;"/> <!-- 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
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Missing closing /link and /meta tags in output?

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Missing closing /link and /meta tags in output?

Post 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
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Missing closing /link and /meta tags in output?

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Missing closing /link and /meta tags in output?

Post 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

Code: Select all

 <xsl:output method="xhtml"/> 
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
sderrick
Posts: 264
Joined: Sat Jul 10, 2010 4:03 pm

Re: Missing closing /link and /meta tags in output?

Post by sderrick »

Oooppss!!

Disregard, pilot error...

Working now as expected....

thanks,

Scott
Post Reply