Ask a Question related to ASP.NET Web Services, Design and Development.
-
MattL #1
Serialization across 'like' attribute names
This serialization error appears to be not correct...
When a class defined in a specific namespace,e.g., "urn:A" and two
attributes which have the same local name, e.g., "Id", with one one attribute
defined as Qualified and in the namespace "urn:A" and the other attribute is
defined as Unqualified cannot be serialized.
The problem (as it appears to me) is that an unqualifed attribute does not
inherit a default namespace (per Namespaces in XML) and this is the error
thrown by the serializer, i.e., that both "Id" attributes appear in the same
namespace.
Thoughts!
-MattL
MattL Guest
-
#39635 [NEW]: Better control for serialization (keyword for permit property serialization)
From: t dot prochazka at centrum dot cz Operating system: all PHP version: 5CVS-2006-11-26 (CVS) PHP Bug Type: Feature/Change... -
Help getting attribute names from xml
Can anyone help me figure out how to retrieve the attribute names from an xmlNode type variable? I have an xmlNode (student). student has 3... -
Retrieving XML attribute using XML::XPath::Node::Attribute
Hi I am trying to retrieve an attribute of a particular node from my XML using "XML::XPath::Node::Attribute", but couldn't come across on how to... -
XML attribute for serialization
Hi, I use XML in a webservice that looks like this: <address> <addressline>aaaa</addressline> <addressline>aaaa</addressline> <zip></zip>... -
avoiding XML serialization, different WSDL generation, soap serialization
Hello, I think my problem is interesting for most of developers who wish to exchange actual business entities with webservices, not just xml... -
MattL #2
RE: Serialization across 'like' attribute names
To clarify myself:
The unqualified attribute SHOULD NOT inherit the default namespace and it
appears that the serializer "puts" it in the default namespace.
-MattL
"MattL" wrote:
> This serialization error appears to be not correct...
>
> When a class defined in a specific namespace,e.g., "urn:A" and two
> attributes which have the same local name, e.g., "Id", with one one attribute
> defined as Qualified and in the namespace "urn:A" and the other attribute is
> defined as Unqualified cannot be serialized.
>
> The problem (as it appears to me) is that an unqualifed attribute does not
> inherit a default namespace (per Namespaces in XML) and this is the error
> thrown by the serializer, i.e., that both "Id" attributes appear in the same
> namespace.
>
> Thoughts!
>
> -MattL
>
>
>MattL Guest
-
Dilip Krishnan #3
RE: Serialization across 'like' attribute names
Hello MattL,
That is the default behaviour. If you done specify the namespace it resolves
to the default namespace.. am I missing something?
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
[url]http://www.geniant.com[/url]
> To clarify myself: The unqualified attribute SHOULD NOT inherit the
> default namespace and it appears that the serializer "puts" it in the
> default namespace.
>
> -MattL
>
> "MattL" wrote:
>>> This serialization error appears to be not correct...
>>
>> When a class defined in a specific namespace,e.g., "urn:A" and two
>> attributes which have the same local name, e.g., "Id", with one one
>> attribute defined as Qualified and in the namespace "urn:A" and the
>> other attribute is defined as Unqualified cannot be serialized.
>>
>> The problem (as it appears to me) is that an unqualifed attribute
>> does not inherit a default namespace (per Namespaces in XML) and this
>> is the error thrown by the serializer, i.e., that both "Id"
>> attributes appear in the same namespace.
>>
>> Thoughts!
>>
>> -MattL
>>
Dilip Krishnan Guest
-
Dan Rogers #4
RE: Serialization across 'like' attribute names
Hi Matt,
Please send me the schema you wish to make classes for.
Thanks
Dan Rogers
Microsoft Corporation
--------------------microsoft.public.dotnet.framework.aspnet.webservic es:27099>Thread-Topic: Serialization across 'like' attribute names
>thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
>X-WBNR-Posting-Host: 208.223.183.27
>From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
>Subject: RE: Serialization across 'like' attribute names
>Date: Wed, 8 Dec 2004 14:41:03 -0800
>Lines: 26
>Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gblattribute>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>To clarify myself:
>The unqualified attribute SHOULD NOT inherit the default namespace and it
>appears that the serializer "puts" it in the default namespace.
>
>-MattL
>
>"MattL" wrote:
>>> This serialization error appears to be not correct...
>>
>> When a class defined in a specific namespace,e.g., "urn:A" and two
>> attributes which have the same local name, e.g., "Id", with one oneattribute is>> defined as Qualified and in the namespace "urn:A" and the othernot>> defined as Unqualified cannot be serialized.
>>
>> The problem (as it appears to me) is that an unqualifed attribute doeserror>> inherit a default namespace (per Namespaces in XML) and this is thesame>> thrown by the serializer, i.e., that both "Id" attributes appear in the>>> namespace.
>>
>> Thoughts!
>>
>> -MattL
>>
>>
>>Dan Rogers Guest
-
MattL #5
RE: Serialization across 'like' attribute names
Example
if this example the namespaces should be
{urn:A}Root
{""}Id
{urn:A}Id
[XmlRoot(Namespace="urn:A")]
[XmlType(Namespace="urn:A")]
public class Root
{
public class Root()
{
_xmlns.Add("x","urn:A");
}
private string _id;
private string _otherId;
private XmlSerializerNamespaces _xmlns = new XmlSerializerNamespaces();
[XmlNamespaceDeclarations()]
public XmlSerializerNamespaces Xmlns
{
get{return _xmlns;}
set{_xmlns = value;}
}
[XmlAttribute(Form=XmlSchemaForm.Unqualified)]
public string Id
{
get{return _id;}
set{_id = value;}
}
[XmlAttribute("Id", Namespace="urn:A", Form=XmlSchemaForm.Qualified)]
public string OtherId
{
get{return _otherId;}
set{_otherId = value;}
}
}
"Dan Rogers" wrote:
> Hi Matt,
>
> Please send me the schema you wish to make classes for.
>
> Thanks
> Dan Rogers
> Microsoft Corporation
> --------------------> microsoft.public.dotnet.framework.aspnet.webservic es:27099> >Thread-Topic: Serialization across 'like' attribute names
> >thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
> >X-WBNR-Posting-Host: 208.223.183.27
> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> >Subject: RE: Serialization across 'like' attribute names
> >Date: Wed, 8 Dec 2004 14:41:03 -0800
> >Lines: 26
> >Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl> attribute> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >
> >To clarify myself:
> >The unqualified attribute SHOULD NOT inherit the default namespace and it
> >appears that the serializer "puts" it in the default namespace.
> >
> >-MattL
> >
> >"MattL" wrote:
> >> >> This serialization error appears to be not correct...
> >>
> >> When a class defined in a specific namespace,e.g., "urn:A" and two
> >> attributes which have the same local name, e.g., "Id", with one one> attribute is> >> defined as Qualified and in the namespace "urn:A" and the other> not> >> defined as Unqualified cannot be serialized.
> >>
> >> The problem (as it appears to me) is that an unqualifed attribute does> error> >> inherit a default namespace (per Namespaces in XML) and this is the> same> >> thrown by the serializer, i.e., that both "Id" attributes appear in the>> >> >> namespace.
> >>
> >> Thoughts!
> >>
> >> -MattL
> >>
> >>
> >>
>MattL Guest
-
Dan Rogers #6
RE: Serialization across 'like' attribute names
Hi Matt,
I think you are saying (ignoring your implementation) that you want to get
the following XML:
<Root xmlns="urn:A">
<id>namespaced value</id>
<id xmlns="">non-namespaced value</id>
</Root>
Is this correct? From a schema perspective, this is nearly impossible to
describe, so best practice would seem to dicate not doing this. However,
since it is to a degree, just a matter of what you can serialize, I think
it's possible to make this happen.
If so, try this:
[XmlRoot("urn:A")]
public class Root
{
[XmlElement(ElementName="id", Namespace="urn:A", DataType="string")]
public string firstId;
[XmlElement(ElementName="id", Form=XmlSchemaForm.Unqualified,
DataType="string")]
public string secondId;
public Root()
{
firstId = "namespaced value";
secondId = "non-namespaced value";
}
}
Hope this helps,
Dan Rogers
Microsoft Corporation
--------------------<2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>>Thread-Topic: Serialization across 'like' attribute names
>thread-index: AcTkVqqruD3zK+TeQkiNrEeE6lyK7Q==
>X-WBNR-Posting-Host: 208.223.183.28
>From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
<qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>microsoft.public.dotnet.framework.aspnet.webservic es:27278>Subject: RE: Serialization across 'like' attribute names
>Date: Fri, 17 Dec 2004 08:37:15 -0800
>Lines: 112
>Message-ID: <4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gblit>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>Example
>
>if this example the namespaces should be
>{urn:A}Root
>{""}Id
>{urn:A}Id
>
>
>
>[XmlRoot(Namespace="urn:A")]
>[XmlType(Namespace="urn:A")]
>public class Root
>{
> public class Root()
> {
> _xmlns.Add("x","urn:A");
> }
>
> private string _id;
> private string _otherId;
> private XmlSerializerNamespaces _xmlns = new XmlSerializerNamespaces();
>
> [XmlNamespaceDeclarations()]
> public XmlSerializerNamespaces Xmlns
> {
> get{return _xmlns;}
> set{_xmlns = value;}
> }
> [XmlAttribute(Form=XmlSchemaForm.Unqualified)]
> public string Id
> {
> get{return _id;}
> set{_id = value;}
> }
>
> [XmlAttribute("Id", Namespace="urn:A", Form=XmlSchemaForm.Qualified)]
> public string OtherId
> {
> get{return _otherId;}
> set{_otherId = value;}
> }
>}
>
>"Dan Rogers" wrote:
>>> Hi Matt,
>>
>> Please send me the schema you wish to make classes for.
>>
>> Thanks
>> Dan Rogers
>> Microsoft Corporation
>> -------------------->> microsoft.public.dotnet.framework.aspnet.webservic es:27099>> >Thread-Topic: Serialization across 'like' attribute names
>> >thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
>> >X-WBNR-Posting-Host: 208.223.183.27
>> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
>> >Subject: RE: Serialization across 'like' attribute names
>> >Date: Wed, 8 Dec 2004 14:41:03 -0800
>> >Lines: 26
>> >Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="Utf-8"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Content-Class: urn:content-classes:message
>> >Importance: normal
>> >Priority: normal
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>> >Xref: cpmsftngxa10.phx.gbl>> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>> >
>> >To clarify myself:
>> >The unqualified attribute SHOULD NOT inherit the default namespace anddoes>> attribute>> >appears that the serializer "puts" it in the default namespace.
>> >
>> >-MattL
>> >
>> >"MattL" wrote:
>> >
>> >> This serialization error appears to be not correct...
>> >>
>> >> When a class defined in a specific namespace,e.g., "urn:A" and two
>> >> attributes which have the same local name, e.g., "Id", with one one>> attribute is>> >> defined as Qualified and in the namespace "urn:A" and the other>> >> defined as Unqualified cannot be serialized.
>> >>
>> >> The problem (as it appears to me) is that an unqualifed attributethe>> not>> error>> >> inherit a default namespace (per Namespaces in XML) and this is the>> >> thrown by the serializer, i.e., that both "Id" attributes appear in>>> same>>>> >> namespace.
>> >>
>> >> Thoughts!
>> >>
>> >> -MattL
>> >>
>> >>
>> >>
>> >
>>Dan Rogers Guest
-
MattL #7
RE: Serialization across 'like' attribute names
Dan,
I apoligize, I should have been using [XmlAttribute] and not [XmlElement]
consider this XML
<x:root xmlns:x="urn:A">
<x:child Id="1" x:Id="2"/>
</x:root>
Now...two Ids exist. One is qualified as {""}Id and the other {urn:A}Id
The default namespace is xmlns="" not "urn:A". When you attempt to
serialize this you get a namespace collision in that the serializer believes
that {""}Id and {urn:A}Id belong to the same namespace, i.e., urn:A.
Sorry for the confusion.
-MattL
"Dan Rogers" wrote:
> Hi Matt,
> I think you are saying (ignoring your implementation) that you want to get
> the following XML:
>
> <Root xmlns="urn:A">
> <id>namespaced value</id>
> <id xmlns="">non-namespaced value</id>
> </Root>
>
> Is this correct? From a schema perspective, this is nearly impossible to
> describe, so best practice would seem to dicate not doing this. However,
> since it is to a degree, just a matter of what you can serialize, I think
> it's possible to make this happen.
>
> If so, try this:
>
> [XmlRoot("urn:A")]
> public class Root
> {
> [XmlElement(ElementName="id", Namespace="urn:A", DataType="string")]
> public string firstId;
>
> [XmlElement(ElementName="id", Form=XmlSchemaForm.Unqualified,
> DataType="string")]
> public string secondId;
>
> public Root()
> {
> firstId = "namespaced value";
> secondId = "non-namespaced value";
> }
> }
>
> Hope this helps,
>
> Dan Rogers
> Microsoft Corporation
>
> --------------------> <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>> >Thread-Topic: Serialization across 'like' attribute names
> >thread-index: AcTkVqqruD3zK+TeQkiNrEeE6lyK7Q==
> >X-WBNR-Posting-Host: 208.223.183.28
> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> <qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>> microsoft.public.dotnet.framework.aspnet.webservic es:27278> >Subject: RE: Serialization across 'like' attribute names
> >Date: Fri, 17 Dec 2004 08:37:15 -0800
> >Lines: 112
> >Message-ID: <4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl> it> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >
> >Example
> >
> >if this example the namespaces should be
> >{urn:A}Root
> >{""}Id
> >{urn:A}Id
> >
> >
> >
> >[XmlRoot(Namespace="urn:A")]
> >[XmlType(Namespace="urn:A")]
> >public class Root
> >{
> > public class Root()
> > {
> > _xmlns.Add("x","urn:A");
> > }
> >
> > private string _id;
> > private string _otherId;
> > private XmlSerializerNamespaces _xmlns = new XmlSerializerNamespaces();
> >
> > [XmlNamespaceDeclarations()]
> > public XmlSerializerNamespaces Xmlns
> > {
> > get{return _xmlns;}
> > set{_xmlns = value;}
> > }
> > [XmlAttribute(Form=XmlSchemaForm.Unqualified)]
> > public string Id
> > {
> > get{return _id;}
> > set{_id = value;}
> > }
> >
> > [XmlAttribute("Id", Namespace="urn:A", Form=XmlSchemaForm.Qualified)]
> > public string OtherId
> > {
> > get{return _otherId;}
> > set{_otherId = value;}
> > }
> >}
> >
> >"Dan Rogers" wrote:
> >> >> Hi Matt,
> >>
> >> Please send me the schema you wish to make classes for.
> >>
> >> Thanks
> >> Dan Rogers
> >> Microsoft Corporation
> >> --------------------
> >> >Thread-Topic: Serialization across 'like' attribute names
> >> >thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
> >> >X-WBNR-Posting-Host: 208.223.183.27
> >> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> >> >Subject: RE: Serialization across 'like' attribute names
> >> >Date: Wed, 8 Dec 2004 14:41:03 -0800
> >> >Lines: 26
> >> >Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
> >> >MIME-Version: 1.0
> >> >Content-Type: text/plain;
> >> > charset="Utf-8"
> >> >Content-Transfer-Encoding: 7bit
> >> >X-Newsreader: Microsoft CDO for Windows 2000
> >> >Content-Class: urn:content-classes:message
> >> >Importance: normal
> >> >Priority: normal
> >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >> >Xref: cpmsftngxa10.phx.gbl
> >> microsoft.public.dotnet.framework.aspnet.webservic es:27099
> >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >
> >> >To clarify myself:
> >> >The unqualified attribute SHOULD NOT inherit the default namespace and> does> >> >appears that the serializer "puts" it in the default namespace.
> >> >
> >> >-MattL
> >> >
> >> >"MattL" wrote:
> >> >
> >> >> This serialization error appears to be not correct...
> >> >>
> >> >> When a class defined in a specific namespace,e.g., "urn:A" and two
> >> >> attributes which have the same local name, e.g., "Id", with one one
> >> attribute
> >> >> defined as Qualified and in the namespace "urn:A" and the other
> >> attribute is
> >> >> defined as Unqualified cannot be serialized.
> >> >>
> >> >> The problem (as it appears to me) is that an unqualifed attribute> the> >> not
> >> >> inherit a default namespace (per Namespaces in XML) and this is the
> >> error
> >> >> thrown by the serializer, i.e., that both "Id" attributes appear in>> >> >> same
> >> >> namespace.
> >> >>
> >> >> Thoughts!
> >> >>
> >> >> -MattL
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
>MattL Guest
-
Dan Rogers #8
RE: Serialization across 'like' attribute names
Hi Matt,
Yes, you're going to have lots of serialization issues if you try to do
this. Since the nill namespace is not addressible, and because the rules
of XML say that unqualified child attributes default to the namespace of
their parent element, it's at least debatable as to whether this particular
construct can even be described using a schema.
As a "did you try this" - I'd be shocked if it worked - but did you try
treating the nill namespace value "" as a string, and making it a qualified
attribute?
Dan
--------------------<2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>>Thread-Topic: Serialization across 'like' attribute names
>thread-index: AcTpyavCWD0KjUIjS4ith40Ppl1D9A==
>X-WBNR-Posting-Host: 208.223.183.28
>From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
<qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>
<4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
<NuQqO3u5EHA.3440@cpmsftngxa10.phx.gbl>microsoft.public.dotnet.framework.aspnet.webservic es:27381>Subject: RE: Serialization across 'like' attribute names
>Date: Fri, 24 Dec 2004 07:03:05 -0800
>Lines: 210
>Message-ID: <789F6E5B-745C-4B45-BDA7-B4ACFA4CEFE8@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: cpmsftngxa10.phx.gblbelieves>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
>Dan,
>
>I apoligize, I should have been using [XmlAttribute] and not [XmlElement]
>
>consider this XML
>
><x:root xmlns:x="urn:A">
> <x:child Id="1" x:Id="2"/>
></x:root>
>
>Now...two Ids exist. One is qualified as {""}Id and the other {urn:A}Id
>The default namespace is xmlns="" not "urn:A". When you attempt to
>serialize this you get a namespace collision in that the serializerget>that {""}Id and {urn:A}Id belong to the same namespace, i.e., urn:A.
>
>Sorry for the confusion.
>
>-MattL
>
>
>
>
>
>
>"Dan Rogers" wrote:
>>> Hi Matt,
>> I think you are saying (ignoring your implementation) that you want toto>> the following XML:
>>
>> <Root xmlns="urn:A">
>> <id>namespaced value</id>
>> <id xmlns="">non-namespaced value</id>
>> </Root>
>>
>> Is this correct? From a schema perspective, this is nearly impossibleHowever,>> describe, so best practice would seem to dicate not doing this.think>> since it is to a degree, just a matter of what you can serialize, IXmlSerializerNamespaces();>> it's possible to make this happen.
>>
>> If so, try this:
>>
>> [XmlRoot("urn:A")]
>> public class Root
>> {
>> [XmlElement(ElementName="id", Namespace="urn:A", DataType="string")]
>> public string firstId;
>>
>> [XmlElement(ElementName="id", Form=XmlSchemaForm.Unqualified,
>> DataType="string")]
>> public string secondId;
>>
>> public Root()
>> {
>> firstId = "namespaced value";
>> secondId = "non-namespaced value";
>> }
>> }
>>
>> Hope this helps,
>>
>> Dan Rogers
>> Microsoft Corporation
>>
>> -------------------->> <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>>> >Thread-Topic: Serialization across 'like' attribute names
>> >thread-index: AcTkVqqruD3zK+TeQkiNrEeE6lyK7Q==
>> >X-WBNR-Posting-Host: 208.223.183.28
>> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
>> <qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>>> microsoft.public.dotnet.framework.aspnet.webservic es:27278>> >Subject: RE: Serialization across 'like' attribute names
>> >Date: Fri, 17 Dec 2004 08:37:15 -0800
>> >Lines: 112
>> >Message-ID: <4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="Utf-8"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Content-Class: urn:content-classes:message
>> >Importance: normal
>> >Priority: normal
>> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>> >Xref: cpmsftngxa10.phx.gbl>> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>> >
>> >Example
>> >
>> >if this example the namespaces should be
>> >{urn:A}Root
>> >{""}Id
>> >{urn:A}Id
>> >
>> >
>> >
>> >[XmlRoot(Namespace="urn:A")]
>> >[XmlType(Namespace="urn:A")]
>> >public class Root
>> >{
>> > public class Root()
>> > {
>> > _xmlns.Add("x","urn:A");
>> > }
>> >
>> > private string _id;
>> > private string _otherId;
>> > private XmlSerializerNamespaces _xmlns = newForm=XmlSchemaForm.Qualified)]>> >
>> > [XmlNamespaceDeclarations()]
>> > public XmlSerializerNamespaces Xmlns
>> > {
>> > get{return _xmlns;}
>> > set{_xmlns = value;}
>> > }
>> > [XmlAttribute(Form=XmlSchemaForm.Unqualified)]
>> > public string Id
>> > {
>> > get{return _id;}
>> > set{_id = value;}
>> > }
>> >
>> > [XmlAttribute("Id", Namespace="urn:A",and>> > public string OtherId
>> > {
>> > get{return _otherId;}
>> > set{_otherId = value;}
>> > }
>> >}
>> >
>> >"Dan Rogers" wrote:
>> >
>> >> Hi Matt,
>> >>
>> >> Please send me the schema you wish to make classes for.
>> >>
>> >> Thanks
>> >> Dan Rogers
>> >> Microsoft Corporation
>> >> --------------------
>> >> >Thread-Topic: Serialization across 'like' attribute names
>> >> >thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
>> >> >X-WBNR-Posting-Host: 208.223.183.27
>> >> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
>> >> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
>> >> >Subject: RE: Serialization across 'like' attribute names
>> >> >Date: Wed, 8 Dec 2004 14:41:03 -0800
>> >> >Lines: 26
>> >> >Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
>> >> >MIME-Version: 1.0
>> >> >Content-Type: text/plain;
>> >> > charset="Utf-8"
>> >> >Content-Transfer-Encoding: 7bit
>> >> >X-Newsreader: Microsoft CDO for Windows 2000
>> >> >Content-Class: urn:content-classes:message
>> >> >Importance: normal
>> >> >Priority: normal
>> >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>> >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
>> >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
>> >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
>> >> >Xref: cpmsftngxa10.phx.gbl
>> >> microsoft.public.dotnet.framework.aspnet.webservic es:27099
>> >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>> >> >
>> >> >To clarify myself:
>> >> >The unqualified attribute SHOULD NOT inherit the default namespaceone>> it>> >> >appears that the serializer "puts" it in the default namespace.
>> >> >
>> >> >-MattL
>> >> >
>> >> >"MattL" wrote:
>> >> >
>> >> >> This serialization error appears to be not correct...
>> >> >>
>> >> >> When a class defined in a specific namespace,e.g., "urn:A" and two
>> >> >> attributes which have the same local name, e.g., "Id", with onethe>> does>> >> attribute
>> >> >> defined as Qualified and in the namespace "urn:A" and the other
>> >> attribute is
>> >> >> defined as Unqualified cannot be serialized.
>> >> >>
>> >> >> The problem (as it appears to me) is that an unqualifed attribute>> >> not
>> >> >> inherit a default namespace (per Namespaces in XML) and this isin>> >> error
>> >> >> thrown by the serializer, i.e., that both "Id" attributes appear>>> the>>>> >> same
>> >> >> namespace.
>> >> >>
>> >> >> Thoughts!
>> >> >>
>> >> >> -MattL
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> >
>>Dan Rogers Guest
-
MattL #9
RE: Serialization across 'like' attribute names
Hi Dan,
[1] and [2] (I think) state that the unprefixed attribute *does not* inherit
the namespace of the parent element rather it inherits the default namespace
which is empty string. I believe that [2] also states that the {""}Id and
{"someUri"}Id are unique since they are uniquely qualified.
So, either I'm mistaken in my interpretation of this or the serializer
simply cannot perform this operation (which I think indicates a bug).
[1] [url]http://www.w3.org/TR/REC-xml-names/#defaulting[/url]
[2] [url]http://www.w3.org/TR/REC-xml-names/#uniqAttrs[/url]
Thoughts?
Thx,
-MattL
"Dan Rogers" wrote:
> Hi Matt,
>
> Yes, you're going to have lots of serialization issues if you try to do
> this. Since the nill namespace is not addressible, and because the rules
> of XML say that unqualified child attributes default to the namespace of
> their parent element, it's at least debatable as to whether this particular
> construct can even be described using a schema.
>
> As a "did you try this" - I'd be shocked if it worked - but did you try
> treating the nill namespace value "" as a string, and making it a qualified
> attribute?
>
> Dan
> --------------------> <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>> >Thread-Topic: Serialization across 'like' attribute names
> >thread-index: AcTpyavCWD0KjUIjS4ith40Ppl1D9A==
> >X-WBNR-Posting-Host: 208.223.183.28
> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> <qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>
> <4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
> <NuQqO3u5EHA.3440@cpmsftngxa10.phx.gbl>> microsoft.public.dotnet.framework.aspnet.webservic es:27381> >Subject: RE: Serialization across 'like' attribute names
> >Date: Fri, 24 Dec 2004 07:03:05 -0800
> >Lines: 210
> >Message-ID: <789F6E5B-745C-4B45-BDA7-B4ACFA4CEFE8@microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl> believes> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >
> >Dan,
> >
> >I apoligize, I should have been using [XmlAttribute] and not [XmlElement]
> >
> >consider this XML
> >
> ><x:root xmlns:x="urn:A">
> > <x:child Id="1" x:Id="2"/>
> ></x:root>
> >
> >Now...two Ids exist. One is qualified as {""}Id and the other {urn:A}Id
> >The default namespace is xmlns="" not "urn:A". When you attempt to
> >serialize this you get a namespace collision in that the serializer> get> >that {""}Id and {urn:A}Id belong to the same namespace, i.e., urn:A.
> >
> >Sorry for the confusion.
> >
> >-MattL
> >
> >
> >
> >
> >
> >
> >"Dan Rogers" wrote:
> >> >> Hi Matt,
> >> I think you are saying (ignoring your implementation) that you want to> to> >> the following XML:
> >>
> >> <Root xmlns="urn:A">
> >> <id>namespaced value</id>
> >> <id xmlns="">non-namespaced value</id>
> >> </Root>
> >>
> >> Is this correct? From a schema perspective, this is nearly impossible> However,> >> describe, so best practice would seem to dicate not doing this.> think> >> since it is to a degree, just a matter of what you can serialize, I> XmlSerializerNamespaces();> >> it's possible to make this happen.
> >>
> >> If so, try this:
> >>
> >> [XmlRoot("urn:A")]
> >> public class Root
> >> {
> >> [XmlElement(ElementName="id", Namespace="urn:A", DataType="string")]
> >> public string firstId;
> >>
> >> [XmlElement(ElementName="id", Form=XmlSchemaForm.Unqualified,
> >> DataType="string")]
> >> public string secondId;
> >>
> >> public Root()
> >> {
> >> firstId = "namespaced value";
> >> secondId = "non-namespaced value";
> >> }
> >> }
> >>
> >> Hope this helps,
> >>
> >> Dan Rogers
> >> Microsoft Corporation
> >>
> >> --------------------
> >> >Thread-Topic: Serialization across 'like' attribute names
> >> >thread-index: AcTkVqqruD3zK+TeQkiNrEeE6lyK7Q==
> >> >X-WBNR-Posting-Host: 208.223.183.28
> >> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> >> <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
> >> <qBBWJZu3EHA.768@cpmsftngxa10.phx.gbl>
> >> >Subject: RE: Serialization across 'like' attribute names
> >> >Date: Fri, 17 Dec 2004 08:37:15 -0800
> >> >Lines: 112
> >> >Message-ID: <4A75118D-53D3-463B-A15A-AA694E6CFB93@microsoft.com>
> >> >MIME-Version: 1.0
> >> >Content-Type: text/plain;
> >> > charset="Utf-8"
> >> >Content-Transfer-Encoding: 7bit
> >> >X-Newsreader: Microsoft CDO for Windows 2000
> >> >Content-Class: urn:content-classes:message
> >> >Importance: normal
> >> >Priority: normal
> >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >> >Xref: cpmsftngxa10.phx.gbl
> >> microsoft.public.dotnet.framework.aspnet.webservic es:27278
> >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >
> >> >Example
> >> >
> >> >if this example the namespaces should be
> >> >{urn:A}Root
> >> >{""}Id
> >> >{urn:A}Id
> >> >
> >> >
> >> >
> >> >[XmlRoot(Namespace="urn:A")]
> >> >[XmlType(Namespace="urn:A")]
> >> >public class Root
> >> >{
> >> > public class Root()
> >> > {
> >> > _xmlns.Add("x","urn:A");
> >> > }
> >> >
> >> > private string _id;
> >> > private string _otherId;
> >> > private XmlSerializerNamespaces _xmlns = new> Form=XmlSchemaForm.Qualified)]> >> >
> >> > [XmlNamespaceDeclarations()]
> >> > public XmlSerializerNamespaces Xmlns
> >> > {
> >> > get{return _xmlns;}
> >> > set{_xmlns = value;}
> >> > }
> >> > [XmlAttribute(Form=XmlSchemaForm.Unqualified)]
> >> > public string Id
> >> > {
> >> > get{return _id;}
> >> > set{_id = value;}
> >> > }
> >> >
> >> > [XmlAttribute("Id", Namespace="urn:A",> and> >> > public string OtherId
> >> > {
> >> > get{return _otherId;}
> >> > set{_otherId = value;}
> >> > }
> >> >}
> >> >
> >> >"Dan Rogers" wrote:
> >> >
> >> >> Hi Matt,
> >> >>
> >> >> Please send me the schema you wish to make classes for.
> >> >>
> >> >> Thanks
> >> >> Dan Rogers
> >> >> Microsoft Corporation
> >> >> --------------------
> >> >> >Thread-Topic: Serialization across 'like' attribute names
> >> >> >thread-index: AcTddv9JsCx498jxRx2TdGUFw+iZkg==
> >> >> >X-WBNR-Posting-Host: 208.223.183.27
> >> >> >From: "=?Utf-8?B?TWF0dEw=?=" <MattL@discussions.microsoft.com>
> >> >> >References: <8D601524-5160-4866-A47D-3A30E98F17BA@microsoft.com>
> >> >> >Subject: RE: Serialization across 'like' attribute names
> >> >> >Date: Wed, 8 Dec 2004 14:41:03 -0800
> >> >> >Lines: 26
> >> >> >Message-ID: <2C8103C2-858C-4D28-BFFE-05A84E7EDEA7@microsoft.com>
> >> >> >MIME-Version: 1.0
> >> >> >Content-Type: text/plain;
> >> >> > charset="Utf-8"
> >> >> >Content-Transfer-Encoding: 7bit
> >> >> >X-Newsreader: Microsoft CDO for Windows 2000
> >> >> >Content-Class: urn:content-classes:message
> >> >> >Importance: normal
> >> >> >Priority: normal
> >> >> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >> >> >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >> >> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >> >> >Xref: cpmsftngxa10.phx.gbl
> >> >> microsoft.public.dotnet.framework.aspnet.webservic es:27099
> >> >> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
> >> >> >
> >> >> >To clarify myself:
> >> >> >The unqualified attribute SHOULD NOT inherit the default namespace> one> >> it
> >> >> >appears that the serializer "puts" it in the default namespace.
> >> >> >
> >> >> >-MattL
> >> >> >
> >> >> >"MattL" wrote:
> >> >> >
> >> >> >> This serialization error appears to be not correct...
> >> >> >>
> >> >> >> When a class defined in a specific namespace,e.g., "urn:A" and two
> >> >> >> attributes which have the same local name, e.g., "Id", with one> the> >> >> attribute
> >> >> >> defined as Qualified and in the namespace "urn:A" and the other
> >> >> attribute is
> >> >> >> defined as Unqualified cannot be serialized.
> >> >> >>
> >> >> >> The problem (as it appears to me) is that an unqualifed attribute
> >> does
> >> >> not
> >> >> >> inherit a default namespace (per Namespaces in XML) and this is> in> >> >> error
> >> >> >> thrown by the serializer, i.e., that both "Id" attributes appear>> >> >> the
> >> >> same
> >> >> >> namespace.
> >> >> >>
> >> >> >> Thoughts!
> >> >> >>
> >> >> >> -MattL
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> >> >
> >>
> >>
>MattL Guest



Reply With Quote

