[erlang-questions] xmerl and DTD

Arndt Jonasson arndt@REDACTED
Tue Oct 24 16:28:57 CEST 2006


I have problems using xmerl to validate an XML document using a DTD.

The DTD looks like this:
    <!ELEMENT a1 (d, (b | c)*)>
    <!ELEMENT a2 (d | b | c)*>

    <!ELEMENT b EMPTY>
    <!ELEMENT c EMPTY>
    <!ELEMENT d EMPTY>

The document looks like this:
    <a1>

      <d/>

      <b/>

      <c/>

    </a1>

When I do

xmerl_scan:file("test.xml", [{doctype_DTD, "test.dtd"}, {validation, true}])

I get this crash:

    535- fatal: {failed_validation,{function_clause,
				       [{xmerl_validate,
					    choice,
					    [[b,c],
					     [],
					     37,
					     remove,
					     {xmerl_scanner,
						 undefined,
						 no,
   ...

If I change the a1 elements in the document to a2 (i.e., using a simpler
DTD element rule), the scan+validation work. If I remove all whitespace
in the a1 document, it works too. If my document looks like this:

    <a1>

      <d/>

      <b/>

      <c/></a1>

it works too. So whitespace as such seems not to be the problem, but
it is not tolerated at one particular point.

('xmllint' declares the original document valid, by the way.)

Am I doing something wrong, have misunderstood something, or is this a
bug in xmerl?



More information about the erlang-questions mailing list