[xml] RNG error messages?



Daniel--

See session below--is this what you're talking about for not-ideal error message?

Basically, if the attribute "break-after" of the <para> element doesn't validate, xmllint gives a spurious error about "Element ufo has extra content: p".

Thanks.
- - -
% cat ufo.rng
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="http://www.emsoftware.com/NS/UFO"; xmlns="http://relaxng.org/ns/structure/1.0"; datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes";>
  <!-- Top level -->
  <start>
    <choice>
      <ref name="ufo"/>
      <ref name="para"/>
    </choice>
  </start>
  <!-- Data types -->
  <define name="NUMBER">
    <data type="float"/>
  </define>
  <define name="BOOL">
    <choice>
      <value>y</value>
      <value>yes</value>
      <value>n</value>
      <value>no</value>
    </choice>
  </define>
  <define name="ufo">
    <element name="ufo">
      <optional>
        <attribute name="version">
          <ref name="NUMBER"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="source">
          <choice>
            <value>QXP</value>
            <value>ID</value>
          </choice>
        </attribute>
      </optional>
      <zeroOrMore>
        <ref name="para"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="para">
    <element>
      <choice>
        <name>para</name>
        <name>p</name>
      </choice>
      <optional>
        <attribute name="break-after">
          <ref name="BOOL"/>
        </attribute>
      </optional>
      <zeroOrMore>
        <choice>
          <text/>
          <ref name="para"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
</grammar>
% cat Untitled1.xml
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="file:/Users/cpr/Desktop/ufo.rnc" type="compact"?>
<ufo xmlns="http://www.emsoftware.com/NS/UFO"; source="QXP">
    <p>here we go.</p>
    <para>and here we are as well.</para>
    <para break-after="1">foo</para>

</ufo>
% xmllint --relaxng ufo.rng Untitled1.xml
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="file:/Users/cpr/Desktop/ufo.rnc" type="compact"?>
<ufo xmlns="http://www.emsoftware.com/NS/UFO"; source="QXP">
    <p>here we go.</p>
    <para>and here we are as well.</para>
    <para break-after="1">foo</para>

</ufo>
Untitled1.xml:6: element para: Relax-NG validity error : Invalid attribute break-after for element para Untitled1.xml:4: element p: Relax-NG validity error : Element ufo has extra content: p
Untitled1.xml fails to validate
% xmllint --version
xmllint: using libxml version 20607
compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer XInclude Iconv Unicode Regexps Automata Schemas
%

Cheers!
--Chris Ryland / Em Software, Inc. / www.emsoftware.com




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