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

trying to get facets of globally defined xsd:simpleType

Greetings

Please give me a push in the right direction if this the wrong place to
ask this question.

Why is it that I can get the count of facets for an element restriction
if the corresponding simpleType is declared inline, but I can't get it
if the simpleType is globally defined?

Given this schema:

<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:simpleType name="MYTYPE">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Option1" />
<xsd:enumeration value="Option2" />
<xsd:enumeration value="Option3" />
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Element1" default="Option1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Option1" />
<xsd:enumeration value="Option2" />
<xsd:enumeration value="Option3" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Element2" type="MYTYPE" default="Option1">
</xsd:element>
</xsd:schema>

This code:

class Class1
{
const String FILENAME = @"d:\work\schemaTest\schemaTest.xsd";

static void Main()
{
XmlSchema schema = XmlSchema.Read( new XmlTextReader( FILENAME ),
null );
foreach( XmlSchemaObject entry in schema.Items )
{
if( entry is XmlSchemaElement )
{

Console.WriteLine(((XmlSchemaSimpleTypeRestriction )((XmlSchemaSimpleType)(((XmlSchemaElement)entry). SchemaType)).Content).Facets.Count);
}
}
}
}

breaks on the second iteration through the for loop.

I guess my real question is: What's the easiest way to get at the
facets collection of a globally defined type as I'm iterating over
elements in the schema?

I'll appreciate any replies, including guesses.

Thanks in advance for your time.
Tony

PS> I wish google would let me format code prettier.

Nov 16 '05 #1
2 2267
Excuse me -- I should say that it throws an exception on the last
iteration through the loop.

Yes, I know I could build my own type cache and search it by name every
time I encounter the type in the rest of the schema, but there's got to
be a better way than that.

Thanks
Tony

Nov 16 '05 #2
Nevermind - I'll just dereference the SchemaTypes property by name.

It's unfortunate that the XmlSchema object doesn't automatically
amalgamate the base types with the derived types so the above code
fragment would just work.

Nov 16 '05 #3

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

Similar topics

1
by: Ed Slen | last post by:
Hi, Guys! Have a question about xsd restriction: I am having an element "state" and it could be US state (Which is easy) or Canadian postal code which is easy too (both rules are working...
0
by: Brett Selleck | last post by:
We have an issue where the JAXB generated classes are creating an interface which references itself. The Schema is valid, and I have not seen this ran into before. The code is below. What is...
1
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
8
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0"...
0
by: Codex Twin | last post by:
hello group: The following is a fragment from a schema which defines the EWethnicCategoryStructure type. As you can see, its type is defined by the SimpleType enumeration EWethnicCategoryType....
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
0
by: rameshpatnaik | last post by:
If I define xsd:SimpleType for my type in WSDL, what type it will convert when I generate using .NET? Is this xsd:anyType is interoperable or not???
0
by: JamesG | last post by:
Hi all, In my WSDL, I have several constraints on the data structure. The problem is, they aren't being enforced. Take the following two as an example. <xsd:simpleType name="consTokenType">...
2
by: JamesG | last post by:
Hi all, I'm developing a web service, and as part of the WSDL I have the following constraints: <xsd:simpleType name="consTokenType"> <xsd:restriction base="xsd:string"> <xsd:pattern...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.