Schematron XML сравнение даты не работает.И это возвращает ложную ошибку.Я думаю, что я использую schematron 1.01.Я использую C # и библиотеку DLL из MSDN: Ссылка на схему MSDN
Вот вывод ошибки (кстати, она проходит проверку XSD):
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]
<dat_VisitDate signedWho="System" value="2009-02-02">...</dat_VisitDate>
(Line: 7, Column: 10)
Правило схематрона:
<sch:rule context="MyData/Site/Patient/form_Baseline/dat_VisitDate">
<sch:assert test="@value > //MyData/@dataBeginDate">VisitDate must be within a valid date range as specified in dataBeginDate and dataEndDate</sch:assert>
</sch:rule>
XML:
<?xml version="1.0" encoding="utf-8"?>
<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">
<Site SiteKey="11">
<Patient PatientKey="33">
<dat_StatusDate signedWho="System" value="2009-01-01" />
<form_Baseline>
<dat_VisitDate signedWho="System" value="2009-02-02" />
</form_Baseline>
<form_Flowsheet VisitDateKey="2009-03-03">
<dat_OtherDate signedWho="System" value="2009-03-03" />
</form_Flowsheet>
</Patient>
</Site>
</MyData>
XSD:
<?xml version="1.0" encoding="utf-8"?>
<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">
<xs:annotation>
<xs:appinfo>
<sch:title>Schematron Validation</sch:title>
</xs:appinfo>
</xs:annotation>
<xs:simpleType name="dateMyDate">
<xs:restriction base="xs:date">
<xs:minInclusive value="2000-01-01"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="integerMyKey">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="9999"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="stringNonEmpty">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="32"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="MyData">
<xs:complexType>
<xs:sequence>
<xs:element name="Site" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Patient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="dat_StatusDate" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="value" type="dateMyDate" use="required" />
<xs:attribute name="signedWho" type="stringNonEmpty" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="form_Baseline" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="dat_VisitDate" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<sch:pattern name="Check co-occurrence constraints">
<sch:rule context="MyData/Site/Patient/form_Baseline/dat_VisitDate">
<sch:assert test="@value > //MyData/@dataBeginDate">
VisitDate must be within a valid date range as specified in dataBeginDate and dataEndDate
</sch:assert>
</sch:rule>
</sch:pattern>
</xs:appinfo>
</xs:annotation>
<xs:attribute name="value" type="dateMyDate" use="required" />
<xs:attribute name="signedWho" type="stringNonEmpty" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="form_Flowsheet" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="dat_OtherDate" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="value" type="dateMyDate" use="required" />
<xs:attribute name="signedWho" type="stringNonEmpty" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="VisitDateKey" type="dateMyDate" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="PatientKey" type="stringNonEmpty" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="SiteKey" type="integerMyKey" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="dataBeginDate" type="dateMyDate" use="required" />
<xs:attribute name="dataEndDate" type="dateMyDate" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>