473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1414

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
2
by: Maersa | last post by:
hi, i'm trying to add "attributes" to some nodes and it works at design time but fails at runtime. XmlDocument doc = new XmlDocument(); XmlElement elem = doc.CreateElement( "root" );...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
7
by: farseer | last post by:
Hi, i am getting an error when trying to deserialize and xml. the error is shown below. i get this error regardless if i try to desearialize in C# or VB. the XML itself does infact contain a...
6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
0
by: S Wheeler | last post by:
Hi All - I am creating a upgrade utility that transfers an bin / exe image over an xml stream. But I can not seem to get the deserialization of the binary field to work correctly. What I have is...
5
by: asciz | last post by:
Hi I'm having a problem with an XML file, most likely because of my lack of understanding of XML schemas I have the following XML file: <?xml version="1.0" encoding="ISO-8859-1"?>...
0
by: theonlydavewilliams | last post by:
Hi there I'm hoping there's an easy answer to a (hopefully) not too long-winded issue... I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.