Skip to content

Commit cb46620

Browse files
Ron PetrushaBillWagner
andauthored
Added information on schema validation errors (#2498)
* Added information on schema validation errors * Update xml/System.Xml.Schema/XmlSchemaSet.xml Co-Authored-By: Bill Wagner <[email protected]>
1 parent eabd6b3 commit cb46620

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

xml/System.Xml.Schema/XmlSchemaSet.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
5252
5353
## Examples
54-
The following example validates an XML file using schemas stored in the <xref:System.Xml.Schema.XmlSchemaSet>. The namespace in the XML file, `urn:bookstore-schema`, identifies which schema in the <xref:System.Xml.Schema.XmlSchemaSet> to use for validation.
54+
The following example validates an XML file using schemas stored in the <xref:System.Xml.Schema.XmlSchemaSet>. The namespace in the XML file, `urn:bookstore-schema`, identifies which schema in the <xref:System.Xml.Schema.XmlSchemaSet> to use for validation. Output from the example shows that the XML file has two schema violations:
55+
56+
- The first \<book> element contains an \<author> element but no \<title> or \<price> element.
57+
58+
- The \<author> element in the last \<book> element is missing a \<first-name> and \<last-name> element and instead has an invalid \<name> element.
5559
5660
[!code-cpp[XmlReader_Validate_SchemaSet#1](~/samples/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp#1)]
5761
[!code-csharp[XmlReader_Validate_SchemaSet#1](~/samples/snippets/csharp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CS/validschemaset.cs#1)]
@@ -68,11 +72,6 @@
6872
6973
[!code-xml[XmlReader_Validate_SchemaSet#3](~/samples/snippets/xml/VS_Snippets_Data/XmlReader_Validate_SchemaSet/XML/books.xsd#3)]
7074
71-
## Output
72-
Validation Error: The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author' in namespace 'urn:bookstore-schema'. Expected 'title' in namespace 'urn:bookstore-schema'.
73-
74-
Validation Error: The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name' in namespace 'urn:bookstore-schema'. Expected 'first-name' in namespace 'urn:bookstore-schema'.
75-
7675
]]></format>
7776
</remarks>
7877
</Docs>
@@ -1592,4 +1591,4 @@ foreach (XmlSchema schema in schemaSet.Schemas("http://www.contoso.com/books"))
15921591
</Docs>
15931592
</Member>
15941593
</Members>
1595-
</Type>
1594+
</Type>

0 commit comments

Comments
 (0)