473,326 Members | 2,136 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,326 software developers and data experts.

XmlSchema: get basic type of XmlSchemaAttribute?

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 defined as follows:

<xs:simpleType name="abc">
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />
<xs:enumeration value="C" />
</xs:restriction>
</xs:simpleType>

Now suppose one of my elements has an attribute whose type
is the "abc" type shown above, as in:

<xs:attribute name="attribute1" type="abc" />

If I navigate through the SOM to find the attribute,
my XmlSchemaAttribute object will have its SchemaTypeName.Name
property set to "abc".

My question is: how do I find out the basic type of the
attribute? I simply want to know that it's based on the
xs:string built-in type, but I can't find any way to
do that using the SOM...
Nov 12 '05 #1
2 1636
Hi Gary

How about this. Reads the schema, gets a simple type whose name is abc, then
looks at the base type.

HTH

Nigel Armstrong

Dim fs As New IO.FileStream("C:\test.xsd", IO.FileMode.Open)
Dim s As Xml.Schema.XmlSchema = Xml.Schema.XmlSchema.Read(fs, Nothing)
s.Compile(Nothing)
fs.Close()
Dim ot As Xml.Schema.XmlSchemaObjectTable = s.SchemaTypes
Dim st As Xml.Schema.XmlSchemaSimpleType = CType(ot.Item(New
Xml.XmlQualifiedName("abc")), Xml.Schema.XmlSchemaSimpleType)
MessageBox.Show(st.BaseSchemaType.ToString())
"Gary McGill" wrote:
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 defined as follows:

<xs:simpleType name="abc">
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />
<xs:enumeration value="C" />
</xs:restriction>
</xs:simpleType>

Now suppose one of my elements has an attribute whose type
is the "abc" type shown above, as in:

<xs:attribute name="attribute1" type="abc" />

If I navigate through the SOM to find the attribute,
my XmlSchemaAttribute object will have its SchemaTypeName.Name
property set to "abc".

My question is: how do I find out the basic type of the
attribute? I simply want to know that it's based on the
xs:string built-in type, but I can't find any way to
do that using the SOM...

Nov 12 '05 #2
Nigel,

I tried that, but what it actually gets is the name of the .NET class used
to represent the type (such as System.Xml.Schema.Datatype_string") rather
than the qualified name of the type (such as "string" or "positiveInteger").

I suppose I could use the bit after the "_" but that sounds ugly - surely
there must be a better way?

Gary

"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:FF**********************************@microsof t.com...
Hi Gary

How about this. Reads the schema, gets a simple type whose name is abc, then looks at the base type.

HTH

Nigel Armstrong

Dim fs As New IO.FileStream("C:\test.xsd", IO.FileMode.Open)
Dim s As Xml.Schema.XmlSchema = Xml.Schema.XmlSchema.Read(fs, Nothing)
s.Compile(Nothing)
fs.Close()
Dim ot As Xml.Schema.XmlSchemaObjectTable = s.SchemaTypes
Dim st As Xml.Schema.XmlSchemaSimpleType = CType(ot.Item(New
Xml.XmlQualifiedName("abc")), Xml.Schema.XmlSchemaSimpleType)
MessageBox.Show(st.BaseSchemaType.ToString())
"Gary McGill" wrote:
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 defined as follows:

<xs:simpleType name="abc">
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />
<xs:enumeration value="C" />
</xs:restriction>
</xs:simpleType>

Now suppose one of my elements has an attribute whose type
is the "abc" type shown above, as in:

<xs:attribute name="attribute1" type="abc" />

If I navigate through the SOM to find the attribute,
my XmlSchemaAttribute object will have its SchemaTypeName.Name
property set to "abc".

My question is: how do I find out the basic type of the
attribute? I simply want to know that it's based on the
xs:string built-in type, but I can't find any way to
do that using the SOM...

Nov 12 '05 #3

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: Rumen Traykov via .NET 247 | last post by:
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...
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..
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"...
1
by: Ryan | last post by:
Hello Xml Gurus, I'm trying to build an XML schema in memory using the System.Xml.XmlSchema namespace objects, validate it, and then write it to a file. The problem I'm facing is that...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.