473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using annotations in .xsd file to pass metadata

I'm very new to xml, and struggling a bit..

I want to use an .xsd file passed to a windows application to define a
dataset's schema, and also (if possible) pass other metadata associated with
given elements of the schema (tables and columns) that the application also
requires. I've guessed that Annotations are a way to do this, so added
<xs:annotation> elements to the xsd file (see example below).

I can set up the dataset fine:

Dim ds As New DataSet()
ds.ReadXmlSchema("XMLSchema1.xsd")

All tables and columns set up beautifully. But what object do I use to get
at the metadata in the annotations, and associate it easily with the
relevant tables and columns within the dataset? I've played with the
xmlDataDocument class, the xmlSchemaAnnotated class, and various others, but
I'm fast losing contact with the ground...

Alternatively, is there a better way to pass such metadata?

Thanks!

Jonathan

Here's the sample xsd file:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Table1">
<xs:complexType>
<xs:annotation>
<xs:appinfo>Meta data about Table1</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="ID1" type="xs:integer">
<xs:annotation>
<xs:appinfo>Metat data about column ID1</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Text1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:annotation>
<xs:appinfo>Meta data about Table2</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="ID2" type="xs:integer" />
<xs:element name="Text2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Nov 11 '05 #1
1 2905
Thanks for the suggestion.
XmlSchema class yes - but it's difficult to align this with the dataset's
inferred tables and columns.

I think I've cracked it another way (by checking what happens to the xml
when I create a dataset the way I want it, then use WriteXMLSchema to see
what xml it generates). The ExtendedProperties property of a table or column
emerges in xml like this:

<xs:element name="Table1" msprop:MyTableProperty="MyTablePropertyValue">

It looks like I can use this msprop: namespace to create the metadata I need
and have it transported into ExtendedProperties properties within the tables
and columns, where it's easy to get at.

Jonathan
"Dare Obasanjo [MSFT]" <da***@online.microsoft.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
Have you tried using the XmlSchema class?

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jonathan Gibbs" <jo******************@dial.pipex.com> wrote in message
news:4L******************@news-text.cableinet.net...
I'm very new to xml, and struggling a bit..

I want to use an .xsd file passed to a windows application to define a
dataset's schema, and also (if possible) pass other metadata associated

with
given elements of the schema (tables and columns) that the application

also
requires. I've guessed that Annotations are a way to do this, so added
<xs:annotation> elements to the xsd file (see example below).

I can set up the dataset fine:

Dim ds As New DataSet()
ds.ReadXmlSchema("XMLSchema1.xsd")

All tables and columns set up beautifully. But what object do I use to get at the metadata in the annotations, and associate it easily with the
relevant tables and columns within the dataset? I've played with the
xmlDataDocument class, the xmlSchemaAnnotated class, and various others,

but
I'm fast losing contact with the ground...

Alternatively, is there a better way to pass such metadata?

Thanks!

Jonathan

Here's the sample xsd file:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Table1">
<xs:complexType>
<xs:annotation>
<xs:appinfo>Meta data about Table1</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="ID1" type="xs:integer">
<xs:annotation>
<xs:appinfo>Metat data about column ID1</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Text1" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:annotation>
<xs:appinfo>Meta data about Table2</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="ID2" type="xs:integer" />
<xs:element name="Text2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Nov 11 '05 #2

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

Similar topics

4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
9
by: Dr. Know | last post by:
Greetings, I am running IIS on W2kServer and am trying to use ASP with some legacy X-Base tables. I cannot get the provider to connect. Relevant code is: strProvider =...
6
by: Nathan Kovac | last post by:
Yesterday afternoon I was getting the following errors in a windows service: 'DatabaseManager.DataComponent', 'Error', '3 Errors: Line: 0 - Metadata file 'ScriptingMethods.dll' could not be found...
2
by: EP | last post by:
I'm looking for a method by which to access Windows files metadata and have not been able to find anything in the standard modules or via Google - what is the standard approach? Shamefully I...
8
by: oripel | last post by:
Hi, I'm trying to attach some attributes to functions and methods, similar to Java annotations and .NET attributes. I also want to use a convenient decorator for it, something along the lines...
6
by: gregarican | last post by:
I am trying to port a legacy CTI application written in another programming language to C# 2005. From my initial research into it I see I can utilize the DllImport method to tap into the DLL file...
1
by: spatro | last post by:
Hi, I am trying to install DBD::mysql using the CPAN and I am facing the following error: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Warning:...
44
by: John Dann | last post by:
I'm unclear as to how best to use what I'm terming the top-level CSS selectors, by which I mean selectors like *, html and body. I'm coming at this from trying to understand how best to set font...
5
by: Luis Zarrabeitia | last post by:
I need to parse a file, text file. The format is something like that: TYPE1 metadata data line 1 data line 2 .... data line N TYPE2 metadata data line 1 ....
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,...
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...
1
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.