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

Listing Entities and Attributes from a XML Schema

Hi all..

..NET + MSXML platform....VB

Need to build a list of all the entities and attributes to allow the user to
do search...how can i do that from the schema ??

Cheers
Rohit
Nov 11 '05 #1
3 1714
Rohit Sharma wrote:
.NET + MSXML platform....VB
Are you sure you are using MSXML? Actually .NET doesn't include MSXML in any form.
Need to build a list of all the entities and attributes to allow the user to
do search...how can i do that from the schema ??

Could you provide some sample of what are you looking for? It's not clear,
whether you need all attributes in schema file or all attributes, declared in
schema file?
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Rohit Sharma wrote:
Then for each of them i need the attributes...like
Product : -> ID
Product: -> Product_Name
Product: -> description

and so on...
That's pretty easy. Learn about Schema object model (SOM) and
System.Xml.Schema namespace. The idea is to read schema file, compile it into
an object model, then for each complex type defined iterate over its declared
attributes:
public class Class1 {
public static void Main(string[] args) {
XmlSchema schema = XmlSchema.Read(new
StreamReader("LPD_PLCS_Schema.xsd"),
new ValidationEventHandler(ShowCompileError));
schema.Compile(new ValidationEventHandler(ShowCompileError));
foreach (XmlSchemaType t in schema.SchemaTypes.Values) {
XmlSchemaComplexType type = t as XmlSchemaComplexType;
if (type != null) {
foreach (XmlSchemaAttribute attr in type.Attributes)
Console.WriteLine("{0}:->{1}", type.Name, attr.Name);

}
}
}
private static void ShowCompileError(object sender, ValidationEventArgs e) {
Console.WriteLine("Validation Error: {0}", e.Message);
}

}

Note, that one cannot use xs:anySimpleType type directly in schema using .NET.
It's "implied" type, each simple type derives from by definition. So change
<xs:element name="Value_component" type="xs:anySimpleType"/>
to
<xs:element name="Value_component"/>

With this change code above produces:
Unit:->id
System_breakdown:->id
Document_version:->id
Breakdown_element_realization:->id
Date_or_date_time_assignment:->id
System_element_version:->id
System_breakdown_context:->id
Part_view_definition:->id
View_definition_context:->id
Product:->id
PLCS_Part:->id
Document_assignment:->id
System_element:->id
Document:->id
Calendar_date:->id
Digital_file:->id
Next_assembly_usage:->id
Value_with_unit:->id
Identification_assignment:->id
Part_version:->id
Digital_document_definition:->id
System_element_usage:->id
System_breakdown_version:->id
System_element_definition:->id
LPD_PLCS_Schema:->id
LPD_PLCS_Schema:->version_id
The idea being that the user can enter a string and then specify to search
for the string in a particular complexType ...i.e the XPATH is built in real
time and the types are available to the user as a dropdown list.

Hmm, you may want to clarify what do you mean here :)
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Hi Again Oleg,

Thanks. I got this running. After sending the mail I was actually reading up
on the MS website and was just discovering the SOM...

Cheers
Rohit

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
Rohit Sharma wrote:
Then for each of them i need the attributes...like
Product : -> ID
Product: -> Product_Name
Product: -> description

and so on...
That's pretty easy. Learn about Schema object model (SOM) and
System.Xml.Schema namespace. The idea is to read schema file, compile it

into an object model, then for each complex type defined iterate over its declared attributes:
public class Class1 {
public static void Main(string[] args) {
XmlSchema schema = XmlSchema.Read(new
StreamReader("LPD_PLCS_Schema.xsd"),
new ValidationEventHandler(ShowCompileError));
schema.Compile(new ValidationEventHandler(ShowCompileError));
foreach (XmlSchemaType t in schema.SchemaTypes.Values) {
XmlSchemaComplexType type = t as XmlSchemaComplexType;
if (type != null) {
foreach (XmlSchemaAttribute attr in type.Attributes)
Console.WriteLine("{0}:->{1}", type.Name, attr.Name);

}
}
}
private static void ShowCompileError(object sender, ValidationEventArgs e) { Console.WriteLine("Validation Error: {0}", e.Message);
}

}

Note, that one cannot use xs:anySimpleType type directly in schema using ..NET. It's "implied" type, each simple type derives from by definition. So change <xs:element name="Value_component" type="xs:anySimpleType"/>
to
<xs:element name="Value_component"/>

With this change code above produces:
Unit:->id
System_breakdown:->id
Document_version:->id
Breakdown_element_realization:->id
Date_or_date_time_assignment:->id
System_element_version:->id
System_breakdown_context:->id
Part_view_definition:->id
View_definition_context:->id
Product:->id
PLCS_Part:->id
Document_assignment:->id
System_element:->id
Document:->id
Calendar_date:->id
Digital_file:->id
Next_assembly_usage:->id
Value_with_unit:->id
Identification_assignment:->id
Part_version:->id
Digital_document_definition:->id
System_element_usage:->id
System_breakdown_version:->id
System_element_definition:->id
LPD_PLCS_Schema:->id
LPD_PLCS_Schema:->version_id
The idea being that the user can enter a string and then specify to search for the string in a particular complexType ...i.e the XPATH is built in real time and the types are available to the user as a dropdown list.

Hmm, you may want to clarify what do you mean here :)
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4

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

Similar topics

3
by: Kunle Odutola | last post by:
I have a database that tracks players for children's sports clubs. I have included representative DDL for this database at the end of this post. A single instance of this database supports...
9
by: Robert Brown | last post by:
Our customer (of our ecommerce system) wants to be able to preserve deleted entities in the database so that they can do reporting, auditing etc. The system is quite complex where each end user...
5
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that...
2
by: kamp | last post by:
Hello, Below is a snippet from a schema. The second enumeration should contain an i umlaut (archaïsch) but when I use this schema with Altova's Stylevision software the iumlaut is not displayed...
1
by: suresh | last post by:
How can I use HTML character entities in my xml file? it has reference of Schema file(.xsd) which has fixed structure defined by our client. so without disturbing to schema, I want to use...
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: Mike Jansen | last post by:
Does anyone know why if I create a complexType based off another complexType using xsd:extension the attributes don't seem to be inherited? Is this a bug/non-implementation in the .NET Schema...
4
by: craig.wagner | last post by:
I have a situation where I need to carry additional information in an XML Schema. What I've found to appear to work is doing something like the following: <xs:schema xmlns:xs="...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.