473,830 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 programmaticall y 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.W riteRaw 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.Forma tting = Formatting.Inde nted;
xsdWriter.Inden tation = 4;
xsdWriter.Write StartDocument() ;
string xsdNS = "xmlns:xsd= " +
@"""http://www.w3.org/2001/XMLSchema""";
xsdWriter.Write StartElement("x sd:schema " + xsdNS);
xsdWriter.Write StartElement("x sd:element name=" +
@"""main""") ;
xsdWriter.Write StartElement("x sd:complexType" );
xsdWriter.Write StartElement("x sd:sequence");

for (int field = 0; field <= tablesnames.Len gth - 1; field++)
{
xsdWriter.Write StartElement("x sd:element name=" + @""""
+ tablesnames[field] + @"""" +
" type=" + @"""xsd:string" "");
xsdWriter.Write EndElement();
}

xsdWriter.Write EndElement(); //sequence
xsdWriter.Write EndElement(); //complextype
xsdWriter.Write EndElement();
xsdWriter.Write EndElement();

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 1094

"Terrance" <Te******@discu ssions.microsof t.comwrote in message
news:83******** *************** ***********@mic rosoft.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 programmaticall y 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.W riteRaw 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 WriteAttributeS tring statement. You
can use Google and look it up. But as I recalled, that is how you control
name spaces on closing tags.

writer.WriteSta rtElement("trac k");
writer.WriteAtt ributeString("n ame", "Street Spirit");
writer.WriteEnd Element();



Jun 27 '08 #2

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

Similar topics

9
2943
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 a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the device
1
3842
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 an object with properties name and code public System.Xml.Schema.XmlSchema GetSchema() { string _namespace;
9
10684
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 table from which I want to delete has two foreign keys that references two other tables and it is also referenced by another table. But this shouldn't be a problem, since I set the commit mode to none (or *none) at all places where this makes...
1
4246
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. From the log it looks like the problem happens when 2 threads insert 1 record each in the same table and then try to aquire a NS (Next Key Share) lock on the record inserterd by the other thread. Thanks Rohit
1
1607
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 files that i was given to xsd files and used the xsd tool to create the classes. i used those classes to create the parameters for the web method defined as follows: publicSchema.submitOrderBatchResponse submitOrderBatch(Schema.submitOrderBatch...
6
20830
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"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pd="uri:myUri.com"> <xsd:simpleType name="pd:width">
1
1554
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 the original xml into 10 individual SalesOrder xml files, each file containing a single sales order. The xml files created must be created based on a set xsd schema.See example below: Here I have 2 sales orders in my original xml, I want to create 1...
5
2524
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 startdate and enddate, all in the same query.
0
4017
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 valid) but in this one I am having problems. Any time I run this I get the folowing message from the db2 clp window that opens up. SQL0104N An unexpected token "SET" was found following "<identifier>". Expected tokens may include: "NEW". ...
0
9791
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
10771
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10487
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...
0
10202
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...
0
9313
agi2029
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...
0
6950
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();...
0
5617
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...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4411
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 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.