Re: [xml] Help with dtd, and XML_PARSE_PEDANTIC

On Tue, Dec 19, 2006 at 01:13:55PM +0000, chinlu chinawa wrote:

I'm validating a xml document via xmlCtxtReadFile,
with the flags XML_PARSE_DTDVALID |

The problem I'm finding is with the structure of my
document which looks like this:

  <title>bla bla</title>
  <answer>bla bla</answer>
  <correct-answer>bla bla</correct-answer>
  <image>bla bla</image>

There can be more than one possible <answer>, but only
one mandatory <correct-answer> per question, and zero
or one <image>.

Then I thought on letting the user being able to put
those nodes in the order he/she felt like doing it,
though I think this is not actually possible, is it?

At dtd validation time "positional-strictness"
applies, and there's no way I can do it (or I haven't
achieved it, have tried many different dtd
constructions for a while)

So I wonder if someone can confirm me that I'm forced
to provide a static structure so users would have to
build the document strictly as dtd says is should
(same order), or if there's someway I could have the
document well validated while letting the users chuck
these nodes in an arbitrary order?

  It's a limitation of DTDs, in XSD there is the xsd:all construct,
in RNG there is the interleave construct. With DTD you must specify 
explicitely all the orders possible e.g:

   (a, b, c) | (a, c, b) | (b, a, c) | (b, c, a) ...

 of course with 4-5 elements it's already a serious problem.
 Conclusion: DTD are extremely limited
 Also this has nothing to do with XML_PARSE_PEDANTIC, but with validation


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]