2016-10-14 21 views
1
<ROOTNODE> 
    <Blocks> 
    <Block> 
    <Ref/> 
     <BlockDates Start="2015-10-20" End="2015-10-25" /> 
     <Types> 
     <Type TypeCode="SGL"> 
     <TypeAllocations> 
     <TypeAllocation Start="2015-10-26" End="2015-10-27" /> 
     <TypeAllocation Start="2015-10-26" End="2015-10-25" /> 
     </TypeAllocations> 
     </Type> 
     <Type TypeCode="SGL"> 
     <TypeAllocations> 
     <TypeAllocation Start="2015-10-28" End="2015-10-29" /> 
     <TypeAllocation Start="2015-10-26" End="2015-10-27" /> 
     </TypeAllocations> 
     </Type> 
     </Types> 
    </Block> 

    <Block> 
     <Ref/> 
     <BlockDates Start="2015-10-26" End="2015-10-30"/> 
     <Types> 
     <Type TypeCode="SG"> 
     <TypeAllocations> 
     <TypeAllocation Start="2015-10-31" End="2015-11-01" /> 
     <TypeAllocation Start="2015-10-25" End="2015-10-24" /> 
     </TypeAllocations> 
     </Type> 
     <Type TypeCode="SG"> 
     <TypeAllocations> 
     <TypeAllocation Start="2015-10-21" End="2015-10-25" /> 
     <TypeAllocation Start="2015-10-23" End="2015-11-27" /> 
     </TypeAllocations> 
     </Type> 
     </Types> 
    </Block> 
    </Blocks> 
    </ROOTNODE> 

私は< TypeAllocation @startと@end >日付が< BlockDates @startと@end >日付の外にある場合に伝える方法を見つけようとしています。 <タイプアロケーション>エレメントと<タイプ>エレメントの任意の数があります。上記はすべての場合に失敗するはずです。以下は私が試みたものです。しかし、私はそれが最初のものだけを見つけるので、その道が離れていると感じます。どんな助けでも大歓迎です!Schematronの日付の比較

<sch:pattern name="Testing Start and End dates"> 
                       <sch:rule context="blk:InvBlock"> 
                        <sch:report test="translate(blk:InvBlockDates/@Start, '-', '') &lt;= translate(blk:RoomTypes/blk:RoomType/blk:RoomTypeAllocations/blk:RoomTypeAllocation/@Start, '-', '') or translate(blk:InvBlockDates/@End, '-', '') &lt;= translate(blk:RoomTypes/blk:RoomType/blk:RoomTypeAllocations/blk:RoomTypeAllocation/@End, '-', '')"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report> 
                       </sch:rule> 
                      </sch:pattern> 
+0

こんにちはMartin、はいブロック内にAllocation開始日と終了日をすべて確認する必要があります。私はこれを使ってSchematron 1.5を使っていることを忘れていました。したがって、current()関数は機能していません。 – user1128792

答えて

0

私は次のように使用してこの作業を取得することができました。マーティンに感謝します。

<sch:rule context="Block"> 
    <sch:report test="Types/Type/TypeAllocations/TypeAllocation[ 
    translate(@Start, '-', '') &lt; translate(ancestor::Block/BlockDates/@Start, '-', '') ] 
    or 
    Types/Type/TypeAllocations/TypeAllocation[translate(@End, '-', '') &gt; translate(ancestor::Block/BlockDates/@End, '-', '')] "> 
    Allocation @Start and @End dates can not be outside the Block @Start and @End dates. 
    </sch:report> 
</sch:rule> 
1

私はあなたが間違っているStartまたはEndと少なくとも1 TypeAllocationまたはあなたがそれらのすべてをチェックしたい場合があるかどうか検証エラーを報告するかどうかわかりません。それらのうち少なくとも1つが間違っていることを確認したい場合は、

<sch:pattern> 
    <sch:rule context="Block"> 
     <sch:report test="Types/Type/TypeAllocations/TypeAllocation[ 
          translate(@Start, '-', '') > translate(current()/BlockDates/@Start, '-', '') 
          or 
          translate(@End, '-', '') > translate(current()/BlockDates/@End, '-', '')]"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report> 
    </sch:rule> 
</sch:pattern> 

と思います。 Schematronののバージョンがあなたの例の文脈では、その後、それぞれ私の提案をcurrent()機能の使用をサポートしていない場合は、代わりにcurrent()ancestor::Blockを使用することができます。

<sch:pattern> 
    <sch:rule context="Block"> 
     <sch:report test="Types/Type/TypeAllocations/TypeAllocation[ 
          translate(@Start, '-', '') > translate(ancestor::Block/BlockDates/@Start, '-', '') 
          or 
          translate(@End, '-', '') > translate(ancestor::Block/BlockDates/@End, '-', '')]"> Allocation @Start and @End dates can not be outside the Block @Start and @End dates. </sch:report> 
    </sch:rule> 
</sch:pattern>