2012-01-02 13 views
0

要求メッセージの詳細仕様は、名前でフィールドがあります。IgnoreEmptyElementIndはブール型です。そのフィールドがTrueの場合、要求メッセージの空の要素フィールドを無視する必要があり、 "-111"などのデフォルト値がデフォルト値として設定されます。 falseの場合、空の要素を削除する必要はありません。デフォルト値が見つかると通知されます。 IgnoreEmptyElementIndの値がIgnoreEmptyElementIndの値が、その後、出力SHD であれば、出力SHDがXSLTを使用してXMLメッセージの空の要素フィールドとデフォルト値を削除します

<SampleUpdRq> 
    <RqUID>00000000-0000-0000-0000-000000000000</RqUID> 
    <UpdMsgRqHdr> 
      <ContextRqHdr> 
       <RsSelURL>111</RsSelURL> 
       <NetworkTrnData> 
        <TerminalIdent>a</TerminalIdent> 
        <Name>111</Name> 
       </NetworkTrnData> 
       <ClientApp> 
        <Org>dweer</Org> 
        <Name>aaaaaaaaaaaaaaaaaaa</Name> 
        <Version>112</Version> 
        <Channel>abc</Channel> 
       </ClientApp> 
      </ContextRqHdr> 
      <IgnoreEmptyElementInd>true</IgnoreEmptyElementInd> 
    </UpdMsgRqHdr> 
    <SampleKeys> 
      <SampleId>aaaaaaaaaaaaaaaaaaa</SampleId> 
      <AltSampleIdentifiers> 
       <SampleIdent> 
        <SampleIdentType>Default Found</SampleIdentType> 
        <SampleIdentValue>ttttttt</SampleIdentValue> 
       </SampleIdent> 
      </AltSampleIdentifiers> 
      <SampleType> 
       <SampleTypeValue>MMA</SampleTypeValue> 
       <SampleTypeSrc>bbc</SampleTypeSrc> 
      </SampleType> 
      <CommercialSampleType>Default Found</CommercialSampleType> 
      <COID>aaaaa</COID> 
     </SampleKeys> 
</SampleUpdRq> 

ようになり、ある場合

私の入力メッセージが

<SampleUpdRq> 
    <RqUID>00000000-0000-0000-0000-000000000000</RqUID> 
    <UpdMsgRqHdr> 
      <ContextRqHdr> 
       <RsSelURL>111</RsSelURL> 
       <NetworkTrnData> 
        <TerminalIdent>a</TerminalIdent> 
        <Name>111</Name> 
       </NetworkTrnData> 
       <ClientApp> 
        <Org>dweer</Org> 
        <Name>aaaaaaaaaaaaaaaaaaa</Name> 
        <Version>112</Version> 
        <Channel>abc</Channel> 
       </ClientApp> 
      </ContextRqHdr> 
      <IgnoreEmptyElementInd>true</IgnoreEmptyElementInd> 
    </UpdMsgRqHdr> 
    <SampleKeys> 
      <SampleId>aaaaaaaaaaaaaaaaaaa</SampleId> 
      <AltSampleIdentifiers> 
       <SampleIdent> 
        <SampleIdentType>-111</SampleIdentType> 
        <SampleIdentValue>ttttttt</SampleIdentValue> 
       </SampleIdent> 
       <SampleIdentType/> 
      </AltSampleIdentifiers> 
      <SampleType> 
       <SampleTypeValue>MMA</SampleTypeValue> 
       <SampleTypeSrc>bbc</SampleTypeSrc> 
       <CommercialSampleType></CommercialSampleType> 
      </SampleType> 
      <CommercialSampleType>-111</CommercialSampleType> 
      <COID>aaaaa</COID> 
     </SampleKeys> 
</SampleUpdRq> 

ですbe like

<SampleUpdRq> 
    <RqUID>00000000-0000-0000-0000-000000000000</RqUID> 
    <UpdMsgRqHdr> 
      <ContextRqHdr> 
       <RsSelURL>111</RsSelURL> 
       <NetworkTrnData> 
        <TerminalIdent>a</TerminalIdent> 
        <Name>111</Name> 
       </NetworkTrnData> 
       <ClientApp> 
        <Org>dweer</Org> 
        <Name>aaaaaaaaaaaaaaaaaaa</Name> 
        <Version>112</Version> 
        <Channel>abc</Channel> 
       </ClientApp> 
      </ContextRqHdr> 
      <IgnoreEmptyElementInd>false</IgnoreEmptyElementInd> 
    </UpdMsgRqHdr> 
    <SampleKeys> 
      <SampleId>aaaaaaaaaaaaaaaaaaa</SampleId> 
      <AltSampleIdentifiers> 
       <SampleIdent> 
        <SampleIdentType>Default Found</SampleIdentType> 
        <SampleIdentValue>ttttttt</SampleIdentValue> 
       </SampleIdent> 
       <SampleIdentType/> 
      </AltSampleIdentifiers> 
      <SampleType> 
       <SampleTypeValue>MMA</SampleTypeValue> 
       <SampleTypeSrc>bbc</SampleTypeSrc> 
      <CommercialSampleType/> 
      </SampleType> 
      <CommercialSampleType>Default Found</CommercialSampleType> 
      <COID>aaaaa</COID> 
     </SampleKeys> 
</SampleUpdRq> 

私はこのようなXSLを書かれている:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="xml" indent="yes"/>  

<xsl:template match="*[not(node())]" />  

<xsl:template match="*[. = '-111']">  
    <xsl:copy>   
    <xsl:text>Default Found</xsl:text> 
</xsl:copy>  
</xsl:template>  

<xsl:template match="@*|node()"> 
    <xsl:copy>   
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy>  
</xsl:template> 

</xsl:stylesheet> 

は本当に専門知識の助けと混乱を気の毒に感謝。前もって感謝します。

+1

最初のXSLTサンプルに 'version =" 2.0 "'がありますが、XSLT 2.0プロセッサを使用していますか?また、代表的なXML入力サンプルとそれに対応する結果を投稿してから、それを解決するための正しいXSLTの方法を提案することもできます。 –

+0

要素の削除に使用する条件を定義する必要があります。質問を編集して追加してください。 –

+0

@Vinay:** IgnoreEmptyElementInd **はXML文書全体に適用されるのですか、** UpdMsgRqHdr **要素にのみ適用されますか? –

答えて

1

「IgnoreEmptyElementIndの後に来る要素、その規則を適用する」と言う場合、その値を決定するためにXPathの '先行'軸を使用する必要があると聞きます。

IgnoreEmptyElementIndがtrueに設定されている場合、このテンプレートでXSLTを拡張して空のノードを無視することができます。あなたのサンプルXMLに適用された場合

<xsl:template 
    match="*[not(node())][preceding::IgnoreEmptyElementInd[. = 'true']]"/> 

ので、以下のXSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="xml" indent="yes"/> 

    <xsl:template match="*[not(node())][preceding::IgnoreEmptyElementInd[. = 'true']]"/> 

    <xsl:template match="*[. = '-111']"> 
     <xsl:copy> 
     <xsl:text>Default Found</xsl:text> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 

を与え、次はIgnoreEmptyElementIndは、以下の '偽' に設定されている出力

<SampleUpdRq> 
    <RqUID>00000000-0000-0000-0000-000000000000</RqUID> 
    <UpdMsgRqHdr> 
     <ContextRqHdr> 
     <RsSelURL>111</RsSelURL> 
     <NetworkTrnData> 
      <TerminalIdent>a</TerminalIdent> 
      <Name>111</Name> 
     </NetworkTrnData> 
     <ClientApp> 
      <Org>dweer</Org> 
      <Name>aaaaaaaaaaaaaaaaaaa</Name> 
      <Version>112</Version> 
      <Channel>abc</Channel> 
     </ClientApp> 
     </ContextRqHdr> 
     <IgnoreEmptyElementInd>true</IgnoreEmptyElementInd> 
    </UpdMsgRqHdr> 
    <SampleKeys> 
     <SampleId>aaaaaaaaaaaaaaaaaaa</SampleId> 
     <AltSampleIdentifiers> 
     <SampleIdent> 
      <SampleIdentType>Default Found</SampleIdentType> 
      <SampleIdentValue>ttttttt</SampleIdentValue> 
     </SampleIdent> 
     </AltSampleIdentifiers> 
     <SampleType> 
     <SampleTypeValue>MMA</SampleTypeValue> 
     <SampleTypeSrc>bbc</SampleTypeSrc> 
     </SampleType> 
     <CommercialSampleType>Default Found</CommercialSampleType> 
     <COID>aaaaa</COID> 
    </SampleKeys> 
</SampleUpdRq> 

です代わりに出力されます

<SampleUpdRq> 
    <RqUID>00000000-0000-0000-0000-000000000000</RqUID> 
    <UpdMsgRqHdr> 
     <ContextRqHdr> 
     <RsSelURL>111</RsSelURL> 
     <NetworkTrnData> 
      <TerminalIdent>a</TerminalIdent> 
      <Name>111</Name> 
     </NetworkTrnData> 
     <ClientApp> 
      <Org>dweer</Org> 
      <Name>aaaaaaaaaaaaaaaaaaa</Name> 
      <Version>112</Version> 
      <Channel>abc</Channel> 
     </ClientApp> 
     </ContextRqHdr> 
     <IgnoreEmptyElementInd>false</IgnoreEmptyElementInd> 
    </UpdMsgRqHdr> 
    <SampleKeys> 
     <SampleId>aaaaaaaaaaaaaaaaaaa</SampleId> 
     <AltSampleIdentifiers> 
     <SampleIdent> 
      <SampleIdentType>Default Found</SampleIdentType> 
      <SampleIdentValue>ttttttt</SampleIdentValue> 
     </SampleIdent> 
     <SampleIdentType/> 
     </AltSampleIdentifiers> 
     <SampleType> 
     <SampleTypeValue>MMA</SampleTypeValue> 
     <SampleTypeSrc>bbc</SampleTypeSrc> 
     <CommercialSampleType/> 
     </SampleType> 
     <CommercialSampleType>Default Found</CommercialSampleType> 
     <COID>aaaaa</COID> 
    </SampleKeys> 
</SampleUpdRq> 
+0

@Tim C.のお返事ありがとうございます。上記のXML msg derisフィールドにIgnoreEmptyElementIndという名前の疑問があります。disはブール型です。 IgnoreEmptyElementIndの値がtrueの場合 =>メッセージの空の要素フィールドをすべて削除する必要があります。 =>日付型フィールドには「1200-1-1」のようなデフオルト値はほとんどありません。これらの値を持つ要素については整数型のフィールドのみが保持されます。 値がfalseの場合 =>メッセージ内の空の要素フィールドを削除する必要はありません =>上記のような既定値を持つ要素を削除する必要があります.XSLでは可能ですか? – Vinay

+0

オリジナルの質問を完全な要件と詳細な要件とで修正する必要があるため、誤解はありません。あなたが "IgnoreEmptyElementInd"がどのように動作するかに関する完全なルールを与えるなら、それは可能でなければなりません。 –

+0

詳細な要件で元の質問を変更しました。 – Vinay

関連する問題