By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,018 Members | 967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,018 IT Pros & Developers. It's quick & easy.

XmlSchema: get basic type of XmlSchemaAttribute?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.