Hi,
I have a class that I wish to serialize to XML, part of which looks like
this:
public class TitleNotificati on {
[XmlAttributeAtt ribute(Namespac e="xsi",
AttributeName=" noNameSpaceSche maLocation")]
public string NoNameSpaceSche maLocation = http://www.pdr.com\nhttps://extw3c.p...ification.xsd;
....
}
When the class is serialized, the relevant resulting XML looks like this:
<?xml version="1.0" encoding="utf-8"?>
<TitleNotificat ion xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
d1p1:noNameSpac eSchemaLocation ="http://www.pdr.com
 ; https://extw3c.pdr.co
m/prism/b2b/schemas/TitleNotificati on.xsd" ParagonID="1234 " Version="1"
Source="5" SupplierID="PA-1234" xmlns:d1p1="xsi " ...
How can I get it to generate xsi:noNameSpace SchemaLocation instead of doing
the d1p1 substitution thing it's doing now?
Thanks,
Adam 4 12168
"AP" <ad***@indra.co m> wrote in message news:OA******** ******@TK2MSFTN GP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotificati on { [XmlAttributeAtt ribute(Namespac e="xsi", AttributeName=" noNameSpaceSche maLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http ://www.w3.org/2001/XMLSchema-instance",
AttributeName=" noNamespaceSche maLocation")]
Also observe that the QName, xsi:noNamespace SchemaLocation, is
case-sensitive.
: : How can I get it to generate xsi:noNameSpace SchemaLocation instead of doing the d1p1 substitution thing it's doing now?
Try using the namespace URI, XmlSerializer may re-use the xsi prefix.
If it doesn't, then it's choice of prefix is arbitrary. Correct implementations
that honor xsi:noNamespace SchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noName spaceSchemaLoca tion}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNa mespaces,
and mark it with the [XmlNamespaceDec larations] attribute. You could
initialize this field by Add'ing prefix and namespaceURI pairings into it.
However, the XML Schema namespace declarations are emitted by the
XmlSerializer prior to consulting the XmlNamespaceDec larations field,
so you cannot count on your xsi namespace declaration appearing early
enough in the root element (it'll be there, though, because XmlSerializer
needs the XMLSchema-instance namespace itself.)
Derek Harmon
So in other words there's no gauranteed way of doing it?
"Derek Harmon" <lo*******@msn. com> wrote in message
news:eQ******** *****@TK2MSFTNG P11.phx.gbl... "AP" <ad***@indra.co m> wrote in message
news:OA******** ******@TK2MSFTN GP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotificati on { [XmlAttributeAtt ribute(Namespac e="xsi", AttributeName=" noNameSpaceSche maLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http ://www.w3.org/2001/XMLSchema-instance", AttributeName=" noNamespaceSche maLocation")]
Also observe that the QName, xsi:noNamespace SchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpace SchemaLocation instead of
doing the d1p1 substitution thing it's doing now?
Try using the namespace URI, XmlSerializer may re-use the xsi prefix. If it doesn't, then it's choice of prefix is arbitrary. Correct
implementations that honor xsi:noNamespace SchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noName spaceSchemaLoca tion}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNa mespaces, and mark it with the [XmlNamespaceDec larations] attribute. You could initialize this field by Add'ing prefix and namespaceURI pairings into it.
However, the XML Schema namespace declarations are emitted by the XmlSerializer prior to consulting the XmlNamespaceDec larations field, so you cannot count on your xsi namespace declaration appearing early enough in the root element (it'll be there, though, because XmlSerializer needs the XMLSchema-instance namespace itself.)
Derek Harmon
You can get rid of the xsd and xsi namespace declarations by using the
technique explained here: http://weblogs.asp.net/cazzu/archive.../23/62141.aspx, at the very
beginning of the post.
HTH
--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA http://weblogs.asp.net/cazzu http://aspnet2.com
"Derek Harmon" <lo*******@msn. com> wrote in message
news:eQ******** *****@TK2MSFTNG P11.phx.gbl... "AP" <ad***@indra.co m> wrote in message
news:OA******** ******@TK2MSFTN GP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotificati on { [XmlAttributeAtt ribute(Namespac e="xsi", AttributeName=" noNameSpaceSche maLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http ://www.w3.org/2001/XMLSchema-instance", AttributeName=" noNamespaceSche maLocation")]
Also observe that the QName, xsi:noNamespace SchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpace SchemaLocation instead of
doing the d1p1 substitution thing it's doing now?
Try using the namespace URI, XmlSerializer may re-use the xsi prefix. If it doesn't, then it's choice of prefix is arbitrary. Correct
implementations that honor xsi:noNamespace SchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noName spaceSchemaLoca tion}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNa mespaces, and mark it with the [XmlNamespaceDec larations] attribute. You could initialize this field by Add'ing prefix and namespaceURI pairings into it.
However, the XML Schema namespace declarations are emitted by the XmlSerializer prior to consulting the XmlNamespaceDec larations field, so you cannot count on your xsi namespace declaration appearing early enough in the root element (it'll be there, though, because XmlSerializer needs the XMLSchema-instance namespace itself.)
Derek Harmon
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 23/04/2004
Well, not quite what you wanted anyway :S
--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA http://weblogs.asp.net/cazzu http://aspnet2.com
"Daniel Cazzulino [MVP XML]" <kz***@NOaspnet 2SPAMPLZ.com> wrote in message
news:#3******** ******@TK2MSFTN GP10.phx.gbl... You can get rid of the xsd and xsi namespace declarations by using the technique explained here: http://weblogs.asp.net/cazzu/archive.../23/62141.aspx, at the very beginning of the post.
HTH -- Daniel Cazzulino [MVP XML] Clarius Consulting SA http://weblogs.asp.net/cazzu http://aspnet2.com "Derek Harmon" <lo*******@msn. com> wrote in message news:eQ******** *****@TK2MSFTNG P11.phx.gbl... "AP" <ad***@indra.co m> wrote in message news:OA******** ******@TK2MSFTN GP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks
like this:
public class TitleNotificati on { [XmlAttributeAtt ribute(Namespac e="xsi", AttributeName=" noNameSpaceSche maLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute(
Namespace="http ://www.w3.org/2001/XMLSchema-instance", AttributeName=" noNamespaceSche maLocation")]
Also observe that the QName, xsi:noNamespace SchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpace SchemaLocation instead of doing the d1p1 substitution thing it's doing now?
Try using the namespace URI, XmlSerializer may re-use the xsi prefix. If it doesn't, then it's choice of prefix is arbitrary. Correct implementations that honor xsi:noNamespace SchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noName spaceSchemaLoca tion} Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type
XmlSerializerNa mespaces, and mark it with the [XmlNamespaceDec larations] attribute. You could initialize this field by Add'ing prefix and namespaceURI pairings into
it. However, the XML Schema namespace declarations are emitted by the XmlSerializer prior to consulting the XmlNamespaceDec larations field, so you cannot count on your xsi namespace declaration appearing early enough in the root element (it'll be there, though, because
XmlSerializer needs the XMLSchema-instance namespace itself.)
Derek Harmon
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.665 / Virus Database: 428 - Release Date: 23/04/2004
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.665 / Virus Database: 428 - Release Date: 23/04/2004 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave |
last post by:
Hello all,
Please consider this code:
#ifndef FOO_INCLUDED
#define FOO_INCLUDED
// File: foo.h
class foo
{
|
by: Dan Kelley |
last post by:
I have an application which sends messages to an external application. All data is submitted as a string in an Xml format specified by the other application, along with some custom elements we have added to assist in trouble shooting. The format is below
<AppName><Data><!]></Data><CustomField1>field 1 data here</CustomField1><CustomField2>field 2 data here</CustomField2></AppName
Currently this Xml is being created dynamically each time a...
|
by: Alberto Grosso Nicolin |
last post by:
We have the following XML schema: there's a root element (Response) with of a
single child element (Result).
----------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TaskRequest"
targetNamespace="http://xyz.com/TaskResponse/1.0"
elementFormDefault="qualified" xmlns="http://xyz.com/TaskResponse/1.0"
|
by: ktn |
last post by:
Hi all,
I'm a .NET beginner and I've got a problem on a program where I try to do an
XML serialization.
I get the following error :
"An unmanaged exception of type 'System.IO.FileNotFoundException' occured in
mscorlib.dll
Additonal information : the file or asssembly named n9gu4-bo.dll or one of
its dependencies cannot be found"
|
by: psy000 |
last post by:
Hi,
I have a C# web service client that talks to a JAVA application sever.
I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy
stub c# code. When I try to use c# client connect to application
server, I did not get the result in the C# client side, I used a soap
monitor to look at the SOAP messages that were exchanged, I can see
server returned a correct SOAP message, but the C# client failed to
deserialize the XML...
| |
by: andrewcw |
last post by:
There is an error in XML document (1, 2).
I used XML spy to create the XML and XSD. When I asked to
have the XML validated it said it was OK.
I used the .net SDK to generate the class. I have done
this before but this time I have no idea why I am getting
the error. Any ideas ?? THANKS !
<qcsttatus>
<manual sourcerootfolder="" manualname="">
|
by: umhlali |
last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem serializing the object but there seems to be a problem serializing an array of objects. Any help will be appreciated
"Cannot assign object of type System.Object to an object of type ElectronicWallet.C2PTest.PaymentItem."
:...
|
by: Jeremy Chapman |
last post by:
I'm building a class with xml serialization attrbutes. Below I've included
the class and the xml it serializes to. It pretty much matches what I want
except for the Message property of the ResultValue class. I want it to
serialize to
<ResultValue><Messages><Message>value</Message><Message>value2</Message></Messages></ResultValue>
but it is actually serializing to...
|
by: groovyghoul |
last post by:
Hi
I have the following XML file:
===========================================================
<?xml version="1.0" encoding="UTF-16"?>
<Policy xmlns="http://tempuri.org/richard.xsd">
<TransType />
<LOB />
<Name>
<FirstName />
|
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...
|
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,...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |