Skip to content

Commit 6cec9f2

Browse files
authored
Merge pull request #12 from berghall/issue_7
issue_7: Document the Xml.Validate Task
2 parents 1cab403 + cdb1f32 commit 6cec9f2

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,93 @@ Create a XSLT transformation.
114114
#### Result
115115
string
116116

117+
### Xml.Validate
118+
119+
Validate XML against XML Schema Definitions.
120+
121+
#### Input
122+
123+
| Property | Type | Description |
124+
|-----------------|----------|----------------------------------|
125+
| Xml | string | XML to validate |
126+
| XsdSchemas | string[] | List of XML Schema Definitions |
127+
128+
#### Options
129+
130+
| Property | Type | Description |
131+
|--------------------------|------------------|--------------------------------------|
132+
| ThrowOnValidationErrors | bool | Throw exception on validation error. |
133+
134+
#### Result
135+
136+
| Property | Type | Description |
137+
|------------|--------|--------------------------|
138+
| IsValid | bool | Is the Xml valid or not |
139+
| Error | string | Validation error message |
140+
141+
Example input Xml:
142+
```xml
143+
<?xml version="1.0"?>
144+
<catalog>
145+
<book id="book1">
146+
<author>My favorite author</author>
147+
<title>XML Developer’s Guide</title>
148+
<genre>Markup</genre>
149+
<price>44.95</price>
150+
<publish_date>2002-09-24</publish_date>
151+
<description>An in-depth look at creating applications with XML.</description>
152+
</book>
153+
</catalog>
154+
````
155+
156+
Example input XSD schema:
157+
```xml
158+
<?xml version="1.0"?>
159+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
160+
<xs:element name="catalog" type="catalogType"/>
161+
<xs:complexType name="bookType">
162+
<xs:sequence>
163+
<xs:element type="xs:string" name="author"/>
164+
<xs:element type="xs:string" name="title"/>
165+
<xs:element type="xs:string" name="genre"/>
166+
<xs:element type="xs:float" name="price"/>
167+
<xs:element type="xs:date" name="publish_date"/>
168+
<xs:element type="xs:string" name="description"/>
169+
</xs:sequence>
170+
<xs:attribute type="xs:string" name="id"/>
171+
</xs:complexType>
172+
<xs:complexType name="catalogType">
173+
<xs:sequence>
174+
<xs:element type="bookType" name="book"/>
175+
</xs:sequence>
176+
</xs:complexType>
177+
</xs:schema>
178+
```
179+
180+
#### Failing example
181+
182+
With the same XSD schema above, this XML:
183+
```xml
184+
<?xml version="1.0"?>
185+
<catalog>
186+
<book id="book1">
187+
<author>My favorite author</author>
188+
<title>XML Developer’s Guide</title>
189+
<genre>Markup</genre>
190+
<price>44.95</price>
191+
<publish_date>2002-09-24-9:00</publish_date>
192+
<description>An in-depth look at creating applications with XML.</description>
193+
</book>
194+
</catalog>
195+
````
196+
197+
would return:
198+
199+
```
200+
IsValid: false
201+
Error: The 'publish_date' element is invalid - The value '2002-09-24-9:00' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:date' - The string '2002-09-24-9:00' is not a valid Date value.
202+
```
203+
117204
### Xml.ConvertJsonToXml
118205
119206
This task takes JSON text and deserializes it into an xml text.

0 commit comments

Comments
 (0)