473,659 Members | 2,664 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 1435

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

Similar topics

1
2720
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
1835
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
9300
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
2579
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
16056
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
5991
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
1442
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
2797
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
8427
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
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
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...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
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
4175
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
2749
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
2
1975
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.