Hi Steve,
Thanks, another user pointed me to the solution which it turns out is
documented under the DOM manual. I hope they won't mind if I copy their code
below for other readers. I initially verified my XML and XSD using a web
service, then confirmed that validation is working correctly as you
suggested.
I'm still not entirely clear what results from using the validation option
with just the tclxml package, as documented here:
http://tclxml.sourceforge.net/tclxml/3.2/tclxml.html#id19102.
By the way I notice that "cget -parser" raises an error, but "cget *
-option: Returns the current value of the configuration option given by
option. Option may have any of the values accepted by the parser object."*
#####################################
package require xml
package require xml::libxml2
package require dom
# Reads the document to validate
set text [read [open
/xmlfiles/atmoa4_atmos_smioc.xml
]]
set doc [dom::parse $text]
# Reads the validating schema
set schema_text [read [open
/xmlfiles/smioc.xsd
]]
set schema_doc [dom::parse $schema_text]
# Compile the schema
$schema_doc schema compile
# Do the actual validation
$schema_doc schema validate $doc
On Thu, Sep 10, 2009 at 7:10 AM, Steve Ball <Ste...@ex...>wrote:
> Hi Ben,
>
> TclXML/libxml2 v3.2 supports XSD schema validation and the upcoming v3.3
> will support RelaxNG schema validation. Schema validation is usually
> performed post-parsing, upon the document DOM tree; I'll need to check
> whether validation works as expected during parsing.
>
> Anyway, sometime today I'll see if I can post an example on the Tcl Wiki.
> For another example see the tkxmllint application.
>
> Also, if you want to confirm that the XSD parsing is working then the
> easiest way to do that would be to feed a known schema-invalid document into
> the system and check that it correctly reports an error. You can also feed
> it a deliberately incorrect schema document and check that it fails at the
> compilation stage.
>
> Cheers,
> Steve Ball
>
>
|