blob: 2b5df57ee2a06375a9fda690a9614e4136581e31 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<meta charset="utf-8"/>
<title>ValidateCsv</title>
<link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/>
</head>
<body>
<h2>Usage Information</h2>
<p>
In order to fully validate XML, a schema must be provided. The ValidateXML processor allows the schema to be specified in the
property 'Schema File'. The following example illustrates how an XSD schema and XML data work together.
</p>
<p>Example XSD specification</p>
<p>
<pre>
&ltxs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://namespace/1" xmlns:tns="http://namespace/1" elementFormDefault="unqualified"&gt
&ltxs:element name="bundle" type="tns:BundleType"&gt&lt/xs:element&gt
&ltxs:complexType name="BundleType"&gt
&ltxs:sequence&gt
&ltxs:element name="node" type="tns:NodeType" maxOccurs="unbounded" minOccurs="0"&gt&lt/xs:element&gt
&lt/xs:sequence&gt
&lt/xs:complexType&gt
&ltxs:complexType name="NodeType"&gt
&ltxs:sequence&gt
&ltxs:element name="subNode" type="tns:SubNodeType" maxOccurs="unbounded" minOccurs="0"&gt&lt/xs:element&gt
&lt/xs:sequence&gt
&lt/xs:complexType&gt
&ltxs:complexType name="SubNodeType"&gt
&ltxs:sequence&gt
&ltxs:element name="value" type="xs:string"&gt&lt/xs:element&gt
&lt/xs:sequence&gt
&lt/xs:complexType&gt
&lt/xs:schema&gt
</pre>
</p>
<p>Given the schema defined in the above XSD, the following are valid XML data.</p>
<p>
<pre>
&ltns:bundle xmlns:ns="http://namespace/1"&gt
&ltnode&gt
&ltsubNode&gt
&ltvalue&gtHello&lt/value&gt
&lt/subNode&gt
&ltsubNode&gt
&ltvalue&gtWorld!&lt/value&gt
&lt/subNode&gt
&lt/node&gt
&lt/ns:bundle&gt
</pre>
</p>
<p>
<pre>
&ltns:bundle xmlns:ns="http://namespace/1"&gt
&ltnode&gt
&ltsubNode&gt
&ltvalue&gtHello World!&lt/value&gt
&lt/subNode&gt
&lt/node&gt
&lt/ns:bundle&gt
</pre>
</p>
<p>The following are invalid XML data. The resulting <span style="font-family: monospace">validatexml.invalid.error</span> attribute is shown.
<pre>
&ltns:bundle xmlns:ns="http://namespace/1"&gt
&ltnode&gtHello World!&lt/node&gt
&lt/ns:bundle&gt
<br> validatexml.invalid.error: cvc-complex-type.2.3: Element 'node' cannot have character [children], because the type's content type is element-only.
</pre>
</p>
<p>
<pre>
&ltns:bundle xmlns:ns="http://namespace/1"&gt
&ltnode&gt
&ltvalue&gtHello World!&lt/value&gt
&lt/node&gt
&lt/ns:bundle&gt
<br> validatexml.invalid.error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'value'. One of '{subNode}' is expected.
</pre>
</p>
</body>
</html>