A
aevans1108
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.
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.