469,313 Members | 2,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

Deserializing attributes from different namespace

Hi,

I'm having an issue with deserializing some xml using a proxy class
generated by "xsd.exe". My proxy class contains this class definition:

[System.SerializableAttribute()]

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="urn:profile")]
public class IqProfileType {

[System.Xml.Serialization.XmlElementAttribute("Name ")]
public string Name;

[System.Xml.Serialization.XmlAttributeAttribute(
Form=System.Xml.Schema.XmlSchemaForm.Qualified,
Namespace="urn:common")]
public string ChangeNumber;

}

My xml (stripped down):

<m:IqProfile ChangeNumber="87" xmlns:m="urn:profile"
xmlns:iq="urn:common">
<m:Name>xyz</m:Name>
</m:IqProfile>

My xsd (stripped down):

<xsd:schema
targetNamespace="urn:profile"
xmlns="urn:profile"
xmlns:iq="urn:common"
elementFormDefault="qualified"
version="1.0">

<xsd:complexType
name="IqProfileType"

<xsd:sequence>
<xsd:element
name="Name"
type="xsd:string" />
</xsd:sequence>
<xsd:attributeGroup ref="iq:DocumentRootAttributeGroup" />
</xsd:complexType>
</xsd:schema>

The "DocumentRootAttributeGroup" is defined in another xsd (stripped
down version shown below) and is xsd:import'ed in the above xsd:

<xsd:schema
xmlns="urn:common"
targetNamespace="urn:common"
elementFormDefault="qualified"
version="1.0">
<xsd:attributeGroup name="DocumentRootAttributeGroup">
<xsd:attribute name="ChangeNumber" type="xsd:string"
use="required" />
</xsd:attributeGroup>
</xsd:schema>

My deserializer isn't able to map the attribute properly .. what do I
miss to make this work? If I change the proxy class to read:

[System.Xml.Serialization.XmlAttributeAttribute()]
public string ChangeNumber;

i.e. if I remove the "Form" and "Namespace" properties it works as
expected.

I've tried to simply the above xml and xsd so please let me know if you
need more information. Do I need a prefix somewhere?

I'm using .NET 2.0 beta but I don't think that matters in this case.
Rgd,
Peter Theill

Nov 12 '05 #1
0 1308

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John L. Clark | last post: by
9 posts views Thread by Soren Kuula | last post: by
2 posts views Thread by Maersa | last post: by
7 posts views Thread by farseer | last post: by
6 posts views Thread by Samuel M. Smith | last post: by
reply views Thread by S Wheeler | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.