Output for Example 4: Validating with an Inline XSD Schema (C-C++)

 

This topic shows the expected output for the following examples:

When you build and run any of these examples, their output should appear as follows:

Validation succeeded for valid.xml  
===================================  
<?xml version="1.0"?>  
<catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema">  
  <!-- START OF SCHEMA -->  
    <xsd:schema>  
      <xsd:element name="book">  
         <xsd:complexType>  
            <xsd:sequence>  
               <xsd:element name="author" type="xsd:string"/>  
               <xsd:element name="title" type="xsd:string"/>  
               <xsd:element name="genre" type="xsd:string"/>  
               <xsd:element name="price" type="xsd:float"/>  
               <xsd:element name="publish_date" type="xsd:date"/>  
               <xsd:element name="description" type="xsd:string"/>  
            </xsd:sequence>  
           <xsd:attribute name="id" type="xsd:string"/>  
         </xsd:complexType>  
      </xsd:element>  
    </xsd:schema>  
<!-- END OF SCHEMA -->  
  <book id="bk101">  
    <author>Gambardella, Matthew</author>  
    <title>XML Developer's Guide</title>  
    <genre>Computer</genre>  
    <price>44.95</price>  
    <publish_date>2000-10-01</publish_date>  
    <description>An in-depth look at creating applications with  
      XML.</description>  
    </book>  
</catalog>  
  
Validation failed on notValid.xml  
==================================  
Reason: Element 'cost' is unexpected according to content model of parent element ''{urn:book}book'.  
Expecting: price.  
  
Source:       <cost>44.95</cost>  
Line: 25  

This is because the correct and valid name for the element in use at this location in the XML documents is <price/>, not <cost/>.