Stan Kitsis

XML Tools and all things schema in system.xml and MSXML

XML Editor in VS2005: Support for inline schemas

The XML Editor provides support for Inline Schemas.  Inline schemas are XML schema definitions included inside XML instance documents.  They can be used to validate that the rest of the XML matches the schema constraints in the same way that external schema documents can be used.   Likewise, the syntax and semantics of inline schemas are the same as for external schemas. Inline schemas can be useful in a number of situations, including:

·          An architecture where internal DTDs were used and the developers wish to preserve that design pattern.

·          It is difficult to access external files or URLs, e.g. for security or platform reasons.

·          There is too much diversity in the set of schemas and instances that a system must process, so it is easiest to simply keep the schema as an integral part of the XML document.

 

The following XML snippet contains an example of using an inline schema. 

 

<?xml version="1.0" encoding="utf-8"?>

<root xmlns:inl="http://inline">

 

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://inline"

             xmlns="http://inline"

             elementFormDefault="qualified"

             attributeFormDefault="unqualified">

    <xs:element name="parent">

      <xs:complexType>

        <xs:sequence>

          <xs:element name="child" type="xs:string"/>

        </xs:sequence>

      </xs:complexType>

    </xs:element>

  </xs:schema>

 

  <inl:parent>

    <inl:child>text</inl:child>

  </inl:parent>

 

</root>

 

You can change the inline schema and the XML Editor will pick up those changes immediately and use the updated schema for validation and intellisense.  For example, if you change the <child> element’s type from xs:string to xs:int, you will get a validation error.

Published Friday, September 23, 2005 4:29 PM by skits
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Ron Cundiff's WebLog said:

Oops. With all of the excitement of doing 2 webcasts in one day yesterday, I forgot to blog the wrap-up

February 14, 2007 5:17 PM
 

Software Information » Stan Kitsis : XML Editor in VS2005: Support for inline schemas said:

January 26, 2008 11:10 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker