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

Re: Why doesn't <xsl:copy> copy xmlns=""?

Subject: Re: Why doesn't <xsl:copy> copy xmlns=""?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 17 Nov 2012 08:54:21 -0500
Re:  Why doesn't <xsl:copy> copy xmlns=""?
At 2012-11-17 13:39 +0000, you wrote:
I want to do an identity transform of this:
----------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                       targetNamespace="http://www.bar.com"
                        xmlns:bar="http://www.bar.com"
                        xmlns=""
                        elementFormDefault="qualified">

...

</xs:schema>
----------------------------------------------------------------------------

Notice the default namespace declaration, xmlns=""

I see it, but it is redundant. That isn't a namespace declaration, it is a namespace "undeclaration". This concept exists in namespaces 1.0 but the verb to "undeclare" is actually worded in namespaces 1.1:


http://www.w3.org/TR/2006/REC-xml-names11-20060816/#changes

So in XML 1.0 an "undeclaration" *removes* a namespace declaration for the default namespace, it does not add an explicit declaration of nothing.

Here is the output from transforming the <xs:schema> with my code:
----------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                       targetNamespace="http://www.bar.com"
                        xmlns:bar="http://www.bar.com"
                        elementFormDefault="qualified">

And because the default namespace already is not declared, it is identical (from an information set perspective) to your original.


What happened to the default namespace declaration?

The default namespace "undeclaration" wasn't needed and so was ignored.


Questions:

1. Why is my code not copying over the default namespace declaration?

Because xmlns="" is not a namespace declaration. It is a directive to remove the default namespace declaration from the information set.


2. What change can I make to my code to ensure that it copies over the default namespace declaration?

You can already be assured that there is no declaration for the default namespace because the processor would have undeclared it if it were necessary. Thus, you can ensure that the information is correct (not that the declarations are the same) because of the namespace fix-up processes of XML serialization.


I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.