Hi,

I've got a problem with RelaxNG validation. 

I want to describe fixed or relative dates in XML, 
like "2006/02/23 12:00:00", or "yesterday at 12:00:00" or 
"there is 1 month and 2 weeks, the monday at midnight".

I wrote a RNG schema (joined to this mail with a lot of comments and
miscellaneous xml files that should be validated by this schema) to
describe these dates.

See the schema comments for more details on this XML description.

But, libxml2 fails to validate XML files using this schema.

In fact totally relative dates seems to be validated without problems
(rel-1.xml sample file). But when a component is "fixed" (fixed-1.xml
and rel-2.xml) the following errors appears. 

fixed-1.xml :

   Unimplemented block at relaxng.c:10369
   Error /tmp/fixed-1.xml line 3: Element Date has extra content: year


rel-2.xml :

   Error /tmp/rel-2.xml line 3: Element Date has extra content: day


Is my schema description too ambiguous ? Jing seems to validate these
files without any problem.

Any Idea ?


Thanks,
Laurent.


<?xml version="1.0" encoding="utf-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0";
		 datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes";>
  <start>

    <!--
        The Date element is used to describe fixed, relative or
        partially relative dates. These dates are usually used to
        describe start and end date of an interval to retrieve data
        from database (for tables or graphs).
        
        The Following Schema represent validate the following XML :
        
        <Date>
          <year type="fixed|relative">number</year>
          <month type="fixed|relative">number</month>

            <day type="fixed|relative">number</day>
            
            or
            
            <week type="fixed|relative">number</week>
            <dow type="fixed">number</dow>
 
          <hour type="fixed|relative">number</hour>
          <minute type="fixed|relative">number</minute>
          <second type="fixed|relative">number</second>
        </Date>

        * dow stand for "Day Of Week". 0 = Monday, 6 = Sunday.

        The following constraints are applied to this xml description :
        
        - If a node has attribute type="fixed", all the following node
          MUST be specified and MUST have attribute type="fixed".
        
        - If nodes "week" or "dow" are present, the node "day" CAN'T
          be specified.

        - If the node "day" is present, nodes "week" and "dow" CAN'T
          be specified.

        - For the "dow" node, the type attribute MUST have always
          "fixed" value (dow CAN'T be relative)

        - If a node has attribute type="relative", the following nodes
          CAN be omited and are considered having type="relative" and
          value = 0.

        - If a node has attribute type="fixed", the preceding nodes
          CAN be omited and are considered having type="relative" and
          value = 0.
          
          
          SAMPLES :
          
          The February 23, 2006 at 9:06:53 AM :
          
          <Date>
            <year type="fixed">2006</year>
            <month type="fixed">2</month>
            <day type="fixed">23</day>
            <hour type="fixed">9</hour>
            <minute type="fixed">6</minute>
            <second type="fixed">53</second>
          </Date>


          The wednesday of the 4th week of March, 2006 at 9:02:53 AM :

          <Date>
            <year type="fixed">2006</year>
            <month>3</month>
            <week type="fixed">4</year>
            <dow type="fixed">2</dow>
            <hour type="fixed">9</hour>
            <minute type="fixed">6</minute>
            <second type="fixed">53</second>
          </Date>

          
          There are 1 day :

          <Date>
            <day type="relative">1</day>
          </Date>


          Yesterday at 1:00:00 AM :

          <Date>
            <day type="relative">1</day>
            <hour type="fixed">1</hour>
            <minute type="fixed">0</minute>
            <second type="fixed">0</second>
          </Date>


    -->

    <!--
        Main Date Element.
      -->
	<element name="Date">

      <optional>
        <choice>
          <ref name="yearRelative"/>
         <ref name="yearFixed"/>
<!--          <ref name="monthRelative"/>
          <ref name="monthFixed"/>
          <ref name="dayRelative"/>
          <ref name="dayFixed"/>
          <ref name="weekRelative"/>
          <ref name="weekFixed"/>
          <ref name="dowFixed"/>
          <ref name="hourRelative"/>
          <ref name="hourFixed"/>
          <ref name="minuteRelative"/>
          <ref name="minuteFixed"/>
          <ref name="secondRelative"/>
          <ref name="secondFixed"/>-->
        </choice>
      </optional>

	</element>
  </start>


  <!--
      <year type="relative"> Element.
  -->
  <define name="yearRelative">

	<element name="year">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

    <optional>
      <choice>
        <ref name="monthFixed"/>
        <ref name="monthRelative"/>
      </choice>
    </optional>

  </define>


  <!--
      <year type="fixed"> Element.
  -->
  <define name="yearFixed">

	<element name="year">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

    <ref name="monthFixed"/>

  </define>


  <!--
      <month type="relative"> Element.
  -->
  <define name="monthRelative">

	<element name="month">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

<!--    <optional>
      <choice>
        <ref name="dayFixed"/>
        <ref name="dayRelative"/>
        <ref name="weekFixed"/>
        <ref name="weekRelative"/>
      </choice>
    </optional>-->

  </define>


  <!--
      <month type="fixed"> Element.
  -->
  <define name="monthFixed">

	<element name="month">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>
    
    <choice>
      <ref name="weekFixed"/>
      <ref name="dayFixed"/>
    </choice>

  </define>


  <!--
      <week type="relative"> Element.
  -->
  <define name="weekRelative">

	<element name="week">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

    <optional>
      <ref name="dowFixed"/>
    </optional>

  </define>


  <!--
      <week type="fixed"> Element.
  -->
  <define name="weekFixed">

	<element name="week">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

    <ref name="dowFixed"/>
 
  </define>



  <!--
      <dow type="fixed"> Element.
  -->
  <define name="dowFixed">

	<element name="dow">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

  </define>



  <!--
      <day type="relative"> Element.
  -->
  <define name="dayRelative">

	<element name="day">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

    <optional>
      <choice>
        <ref name="hourFixed"/>
        <ref name="hourRelative"/>
      </choice>
    </optional>

  </define>


  <!--
      <day type="fixed"> Element.
  -->
  <define name="dayFixed">

	<element name="day">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

    <ref name="hourFixed"/>

  </define>


  <!--
      <hour type="relative"> Element.
  -->
  <define name="hourRelative">

	<element name="hour">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

    <optional>
      <choice>
        <ref name="minuteFixed"/>
        <ref name="minuteRelative"/>
      </choice>
    </optional>

  </define>


  <!--
      <hour type="fixed"> Element.
  -->
  <define name="hourFixed">

	<element name="hour">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>
    
    <ref name="minuteFixed"/>

  </define>


  <!--
      <minute type="relative"> Element.
  -->
  <define name="minuteRelative">

	<element name="minute">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

    <optional>
      <choice>
        <ref name="secondFixed"/>
        <ref name="secondRelative"/>
      </choice>
    </optional>

  </define>


  <!--
      <minute type="fixed"> Element.
  -->
  <define name="minuteFixed">

	<element name="minute">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

    <ref name="secondFixed"/>

  </define>


  <!--
      <second type="relative"> Element.
  -->
  <define name="secondRelative">

	<element name="second">
      <attribute name="type"><value>relative</value></attribute>
      <data type="integer"/>
    </element>

  </define>

  <!--
      <second type="fixed"> Element.
  -->
  <define name="secondFixed">

	<element name="second">
      <attribute name="type"><value>fixed</value></attribute>
      <data type="integer"/>
    </element>

  </define>

</grammar>
<?xml version="1.0" encoding="utf-8"?>
<Date>
  <year   type="fixed">2005</year>
  <month  type="fixed">12</month>
  <day    type="fixed">10</day>
  <hour   type="fixed">0</hour>
  <minute type="fixed">0</minute>
  <second type="fixed">0</second>
</Date>
<?xml version="1.0" encoding="utf-8"?>
<Date>
  <year   type="relative">0</year>
  <month  type="relative">3</month>
</Date>
<?xml version="1.0" encoding="utf-8"?>
<Date>
  <day  type="relative">4</day>
  <hour type="fixed">12</hour>
  <minute type="fixed">15</minute>
  <second type="fixed">30</second>
</Date>
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to