2017-03-03 5 views
0

XSLT 1.0を使用すると、2つの "関連する" XML要素に基づいてxsl:キーを作成できますか?xsl:keyに2つの関連するxml要素を使用する

  1. /component/section/text/table/tbody/tr/td[1]/text()
  2. /component/section/entry/act/effectiveTime/low/@value

理想的には、キーが希望のような代に見える:

例えば、私は、の値を連結キーを作成したいのですが

  1. test description|20161229000000
  2. test description2|20161230000000

これらの要素は、それらが属性と同じ参照ID(ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_*)との兄弟要素を共有するという意味で関連しています。

キーを定義するときは、 "一致" xpathパターンと "use" xpathパターンを指定する必要があります。しかし、特に要素が異なる親要素を持ち、関連する属性値が関連要素の各ペアごとに異なる場合、特定の値を持つ関連する属性を考慮に入れることができるパターンを作成することは難しいようです。

サンプルXML:共有属性/要素の値に基づいて、2つの要素を連結するとき

<?xml version="1.0" ?> 
    <component> 
    <section classCode="DOCSECT" moodCode="EVN"> 
     <text mediaType="text/x-hl7-text+xml"> 
      <table border="1"> 
       <tbody> 
        <tr> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_1">test description</td> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_dateOfOnset_1">12/29/2016</td> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_comments_1"/> 
        </tr> 
        <tr> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_2">test description2</td> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_dateOfOnset_2">12/30/2016</td> 
         <td ID="ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_comments_2"/> 
        </tr> 
       </tbody> 
      </table> 
     </text> 
     <entry> 
      <act classCode="ACT" moodCode="EVN"> 
       <id extension="1206ca2c614d4d07990b0162ee99aaf1" root="2.16.840.1.113883.3.441"/> 
       <code nullFlavor="NA"/> 
       <statusCode code="completed"/> 
       <effectiveTime> 
        <low value="20161229000000"/> 
        <high nullFlavor="UNK"/> 
       </effectiveTime> 
       <entryRelationship inversionInd="false" typeCode="SUBJ"> 
        <observation classCode="OBS" moodCode="EVN" negationInd="false"> 
         <templateId root="2.16.840.1.113883.10.20.1.28"/> 
         <id extension="99999999" root="2.16.840.1.113883.3.441.1.50.869.51.1349970.61"/> 
         <code code="55607006" 
          codeSystem="2.16.840.1.113883.6.96" 
          codeSystemName="SNOMED CT" displayName="undescriptive display name"/> 
         <text> 
          <reference value="#ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_1"/> 
         </text> 
         <statusCode code="completed"/> 
         <effectiveTime> 
          <low value="20161229000000"/> 
         </effectiveTime> 
         <value code="783.3" codeSystemName="ICD9" displayName="undescriptive display name"> 
          <originalText>ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_1</originalText> 
         </value> 
         <entryRelationship inversionInd="false" typeCode="REFR"> 
          <observation classCode="OBS" moodCode="EVN"> 
           <templateId root="2.16.840.1.113883.10.20.1.50"/> 
           <code code="33999-4" 
            codeSystem="2.16.840.1.113883.6.1" 
            codeSystemName="LOINC" displayName="Status"/> 
           <statusCode code="Completed"/> 
           <value code="73425007" 
            codeSystem="2.16.840.1.113883.6.96" 
            codeSystemName="SNOMED CT" displayName="InActive"/> 
          </observation> 
         </entryRelationship> 
        </observation> 
       </entryRelationship> 
      </act> 
     </entry> 
     <entry> 
      <act classCode="ACT" moodCode="EVN"> 
       <id extension="1206ca2c614d4d07990b0162ee99aaf1" root="2.16.840.1.113883.3.441"/> 
       <code nullFlavor="NA"/> 
       <statusCode code="completed"/> 
       <effectiveTime> 
        <low value="20161230000000"/> 
        <high nullFlavor="UNK"/> 
       </effectiveTime> 
       <entryRelationship inversionInd="false" typeCode="SUBJ"> 
        <observation classCode="OBS" moodCode="EVN" negationInd="false"> 
         <templateId root="2.16.840.1.113883.10.20.1.28"/> 
         <id extension="99999999" root="2.16.840.1.113883.3.441.1.50.869.51.1349970.61"/> 
         <code code="55607006" 
          codeSystem="2.16.840.1.113883.6.96" 
          codeSystemName="SNOMED CT" displayName="undescriptive display name2"/> 
         <text> 
          <reference value="#ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_2"/> 
         </text> 
         <statusCode code="completed"/> 
         <effectiveTime> 
          <low value="20161230000000"/> 
         </effectiveTime> 
         <value code="783.3" codeSystemName="ICD9" displayName="undescriptive display name2"> 
          <originalText>ref_b71a6ee05ef245f1a0c3f302ca769077_pastIllness_name_2</originalText> 
         </value> 
         <entryRelationship inversionInd="false" typeCode="REFR"> 
          <observation classCode="OBS" moodCode="EVN"> 
           <templateId root="2.16.840.1.113883.10.20.1.50"/> 
           <code code="33999-4" 
            codeSystem="2.16.840.1.113883.6.1" 
            codeSystemName="LOINC" displayName="Status"/> 
           <statusCode code="Completed"/> 
           <value code="73425007" 
            codeSystem="2.16.840.1.113883.6.96" 
            codeSystemName="SNOMED CT" displayName="InActive"/> 
          </observation> 
         </entryRelationship> 
        </observation> 
       </entryRelationship> 
      </act> 
     </entry> 
    </section> </component> 
+0

ので、:

これは、元の質問でのXMLのための鍵の一例ですか?そして、どのようにしてテーブル行をエントリと位置関係で関連づけたいのですか? –

答えて

0

current()機能は有用でした。あなたが考えているん `match`の要素は、あなたがのためのキーを定義したいん

<xsl:key name="testKey" match="/component/section/text/table/tbody/tr/td[1]" use="concat(.,'|',substring(../../../../../entry/act/effectiveTime[../entryRelationship/observation/value/originalText/text() = current()/@ID]/low/@value,1,8))"/> 
+0

これは何が良いですか? –

+0

この特定のキーは、2つの要素/属性値に基づいて重複排除するために作成されました – wjjy

関連する問題