XML architecture-read and write Architecture

Source: Internet
Author: User
Read/write Architecture

This example illustrates how to read the XML Schema Definition Language (XSD) file to the schema object model (SOM. This example then writes the XSD Schema that has been loaded into the memory to stringwriter to display it on the screen. You can also use xmlwriter to write the schema to a file.

The SOM provides a set of classes that directly reflect the W3C XSD specifications. The classes, methods, and attributes of XMLSCHEMA can be used to create an in-memory version of the schema. The schema version can be compiled through xmlschemacollection and used for verification.

XMLSCHEMA can load and save valid XSD architectures. It also has a strongly typed class that can be used to create an in-memory architecture. For verification, xmlschemacollection and xmlvalidatingreader classes can use XMLSCHEMA.

 

VB xmlreadwriteschema. aspx

[Running example] | [View Source Code]

You can use XMLSCHEMA to load and/or create a valid schema. In this example, only one simple architecture is loaded from the file.


private const String document = "sample.xsd";            ...            XmlSchema mySchema = XmlSchema.Read(new XmlTextReader(document));            
private const document as String = "sample.xsd"            ...            Dim mySchema as XmlSchema  = XmlSchema.Read(new XmlTextReader(document))            
C # VB  

After loading, this example writes the schema to stringwriter and displays the stringwriter on the screen.

mySchema.Write(myXmlWriter);            Console.WriteLine(myStringWriter.ToString());            
mySchema.Write(myXmlWriter)            Console.WriteLine(myStringWriter.ToString())            
C # VB  

Summary
  1. The schema object model (SOM) provides a set of browsed classes that directly reflect W3C XSD specifications.
  2. Som is created for each imported and contained architecture, which is retained in the inclusion set.
  3. An item set is a list of all schema element types at the architecture level in the loaded architecture. This list can be used continuously.
  4. In addition to this list, it also provides hash tables for all elements, attributes, and other elements generated by referenced architectures (that is, those in the contained architecture, these tables reference All Schema element types at the schema level. This provides a convenient mechanism for searching element names.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.