XML validation: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
Line 1,106:
{{trans|Nim}}
{{libheader|libxml2}}
Although Wren has nothird XMLparty support whateverfor XML, eitherit built-indoes ornot (AFAIK)support viavalidation thirdagainst an XSD partiesschema. We therefore use an
embedded program so we can ask the C host to communicate with Libxml2 for us.
<syntaxhighlight lang="ecmascriptwren">/* xml_validationXML_validation.wren */
 
class Args {
Line 1,158:
<br>
We now embed this in the following C program, compile and run it.
<syntaxhighlight lang="c">/* built with: gcc xml_validationXML_validation.c -o xml_validationXML_validation -I/usr/include/libxml2 -lxml2 -lwren -lm */
 
#include <stdio.h>
Line 1,300:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "xml_validationXML_validation.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 1,319:
 
{{out}}
Using command <code>./xml_validationXML_validation shiporder.xml shiporder.xsd</code>:
<pre>'shiporder.xml' validates.</pre>
Using a modified file “shiporder1.xml” where tag “orderperson” has been replaced by “orderperson1”:
9,485

edits