[libxml-devel] Namespace issue with validate_schema?

15 views
Skip to first unread message

Jonathan Bartels

unread,
Jan 2, 2009, 11:16:29 AM1/2/09
to libxml...@rubyforge.org
This is likely a PEBKAC issue rather than a bug. I hope I'm submitting
to the right list.

I'm getting different validation results from libxml in Ruby than I am
from a command-line tool (xmllint). I'm using a schema definition from
ASTM to validate the output, for what it cost me the schema should be
correct. I'm using libxml 0.9.4.

The XML I'm validating is:
**************
<?xml version="1.0"?>
<ContinuityOfCareRecord xmlns="urn:astm-org:CCR" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:astm-
org:CCR CCR1.0.xsd">
<CCRDocumentObjectID>a4941200-bb14-012b-4b05-001a6b46d85c</
CCRDocumentObjectID>
<Language>
<Text>English</Text>
</Language>
<Version>V1.0</Version>
<DateTime>
<ExactDateTime>2009-01-02T11:02:13-05:00</ExactDateTime>
</DateTime>
</ContinuityOfCareRecord>
*************

The code and output from libxml is:
**************
schema_doc = XML::Document.file("#{RAILS_ROOT}/ADJE2369.18405.xml")
schema = XML::Schema.document(schema_doc)

@@ccr.validate_schema(schema)
Error: Element 'CCRDocumentObjectID': This element is not expected.
Expected is ( {urn:astm-org:CCR}CCRDocumentObjectID ). at :0.
LibXML::XML::Error: Error: Element 'CCRDocumentObjectID': This element
is not expected. Expected is ( {urn:astm-org:CCR}
CCRDocumentObjectID ). at :0.
from /home/jon/EXTENSION/Core/branches/TrustBearer/lib/ccr.rb:86:in
`validate_schema'
from /home/jon/EXTENSION/Core/branches/TrustBearer/lib/ccr.rb:86:in
`validate'
from (irb):1
************

The command and output from xmllint is:
*******
jon@TPX-70002:~$ xmllint --schema ~/Documents/books\ \&\ guides/CCR/
ADJE2369.18405.xml ./test_ccr.xml

./test_ccr.xml:2: element ContinuityOfCareRecord: Schemas validity
error : Element '{urn:astm-org:CCR}ContinuityOfCareRecord': Missing
child element(s). Expected is ( {urn:astm-org:CCR}Patient ).
./test_ccr.xml fails to validate
*************

I expect a failure, since I haven't added a required node yet
(Patient), but I'm trying to reconcile the discrepancy between xmllint
and libxml.

I believe the namespace declaration in the root node is correct, I
would expect since xmlns="urn:astm-org:CCR" is declared that it would
be used on the root node and all children.

Is this a usage error on my part? Am I misusing libxml or is the xml
incorrect?

If this is a bug, has it been patched? If not, what information can I
provide to help get it fixed?

Thanks for your help and thanks for creating and publishing libxml for
Ruby!

_______________________________________________
libxml-devel mailing list
libxml...@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Charlie Savage

unread,
Jan 7, 2009, 4:11:59 PM1/7/09
to libxml...@rubyforge.org

> This is likely a PEBKAC issue rather than a bug. I hope I'm submitting
> to the right list.
>
> I'm getting different validation results from libxml in Ruby than I am
> from a command-line tool (xmllint). I'm using a schema definition from
> ASTM to validate the output, for what it cost me the schema should be
> correct. I'm using libxml 0.9.4.
>
>
> I expect a failure, since I haven't added a required node yet
> (Patient), but I'm trying to reconcile the discrepancy between xmllint
> and libxml.

Yeah, that sure is interesting. My first thought is if libxml-ruby is
using the same version of libmxl that xmllint is using? Is this on
Windows, Linux, OS X or some other OS?

> Is this a usage error on my part? Am I misusing libxml or is the xml
> incorrect?
>
> If this is a bug, has it been patched? If not, what information can I
> provide to help get it fixed?

I see the xml you are validating, but can you provide the schema? Mind
submitting a bug report at ruby forge?

http://rubyforge.org/tracker/?group_id=494

Charlie

Jonathan Bartels

unread,
Jan 8, 2009, 9:43:57 AM1/8/09
to libxml...@rubyforge.org

> Yeah, that sure is interesting. My first thought is if libxml-ruby is
> using the same version of libmxl that xmllint is using?  Is this on
> Windows, Linux, OS X or some other OS?

This is on Ubuntu 8.04, dpkg reports the following for libxml:
libxml1 1:1.8.17-14.1
libxml2 2.6.31.dfsg-2ubuntu1.3

> I see the xml you are validating, but can you provide the schema?  Mind
> submitting a bug report at ruby forge?

Legally, I cannot submit the schema. It is the ASTM CCR standard
(E2369–05). Access is fee based and the schema is not redistributable.
I may be able to post snippets as part of debugging things.

> http://rubyforge.org/tracker/?group_id=494

I'll file a bug report later today and follow it. Given that I can't
submit the schema I'll attempt to do some debugging/testing/patching
myself. Ideally I'd be able to reproduce it with a much simpler use
case than this particular XML standard.

Reply all
Reply to author
Forward
0 new messages