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

XmlSchemaImport, XmlSchema's and derived type

Have somebody had already the problem of having to write more than one XmlSchema,
where some of these schemas have imports to others and respectively derived types?
The imports cannot be resolved until I dont save all schemas to disk, but I cannot
do this because I get an error for the derived types(which have base types from schema
which is not written yet, so the import cannot be resolved).
How could I solve this problem? I dont need any resolving, just save them to disk.
By compiling when I give a null-value for the XmlResolver
schema.Compile(textWriter, null)
I dont get the warning for the import, but still have an error for the derived type.
I also cannot give a specific order of the schemas to be written, because there could
be cycles of derivation in these schemas.

Perhaps somebody can tell me, if it is possible to generate all my elements in one schema
but still keep the namespaces and have derivation from one namespace to other? (I guess not).

It would be pitty to leave the XmlSchema object model and just write strings to files.

Thanks in advance!

--------------------------------
From: Rumen Traykov

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>5F1bKmoKyECaVGBweM2hLQ==</Id>
Nov 12 '05 #1
1 1506
The imports can be resolved without actually loading the schema from disk if
you already have an XmlSchema object corresponding to the
import in memory.
//Create imported schema
XmlSchema importedSchema = new XmlSchema();
importedSchema.TargetNamespace="import";
XmlSchemaElement elem = new XmlSchemaElement();
elem.Name="importedElement";
importedSchema.Items.Add(elem);

//Create main schema
XmlSchema mainSchema = new XmlShcema();
mainSchema.TargetNamespace="main";

XmlSchemaImport imp = new XmlSchemaImport();
imp.Namespace = "import";
imp.Schema = importedSchema; ----> This attaches the imported schema to the
import in the main schema

//Now add the import to the mainSchema
mainSchema.Includes.Add(imp);
mainSchema.Compile(null);

If the above does not solve your problem, please attach a code sample and
the schemas that you are trying to compile.

HTH,
Priya

"Rumen Traykov via .NET 247" <an*******@dotnet247.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Have somebody had already the problem of having to write more than one XmlSchema, where some of these schemas have imports to others and respectively derived types? The imports cannot be resolved until I dont save all schemas to disk, but I cannot do this because I get an error for the derived types(which have base types from schema which is not written yet, so the import cannot be resolved).
How could I solve this problem? I dont need any resolving, just save them to disk. By compiling when I give a null-value for the XmlResolver
schema.Compile(textWriter, null)
I dont get the warning for the import, but still have an error for the derived type. I also cannot give a specific order of the schemas to be written, because there could be cycles of derivation in these schemas.

Perhaps somebody can tell me, if it is possible to generate all my elements in one schema but still keep the namespaces and have derivation from one namespace to other? (I guess not).
It would be pitty to leave the XmlSchema object model and just write strings to files.
Thanks in advance!

--------------------------------
From: Rumen Traykov

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>5F1bKmoKyECaVGBweM2hLQ==</Id>

Nov 12 '05 #2

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

Similar topics

2
by: AlexS | last post by:
Hello, I have error when reading schema using XmlSchema. Read and then .Compile: System.Xml.Schema.XmlSchemaException: May not be nominated as the {substitution group affiliation} of any...
4
by: Stefan Rotter | last post by:
Hi, I'm trying to load a schema into an XmlSchema object with the Read and Compile methods. I use Read with a ValidationEventHandler. No errors occurs but when I look at the XmlSchema properties...
3
by: Nathan Wallace | last post by:
Hello, I have 2 schema, for argument sake let's call them child.xsd and parent.xsd. I define all my types in parent.xsd and the child.xsd include the parent.xsd using the following tag: ...
1
by: Victor Hadianto | last post by:
Hi, I have a simple XSD for example like this: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified">...
2
by: Gary McGill | last post by:
I'm finding the XmlSchema object model very hard to follow :-( I've figured out by trial and error how to do most things I need, but this one has me beat. Suppose my schema has a simple type...
1
by: SideByEach | last post by:
If I wanted to find the type referenced in this XML's root node, what object would I use in the SOM? <xs:schema xmlns="http://www.w3.org/1999/XSL/Transform"elementFormDefault="qualified" ...
4
by: Igor Koretsky | last post by:
Hi. Using VB.Net System.Xml 1.0 SchemaCollection Object I am getting an error when trying to add ‘Schema A’ to the SchemaCollection. Here are my schema files..
2
by: doughboy | last post by:
I create a schema in memory and then I can write to a file fine. But as soon as I add an import element I get an error when it goes to write to the file. The error message is: The type...
1
Samji
by: Samji | last post by:
Hello. I have this XML document: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <vbtagsconf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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,...

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.