[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Namespaces and the identity transform

Subject: Namespaces and the identity transform
From: "James Carlyle" <james.carlyle@xxxxxxxxxxxx>
Date: Thu, 17 Oct 2002 18:01:16 +0100
james carlyle
I have a simple document:
<?xml version="1.0"?>
	<div id="header">

I want to produce a strict xhtml document and use the following stylesheet:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
<xsl:output method="xml"
	doctype-public="-//W3C//DTD XHTML 1 Strict//EN"

<xsl:template match="@*|node()">
		<xsl:apply-templates select="@*|node()"/>

<xsl:template match="doc">
		<xsl:apply-templates select="@*|node()"/>

What I get is
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
	<body xmlns="">
		<div id="header"><h1>TakePart</h1></div>

This is correct, since the html output element has the default namespace,
whereas the body element outputted through the identity transform has no
namespace.  I get the null namespace on any elements passing through the
identity transform.

How can I design an identity transform that applies the default namespace to
the output?  I prefer not to have to restructure my input, and I want all
output nodes to use the strict xhtml namespace.  I substituted the above
identity transform with the following and this seems to produce the correct
output, but is this the most efficient way of doing it?

<xsl:template match="*">
	<xsl:element name="{name()}">
		<xsl:apply-templates select="@*|node()"/>

<xsl:template match="@*">
	<xsl:attribute name="{name()}">
		<xsl:value-of select="."/>

Many thanks,

James Carlyle

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.