Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to compare dates using XML and Schematron
    primarykey
    data
    text
    <p>Schematron XML date comparison in not working. And it returns a false error. I think I am using schematron 1.01. I am using C# and the DLL from MSDN: <a href="http://msdn.microsoft.com/en-us/library/aa468554.aspx" rel="nofollow">MSDN schematron link</a></p> <p>Here is the error output (by the way it passes XSD validation):</p> <pre><code>From pattern "Check co-occurrence constraints" Assert fails: VisitDate must be within a valid date range as specified in dataBeginDate and dataEndDate At: /MyData[1]/Site[1]/Patient[1]/form_Baseline[1]/dat_VisitDate[1] &lt;dat_VisitDate signedWho="System" value="2009-02-02"&gt;...&lt;/dat_VisitDate&gt; (Line: 7, Column: 10) </code></pre> <p><strong>Schematron rule:</strong></p> <pre><code>&lt;sch:rule context="MyData/Site/Patient/form_Baseline/dat_VisitDate"&gt; &lt;sch:assert test="@value &gt; //MyData/@dataBeginDate"&gt;VisitDate must be within a valid date range as specified in dataBeginDate and dataEndDate&lt;/sch:assert&gt; &lt;/sch:rule&gt; </code></pre> <p><strong>XML:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;MyData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dataBeginDate="2008-01-01" dataEndDate="2011-04-26"&gt; &lt;Site SiteKey="11"&gt; &lt;Patient PatientKey="33"&gt; &lt;dat_StatusDate signedWho="System" value="2009-01-01" /&gt; &lt;form_Baseline&gt; &lt;dat_VisitDate signedWho="System" value="2009-02-02" /&gt; &lt;/form_Baseline&gt; &lt;form_Flowsheet VisitDateKey="2009-03-03"&gt; &lt;dat_OtherDate signedWho="System" value="2009-03-03" /&gt; &lt;/form_Flowsheet&gt; &lt;/Patient&gt; &lt;/Site&gt; &lt;/MyData&gt; </code></pre> <p><strong>XSD:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sch="http://www.ascc.net/xml/schematron"&gt; &lt;xs:annotation&gt; &lt;xs:appinfo&gt; &lt;sch:title&gt;Schematron Validation&lt;/sch:title&gt; &lt;/xs:appinfo&gt; &lt;/xs:annotation&gt; &lt;xs:simpleType name="dateMyDate"&gt; &lt;xs:restriction base="xs:date"&gt; &lt;xs:minInclusive value="2000-01-01"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;xs:simpleType name="integerMyKey"&gt; &lt;xs:restriction base="xs:integer"&gt; &lt;xs:minInclusive value="1"/&gt; &lt;xs:maxInclusive value="9999"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;xs:simpleType name="stringNonEmpty"&gt; &lt;xs:restriction base="xs:string"&gt; &lt;xs:minLength value="1"/&gt; &lt;xs:maxLength value="32"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; &lt;xs:element name="MyData"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="Site" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="Patient" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="dat_StatusDate" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="value" type="dateMyDate" use="required" /&gt; &lt;xs:attribute name="signedWho" type="stringNonEmpty" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="form_Baseline" minOccurs="0" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="dat_VisitDate" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:annotation&gt; &lt;xs:appinfo&gt; &lt;sch:pattern name="Check co-occurrence constraints"&gt; &lt;sch:rule context="MyData/Site/Patient/form_Baseline/dat_VisitDate"&gt; &lt;sch:assert test="@value &gt; //MyData/@dataBeginDate"&gt; VisitDate must be within a valid date range as specified in dataBeginDate and dataEndDate &lt;/sch:assert&gt; &lt;/sch:rule&gt; &lt;/sch:pattern&gt; &lt;/xs:appinfo&gt; &lt;/xs:annotation&gt; &lt;xs:attribute name="value" type="dateMyDate" use="required" /&gt; &lt;xs:attribute name="signedWho" type="stringNonEmpty" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="form_Flowsheet" minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="dat_OtherDate" minOccurs="1" maxOccurs="1"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="value" type="dateMyDate" use="required" /&gt; &lt;xs:attribute name="signedWho" type="stringNonEmpty" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="VisitDateKey" type="dateMyDate" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="PatientKey" type="stringNonEmpty" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="SiteKey" type="integerMyKey" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="dataBeginDate" type="dateMyDate" use="required" /&gt; &lt;xs:attribute name="dataEndDate" type="dateMyDate" use="required" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload