473,386 Members | 1,734 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.

Get XmlSchemaElement from Instance Element

Is there anyway to get the correct XmlSchemaElement from an XSD that
corresponds to an element within an Xml Document Instance?

I want to automatically generate a UI for an Xml Instance based upon
information contained within an XSD. Based on the selected element
within the Xml Instance document I want to find the corresponding
XmlSchemaElement in the XSD and then get parameters from the XSD to
customize the UI (min, max, allowable children, etc...).
Please help, I am driving myself nuts trying to figure out how to do
this. I thought I might be able to do it with the XmlValidatingReader
but it doesn't look like it will give me the XmlSchemaElement, just
the type....
THANK YOU FOR YOUR HELP, I NEED SLEEP!!!!! ;-)
Nov 12 '05 #1
1 1718
You are not able to access the SOM Element (XmlSchemaElement) from the
XmlValidatingReader. The new validating reader shipped in System.Xml in
Visual Studio 2005 beta1 does expose the SOM Element. You will have to
modify your code to work with this new validating reader.
In Visual Studio 2005 beta1, use the XmlSchemaSet class which is a
replacement for the XmlSchemaCollection. Below is a code sample to create
the reader and using it. At any point during validation, you can access the
SOM objects(XmlSchemaElement and XmlSchemaAttribute) from

vr.SchemaInfo.XmlSchemaElement
vr.SchemaInfo.XmlSchemaAttribute

Hope this helps,

-Zafar

Code Sample:
XmlReaderSettings settings = new XmlReaderSettings();
settings.XsdValidate = true;
settings.Schemas.ValidationEventHandler += new
ValidationEventHandler(ValidationCallback);
settings.ValidationEventHandler += new
ValidationEventHandler(ValidationCallback);
settings.Schemas.Add(null, "SCHEMA.XSD");
XmlReader vr = XmlReader.Create(xmlFile, null, new XmlUrlResolver(),
settings);
while(vr.Read()) {}



"Josh" <jo**@nautilusnet.com> wrote in message
news:38**************************@posting.google.c om...
Is there anyway to get the correct XmlSchemaElement from an XSD that
corresponds to an element within an Xml Document Instance?

I want to automatically generate a UI for an Xml Instance based upon
information contained within an XSD. Based on the selected element
within the Xml Instance document I want to find the corresponding
XmlSchemaElement in the XSD and then get parameters from the XSD to
customize the UI (min, max, allowable children, etc...).
Please help, I am driving myself nuts trying to figure out how to do
this. I thought I might be able to do it with the XmlValidatingReader
but it doesn't look like it will give me the XmlSchemaElement, just
the type....
THANK YOU FOR YOUR HELP, I NEED SLEEP!!!!! ;-)

Nov 12 '05 #2

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

Similar topics

1
by: wooks | last post by:
The schema below describes an interface to a form where the appInterface type is an extension of an abstract type called interface and it contains an appFrame element that is an extension of an...
2
by: eXavier | last post by:
Hi all, I wrote some generator of classes from XSD files but encountred unexpected (for me) values in parsed DOM. First I load XSD with XmlSchema.Read() method, then iterate through...
0
by: Rein Petersen | last post by:
Hi Folks, I'm reading a schema using SOM (System.Xml.Schema) and there are namespaced attributes that I need to access but I'm having problems with the UnhandledAttributes property - that is is...
1
by: Rein Petersen | last post by:
Somebody please tell me what is the matter with the System.Xml.Schema.XmlSchemaElement.UnhandledAttributes property. I don't seem to be able to access no matter how I try... Rein
1
by: Christian Lammel | last post by:
OK, repost: > I implemented a schema helper function GetDeclaration (similar to MSXML), > that finds a XmlSchemaElement for a given XmlElement, using a > XmlSchemaCollection. There is one kind...
1
by: Sam Vanhoutte | last post by:
Hello, I am generating an XML schema for the use in Biztalk 2004. Everything works, except for one simple thing. I cannot add XmlSchemaElements to a XmlSchemaComplexType. This is necessary...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
1
by: da_pander | last post by:
Hi, Can anyone tell me if it is possible to create a XSD schema document that will only allow certain elements to be displayed as available within the instance document depending on say a...
2
by: wilkinson.philip | last post by:
I have a javascript object which dynamically generates a table adding, deleting and moving rows as the user clicks on buttons or links. Problem is when I generate a table row and add the javascript...
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: 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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.