473,591 Members | 2,919 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Serializ ableAttribute()]

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="urn:pro file")]
public class IqProfileType {

[System.Xml.Seri alization.XmlEl ementAttribute( "Name")]
public string Name;

[System.Xml.Seri alization.XmlAt tributeAttribut e(
Form=System.Xml .Schema.XmlSche maForm.Qualifie d,
Namespace="urn: common")]
public string ChangeNumber;

}

My xml (stripped down):

<m:IqProfile ChangeNumber="8 7" xmlns:m="urn:pr ofile"
xmlns:iq="urn:c ommon">
<m:Name>xyz</m:Name>
</m:IqProfile>

My xsd (stripped down):

<xsd:schema
targetNamespace ="urn:profil e"
xmlns="urn:prof ile"
xmlns:iq="urn:c ommon"
elementFormDefa ult="qualified"
version="1.0">

<xsd:complexTyp e
name="IqProfile Type"

<xsd:sequence >
<xsd:element
name="Name"
type="xsd:strin g" />
</xsd:sequence>
<xsd:attributeG roup ref="iq:Documen tRootAttributeG roup" />
</xsd:complexType >
</xsd:schema>

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

<xsd:schema
xmlns="urn:comm on"
targetNamespace ="urn:common "
elementFormDefa ult="qualified"
version="1.0">
<xsd:attributeG roup name="DocumentR ootAttributeGro up">
<xsd:attribut e name="ChangeNum ber" type="xsd:strin g"
use="required" />
</xsd:attributeGr oup>
</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.Seri alization.XmlAt tributeAttribut e()]
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 1432

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

Similar topics

1
2717
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 namespace prefix, what is its namespace, if default namespaces do not apply? Are (either of) prefixed or non-prefixed attributes correct? For example, are the following equivalent: <html:br class="foo"...
9
1831
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 owner element. Is that right ? Like:
2
9296
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" ); elem.InnerXml = "<first>abcde</first><last>1234</last>";
6
2575
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 schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
7
16054
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 top level "PDocument" note which contains an xmlns namespace and some other attriute. is the error belowing telling it doesn't like that namespace declaration? how can i programmactically fix this, as i do not have control of the xml i recieve...i...
6
5967
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 assign a value to them. I wanted to trap for this exception in a subclass using super but it doesn't happen. I have read Guido's tutorial on new style classes and Shalabh's tuturial on new style attributes and methods, and thought I understood...
0
1440
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 a base 64 encoded field but when I try to deserialize, I throw an XML / reflection exception. However, if I remove the base64 (m_Data) stuff everything works fine. I clearly have a problem with my m_Data set-up. Does anybody know how to do this?...
5
2617
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"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
0
2793
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 namespace. Some schemas extend complex types in others. When i get a soap:Fault from my test server it could contain a serialized exception object (called fault) from one of two of these schemas (and different namespaces, call them xmlns:b0="ns1" and...
0
7935
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8236
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6642
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3851
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2379
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.