|
|
Rank: Newbie
Joined: 7/14/2009 Posts: 5 Location: Montreal, Canada
|
We are using XSLT to transform an XML document into HTML.
this is the beginning of the stylesheet:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="#all" xmlns:mds="http://www.hospitalis.ca/PTM/mds">
<xsl:variable name="DocID" select="/mds:DocumentMDS/@Id"/> <xsl:include href="target_Transform.xslt"/> <xsl:include href="HTML_Transform_Common.xslt"/> <xsl:output method="html" indent="yes" encoding="UTF-8" use-character-maps="spaces" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> <xsl:character-map name="spaces"> <xsl:output-character character=" " string="&nbsp;"/> </xsl:character-map> <xsl:import-schema schema-location="../Schemas/PTM_Document_MDS.xsd"/>
<xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
the resulting HTML looks like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="fr" lang="fr"> <head>....
The xml:lang and lang attributes are correctly output in the HTML. The xmlns declaration disappears. I have played around with the stylesheet declaration, but to no avail. Does anyone know why this is happening? Thanks in advance...
|
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
From XML point of view xmlns is NOT an attribute - it is a namespace declaration and it only impacts the way how elements are processed but kind of does not exist as such.
Therefore you will have to probably explicitly create xmlns in your output by xsl:attribute
|
|
Rank: Advanced Member
Joined: 6/10/2007 Posts: 36
|
I think what you see is a bug. On the other hand if you want XHTML output then xsl:output method="xhtml" seems more appropriate anyway and if I use that then AltovaXML tools emits the namespace declaration. So that might be a way to solve your problem without any disadvantage.
|
|
Rank: Newbie
Joined: 7/14/2009 Posts: 5 Location: Montreal, Canada
|
vlad wrote:From XML point of view xmlns is NOT an attribute - it is a namespace declaration and it only impacts the way how elements are processed but kind of does not exist as such.
Therefore you will have to probably explicitly create xmlns in your output by xsl:attribute
Thanks Vlad. I tried, but I get an "Illegal attribute name" error. I'll post a solution when I find one...
|
|
|
guest |