472,799 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 software developers and data experts.

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 2868
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 ....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.