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

Schemaset : schema compiled form code shows no PSVI elements

I accidentally put this on another group - this is the more likley home...

The first code fragment creates the simplest of XML Schemas is code. After
the “Compile()” method is called on the schemaset objetc, the schema element
count is zero – but I was expecting one element in the PSVI.
I saved the XML output in the console window to a file, and ran the second
code fragment below to load in the XML from the file, and compile the schema.
The element count of the schema is now 1 – as expected.
Why does the compile for a schema created in code not set to schema element
count to 1?

I also tried to add a second element after a schema was loaded from a file
(as in second fragment), but instead of getting 2 elements, scheme just shows
1
First Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler +=new
ValidationEventHandler(schemaSet_ValidationEventHa ndler);

XmlSchema s = new XmlSchema();
schemaSet.Add(s);

// add an element
XmlQualifiedName e1Type = new XmlQualifiedName("string",
"http://www.w3.org/2001/XMLSchema");
XmlSchemaElement e = new XmlSchemaElement();
e.SchemaTypeName = e1Type;
e.Name = "E1";

s.Items.Add(e);
schemaSet.Compile();

XmlNamespaceManager nsmgr = new XmlNamespaceManager(new
NameTable());
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
s.Write(Console.Out, nsmgr);

Second Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchema s = schemaSet.Add(null, @"C:\Temp\CompileTest.xsd");

--
Steve at Pixelda, North Yorkshire.
Nov 12 '05 #1
2 1335
OK, it looks like you need to call the Reprocess method to build the PSVI.

This method performs the steps that an "Add" schema does - and as a side
effect, sets the IsCompiled to false. I assume from the documentation that
the compile method simply performs validation - without setting the PSVI. I
got a bit confused here. Maybee the documentation needs a bit more
explanation.
Nov 12 '05 #2
The XmlSchemaSet does not track editing of the XmlSchema objects already
added to the set, so in case you add a schema and pick up new additions to
it, you must call Reprocess().

In your case, you dont need to call reprocess if you add the XmlSchema to
the set AFTER making the edits, so move to the line:
schemaSet.Add(s);
below the
s.Items.Add(e);
This should let the set add the XmlSchema with the element added.

Thanks.

"Steve at Pixelda" <St************@discussions.microsoft.com> wrote in
message news:C5**********************************@microsof t.com... I accidentally put this on another group - this is the more likley home...

The first code fragment creates the simplest of XML Schemas is code. After the "Compile()" method is called on the schemaset objetc, the schema element count is zero - but I was expecting one element in the PSVI.
I saved the XML output in the console window to a file, and ran the second
code fragment below to load in the XML from the file, and compile the schema. The element count of the schema is now 1 - as expected.
Why does the compile for a schema created in code not set to schema element count to 1?

I also tried to add a second element after a schema was loaded from a file
(as in second fragment), but instead of getting 2 elements, scheme just shows 1
First Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.ValidationEventHandler +=new
ValidationEventHandler(schemaSet_ValidationEventHa ndler);

XmlSchema s = new XmlSchema();
schemaSet.Add(s);

// add an element
XmlQualifiedName e1Type = new XmlQualifiedName("string",
"http://www.w3.org/2001/XMLSchema");
XmlSchemaElement e = new XmlSchemaElement();
e.SchemaTypeName = e1Type;
e.Name = "E1";

s.Items.Add(e);
schemaSet.Compile();

XmlNamespaceManager nsmgr = new XmlNamespaceManager(new
NameTable());
nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
s.Write(Console.Out, nsmgr);

Second Code Fragment
XmlSchemaSet schemaSet = new XmlSchemaSet();
XmlSchema s = schemaSet.Add(null, @"C:\Temp\CompileTest.xsd");
--
Steve at Pixelda, North Yorkshire.

Nov 12 '05 #3

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

Similar topics

2
by: wooks | last post by:
<?xml version='1.0'?> <userlogin xmlns="urn:faster:userlogin" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <login>mick</login> <password>brown</password> </userlogin> Above is my...
0
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
2
by: Ed Trembicki-Guy | last post by:
Does anyone know of an existing tool or template to merge the contents of a base schema and an extension schema that uses the <redefine> tag to extend the base schema? I need to extract a subset...
3
by: Thomas Fischer | last post by:
Hi, i have a very complex XSD with frequently use of xsd:extension, xsd:restriction and xsd:redefine. Now i would like to process a XSL transformation based on the *resulted* Schema. But I don't...
1
by: NaraendiraKumar R. R. | last post by:
Folks, Have any of you figured out a way in .NET 1.1 to access the scheme type of a Xml node from XSLT? Appreciate any pointers or code snippets that you can provide. After some extensive...
2
by: Mike | last post by:
Hi! I have an Excel 2003 Schema I need to parse to extract elements names. I am puzzled which System.Xml object can help me. Here's the example of my schema: I need to get a collection of...
1
by: Mike | last post by:
Hi! I have an Excel 2003 Schema I need to parse to extract elements names. I am puzzled with the System.Xml.Schema object. Here's the example of my schema: I need to get a collection of element...
3
by: asjad | last post by:
Is there any way through which attributes of elements along with their default value and possible values can be retrieved from the schema using C#. Any help will really be appreciated.
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
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: 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: 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?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.