473,403 Members | 2,071 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,403 software developers and data experts.

Help With Program Created XML Schema

Good Morning. I'm trying to create a xml file and schema file for my boss to
upload the information into Sharepoint. Everytime when he uploads the xml
file it notices there's no schema and I'm automatically generating the file;
so I decided to programmatically create a schema file. It's a simple file
and it's works accept for the last elements . Instead of writing
</xsd:elementand </xsd:schemait places the namespace in the schema tag
and name attribute in the element closing tag. I've tried
xmlTextWriter.WriteRaw and .WriteString but it doesn't indent correctly. How
can I get these tags to be generated as I described earlier? Below is the
code (xsdWriter is XmlTextWriter object):

xsdWriter.Formatting = Formatting.Indented;
xsdWriter.Indentation = 4;
xsdWriter.WriteStartDocument();
string xsdNS = "xmlns:xsd=" +
@"""http://www.w3.org/2001/XMLSchema""";
xsdWriter.WriteStartElement("xsd:schema " + xsdNS);
xsdWriter.WriteStartElement("xsd:element name=" +
@"""main""");
xsdWriter.WriteStartElement("xsd:complexType");
xsdWriter.WriteStartElement("xsd:sequence");

for (int field = 0; field <= tablesnames.Length - 1; field++)
{
xsdWriter.WriteStartElement("xsd:element name=" + @""""
+ tablesnames[field] + @"""" +
" type=" + @"""xsd:string""");
xsdWriter.WriteEndElement();
}

xsdWriter.WriteEndElement(); //sequence
xsdWriter.WriteEndElement(); //complextype
xsdWriter.WriteEndElement();
xsdWriter.WriteEndElement();

I'm trying to generate:
<schema xsd:....>
<element name="main">
<complexType>
<sequence>
<xsd:sequence.... />
</sequence>
</complexType>
</xsd:element -- Problem node </xsd:element name="main">
</xsd:schema --Problem node </xsd:schema .........>
--
TC
Jun 27 '08 #1
1 1071

"Terrance" <Te******@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
Good Morning. I'm trying to create a xml file and schema file for my boss
to
upload the information into Sharepoint. Everytime when he uploads the xml
file it notices there's no schema and I'm automatically generating the
file;
so I decided to programmatically create a schema file. It's a simple file
and it's works accept for the last elements . Instead of writing
</xsd:elementand </xsd:schemait places the namespace in the schema tag
and name attribute in the element closing tag. I've tried
xmlTextWriter.WriteRaw and .WriteString but it doesn't indent correctly.
How
can I get these tags to be generated as I described earlier? Below is the
code (xsdWriter is XmlTextWriter object):
I think what you're looking for is the WriteAttributeString statement. You
can use Google and look it up. But as I recalled, that is how you control
name spaces on closing tags.

writer.WriteStartElement("track");
writer.WriteAttributeString("name", "Street Spirit");
writer.WriteEndElement();



Jun 27 '08 #2

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

Similar topics

9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: Leepe | last post by:
example: I have a skill object that implements the XmlSerializable interface Implementing the getschema gives me some unwanted generations towards the wsdl.exe Reference.cs generation. skill is...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
1
by: MR | last post by:
I am in dire need of help in trying to get the client code for a web service to work. i don't have a WSDL for the service so i created my own ASP.NET service to test with. i converted the DTD...
6
by: Thea | last post by:
Hi I am trying to use datatypes defined in xml file to check correctness of input parameter values To define needed datatypes following schema.xml file was created: <?xml version="1.0"?>...
1
by: Domini | last post by:
Hi all, I need urgent help with an xml issue. Let me explain the scenario: My VB.NET app needs to read an xml (e.g. Sales Orders). This xml contains say 10 sales orders. Next the app needs to split...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
0
by: wb5plj | last post by:
Hi I am having a problem passing some sql to the db2cmd via ant. This is very confusing as I am doing this exact thing elseware with no problem (just differant sql, and I have verified the sql is...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.