13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 3-12: The XmlSchemaObject class and some of its descendants.The Items collection picks up all the top-level elements found below the root node. All elements that can be safely cast to XmlSchemaComplexTypehave their Name property checked aga<strong>in</strong>st the requested type, as shown here:XmlSchemaComplexType GetComplexType(XmlSchema schema, str<strong>in</strong>gtypeName){XmlSchemaComplexType ct;<strong>for</strong>each(XmlSchemaObject o <strong>in</strong> schema.Items){if (o is XmlSchemaComplexType){ct = (XmlSchemaComplexType) o;if (ct.Name == typeName)return ct;}}}return null;Once a reference to the complex type has been found, the code proceeds by creat<strong>in</strong>gthe new schema element. The relative type is declared <strong>in</strong>-l<strong>in</strong>e <strong>in</strong> the103

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!