IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Missing xmlns attribute in <html> tag Options · View
toine
Posted: Thursday, September 17, 2009 4:16:37 PM
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="&#160;" string="&amp;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...
vlad
Posted: Friday, September 18, 2009 9:44:25 AM
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
Martin Honnen
Posted: Friday, September 18, 2009 10:00:20 AM
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.
toine
Posted: Friday, September 18, 2009 7:13:03 PM
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...
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.