473,378 Members | 1,620 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,378 software developers and data experts.

XML: empty namespace?

<GTM.Data:GRTMData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:GTM.Data="http://www.pippo.com/GTMData"
xsi:schemaLocation="http://www.pippo.com/GRTMData GTMDataSchema.xsd">

w.WriteStartElement("GTM.Data","GRTMData","");
w.WriteAttributeString("xmlns","xsi",
null,"http://www.w3.org/2001/XMLSchema-instance");
w.WriteAttributeString("xmlns","GTM.Data",null,"ht tp://www.pippo.com/GRTMData");
w.WriteAttributeString("xsi","schemaLocation",null ,"http://www.pippo.com/GTMData
GTMDataSchema.xsd");

Exception: "Cannot use a prefix with an empty namespace".

Why?

Thanks,
Luigi.
May 5 '07 #1
1 3988
BLUE wrote:
<GTM.Data:GRTMData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:GTM.Data="http://www.pippo.com/GTMData"
xsi:schemaLocation="http://www.pippo.com/GRTMData GTMDataSchema.xsd">

w.WriteStartElement("GTM.Data","GRTMData","");
w.WriteAttributeString("xmlns","xsi",
null,"http://www.w3.org/2001/XMLSchema-instance");
w.WriteAttributeString("xmlns","GTM.Data",null,"ht tp://www.pippo.com/GRTMData");
w.WriteAttributeString("xsi","schemaLocation",null ,"http://www.pippo.com/GTMData
GTMDataSchema.xsd");

Exception: "Cannot use a prefix with an empty namespace".
The element has a namespace. And you do not need to write out xmlns
declarations, the serializer will add them automatically once you write
out elements or attributes in a certain namespace. So this suffices:

const string xsi = "http://www.w3.org/2001/XMLSchema-instance";
const string gtm = "http://www.pippo.com/GTMData";

w.WriteStartElement("GTM.Data","GRTMData",gtm);
w.WriteAttributeString("xsi","schemaLocation",xsi,
"http://www.pippo.com/GTMData GTMDataSchema.xsd");

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 6 '07 #2

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

Similar topics

1
by: Mark Olbert | last post by:
I am trying to validate an XML file that does not contain any xmlns: namespace attribute against a predefined XSD schema. I should think this would be easy to do, since there must be far more...
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
5
by: Don | last post by:
Hi: I have created an xsd from my xml document. I pop this xsd in the following directory: C:\program files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\xml. That give me...
1
by: Tony Johansson | last post by:
Hello I'm trying to learn XML by reading a book. There is some text in the book that I don't understand so I try to ask you out there. My first question is does this statement mean that ...
8
by: C# newbie | last post by:
Hi Group, I have a problem with XML! I have an xml file which starts like this: <Plaftorm PlatformName="empty" PlatformID="1" StyleUsage="URL" xmlns="http://www.domain.com" ...
4
by: Mike | last post by:
Hello, I have a custom configuration file that I use to load some data for users to modify (no DB involved). Since this data is used in different GUI components (comboboxes, textboxes, etc.), I...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
6
by: fzhang | last post by:
I am relatively new to XML and C#. So, forgive me if this question is too newbie. :-) While assuming this is an easy programming task, I couldn't find a single reference anywhere for how to do...
5
by: hello | last post by:
How can I define the schema so that myage element has to be double or null? <xs:simpleType name="myage"> <xs:restriction base="xs:double"> <xs:enumeration value="null"/> </xs:restriction>...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.