Hi,
I have a class that I wish to serialize to XML, part of which looks like
this:
public class TitleNotification {
[XmlAttributeAttribute(Namespace="xsi",
AttributeName="noNameSpaceSchemaLocation")]
public string NoNameSpaceSchemaLocation = 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"?>
<TitleNotification xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
d1p1:noNameSpaceSchemaLocation="http://www.pdr.com
 https://extw3c.pdr.co
m/prism/b2b/schemas/TitleNotification.xsd" ParagonID="1234" Version="1"
Source="5" SupplierID="PA-1234" xmlns:d1p1="xsi" ...
How can I get it to generate xsi:noNameSpaceSchemaLocation instead of doing
the d1p1 substitution thing it's doing now?
Thanks,
Adam 4 12111
"AP" <ad***@indra.com> wrote in message news:OA**************@TK2MSFTNGP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotification { [XmlAttributeAttribute(Namespace="xsi", AttributeName="noNameSpaceSchemaLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http://www.w3.org/2001/XMLSchema-instance",
AttributeName="noNamespaceSchemaLocation")]
Also observe that the QName, xsi:noNamespaceSchemaLocation, is
case-sensitive.
: : How can I get it to generate xsi:noNameSpaceSchemaLocation 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:noNamespaceSchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noNamespaceSchemaLocation}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNamespaces,
and mark it with the [XmlNamespaceDeclarations] 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 XmlNamespaceDeclarations 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*************@TK2MSFTNGP11.phx.gbl... "AP" <ad***@indra.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotification { [XmlAttributeAttribute(Namespace="xsi", AttributeName="noNameSpaceSchemaLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http://www.w3.org/2001/XMLSchema-instance", AttributeName="noNamespaceSchemaLocation")]
Also observe that the QName, xsi:noNamespaceSchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpaceSchemaLocation 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:noNamespaceSchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noNamespaceSchemaLocation}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNamespaces, and mark it with the [XmlNamespaceDeclarations] 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 XmlNamespaceDeclarations 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*************@TK2MSFTNGP11.phx.gbl... "AP" <ad***@indra.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks like this:
public class TitleNotification { [XmlAttributeAttribute(Namespace="xsi", AttributeName="noNameSpaceSchemaLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute( Namespace="http://www.w3.org/2001/XMLSchema-instance", AttributeName="noNamespaceSchemaLocation")]
Also observe that the QName, xsi:noNamespaceSchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpaceSchemaLocation 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:noNamespaceSchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noNamespaceSchemaLocation}
Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type XmlSerializerNamespaces, and mark it with the [XmlNamespaceDeclarations] 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 XmlNamespaceDeclarations 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***@NOaspnet2SPAMPLZ.com> wrote in message
news:#3**************@TK2MSFTNGP10.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*************@TK2MSFTNGP11.phx.gbl... "AP" <ad***@indra.com> wrote in message news:OA**************@TK2MSFTNGP12.phx.gbl... I have a class that I wish to serialize to XML, part of which looks
like this:
public class TitleNotification { [XmlAttributeAttribute(Namespace="xsi", AttributeName="noNameSpaceSchemaLocation")]
The Namespace property represents a namespace URI -- not a prefix.
[XmlAttribute(
Namespace="http://www.w3.org/2001/XMLSchema-instance", AttributeName="noNamespaceSchemaLocation")]
Also observe that the QName, xsi:noNamespaceSchemaLocation, is case-sensitive.
: : How can I get it to generate xsi:noNameSpaceSchemaLocation 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:noNamespaceSchemaLocation are actually looking for:
{http://www.w3.org/2001/XMLSchema-instance,noNamespaceSchemaLocation} Therefore, it doesn't matter what prefix it's given.
Ordinarily, you would use a public field of type
XmlSerializerNamespaces, and mark it with the [XmlNamespaceDeclarations] 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 XmlNamespaceDeclarations 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...
|
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).
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |