[xml] Question - Error in definition of DTD or error in libxml2 validation?



I was checking some files with xmllint from libxml2 and had an error.
I made a sample to simplify it for demonstration.  My question is
"Is this an error in the validation checking done by xmllint or am
I misinterpreting the alteration construct? ". The code follows but
the question boils down to the <!ELEMENT item (val* | min-val)>
definition.  I would have thought that this would require one
min-val OR zero or more val elements.  Instead, xmllint seems
to complain if there are no elements.  By adding a '?' as shown,
the problem goes away.  Does alteration require that something exist?
I glanced at the XML spec but didn't find this but could have
missed it easily.

I don't know of another package that I have that I could have 
tried the same sample with.  For now, I have added the '?', but
want to know if the original was correct and if a bug exists in the
validation code.

Thanks,
Brian

-----samp.xml---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE items [
  <!ELEMENT items (item)+>

  <!--  <!ELEMENT item (val* | min-val)?> --> <!-- This one works -->
  <!ELEMENT item (val* | min-val)> <!-- This one doesn't work -->
  <!ATTLIST item name      CDATA #REQUIRED>

  <!ELEMENT val EMPTY>
  <!ATTLIST val qty       CDATA #REQUIRED>

  <!ELEMENT min-val EMPTY>
  <!ATTLIST min-val qty       CDATA #REQUIRED>
]>

<items>
  <item name="A">
        <val qty="1"/>
  </item>
  <item name="B">
        <min-val qty="3"/>
  </item>
  <item name="C"></item>
  <item name="D"/>
</items>
----- End of samp.xml---------
-----Output --------------
% xmllint --noout --valid samp.xml
samp.xml:23: validity error: Element item content doesn't follow the Dtd
Expecting (val* | min-val), got 
  <item name="C"></item>
                       ^
samp.xml:24: validity error: Element item content doesn't follow the Dtd
Expecting (val* | min-val), got 
  <item name="D"/>
                 ^
%
--------End of Output ---------




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