Do you have a link to the W3C discussion document and recommendation?
I have found a link re namespaces in general pertaining mostly
to elements and attributes but nothing specific to QName attribute values. Here
is my link:
http://www.w3.org/TR/xml-names/#scoping-defaulting
Thanks for your reply.
Nader
From: Richard Jacob
[mailto:richard.jacob@de.ibm.com]
Sent: Wednesday, December 09, 2009 6:08 AM
To: Nader Oteifa
Cc: wsrp-interop@lists.oasis-open.org
Subject: RE: [wsrp-interop] Empty value for XMLNS
In
your example the Value for Qname has no namespace attached.
Attributes do
not pick up the default namespace or the element's namespace.
I recall
sending out a W3C discussion document about that and a recommendation to the
list but can't find it any more. The OASIS search doesn't help me very well
here.
Mit
freundlichen Grüßen / Kind regards
|
|
|
|
|
|
|
|
|
Richard
Jacob
|
|
|
|
|
|
|
|
|
Team Lead Portal Standards & WCM development
WSRP Standardization Lead
|
|
|
IBM Software Group, WPLC
|
|
|
WSS Websphere Portal Foundation Development 1
|
|
|
|
|
|
Phone:
|
+49-7031-16-3469
|
IBM Deutschland Research & Development
|
|
|
|
E-Mail:
|
richard.jacob@de.ibm.com
|
Schoenaicher Str. 220
|
|
|
|
|
71032 Boeblingen
|
|
|
|
|
Germany
|
|
|
|
|
|
IBM Deutschland Research & Development GmbH / Vorsitzender
des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
HRB 243294
|
|
|
From:
|
"Nader
Oteifa" <nader2@netunitysoftware.com>
|
To:
|
<wsrp-interop@lists.oasis-open.org>
|
Date:
|
12/09/2009
06:39 AM
|
Subject:
|
RE:
[wsrp-interop] Empty value for XMLNS
|
I
recalled the problem with XMLNS=”” in .NET. The problem has to do when
use a QName for an attribute value.
Take
the following XML:
<?xml
version="1.0" encoding="IBM437"?>
<b1:ComplexType QName="LocalName"
xmlns:b1="urn:Namespace" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<b1:Int>10</b1:Int>
<b1:String>A description</b1:String>
</b1:ComplexType>
What
should the namespace for the QName attribute *value* be? .NET
reports “” for the namespace when I de-serialize the above XML to a .NET class
instance. However, when I take the same class instance and serialize it,
it produces the following XML:
<?xml
version="1.0" encoding="IBM437"?>
<ComplexType
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
QName="LocalName" xmlns="urn:Namespace">
<Int>10</Int>
<String>A description</String>
</ComplexType>
When
this XML is de-serialized for the same class, the namespace for the QName value
is “urn:Namespace”. I’m assuming this is a bug in .NET given that
de-serializing, serializing and then de-serializing once more is producing
different results. I have not found a way to force .NET to emit XMLNS=””
for a QName attribute value specifying an “” namespace value. It would
be interesting to see what Java does.
I’m
not totally sure of all of the interop ramifications because I’m not sure how
Java serializes the above XML and the resulting namespaces. It also
depends on what the W3C XML namespace rules are for QName attribute values
which I need to look into further.
Here
is the code in C# I used for those interested in trying the same thing in Java:
[XmlRoot(Namespace="urn:Namespace")]
public
class ComplexType
{
public int Int = 10;
public string String =
"String Value";
[XmlAttribute]
public XmlQualifiedName QName
= new XmlQualifiedName("LocalName", "");
}
class
Program
{
static void Main(string[]
args)
{
//Build XML and emit to console
System.Text.StringBuilder sb1 = new
StringBuilder();
sb1.AppendLine("<?xml
version=\"1.0\" encoding=\"IBM437\"?>");
sb1.AppendLine("<b1:ComplexType
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
QName=\"LocalName\" xmlns:b1=\"urn:Namespace\"
xmlns=\"\">");
sb1.AppendLine("
<b1:Int>10</b1:Int>");
sb1.AppendLine("
<b1:String>A description</b1:String>");
sb1.AppendLine("</b1:ComplexType>");
Console.WriteLine(sb1.ToString());
//Deserialize and output QName value namespace
XmlSerializer serializer = new
XmlSerializer(typeof(ComplexType));
ComplexType complexInstance =
serializer.Deserialize(new StringReader(sb1.ToString())) as ComplexType;
Console.WriteLine();
Console.WriteLine("QName namespace = [" +
complexInstance.QName.Namespace + "]"); //results in “”
//Serialize to string buffer and emit to
console
System.Text.StringBuilder sb2 = new
StringBuilder();
System.IO.StringWriter writer = new
StringWriter(sb2);
serializer.Serialize(writer, complexInstance);
Console.WriteLine();
Console.WriteLine();
serializer.Serialize(Console.Out, complexInstance);
//Deserialize and output QName value namespace once
more
complexInstance = serializer.Deserialize(new
StringReader(sb2.ToString())) as ComplexType;
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("QName namespace = [" +
complexInstance.QName.Namespace + "]"); //results in
“urn:Namespace”
string s = Console.ReadLine();
}
}
Nader
From: Nader Oteifa [mailto:nader2@netunitysoftware.com]
Sent: Thursday, December 03, 2009 12:55 PM
To: wsrp-interop@lists.oasis-open.org
Subject: [wsrp-interop] Empty value for XMLNS
It appears
that there is not a issue with specifying an empty value for the XMLNS in .NET
for XML serialization in the latest version of .NET. However, it may have
been an issue with prior versions so I will do some more digging.
Nader