2016-09-02 5 views
4

WCF SQLアダプタを使用してデータベースから型付きポーリングを実行するBizTalkアプリケーションを作成しています。生成されたスキーマから標準スキーマにデータをグループ化する方法を研究した後、私は共通の解決策としてMuenchian Groupingを見つけました。しかし、私はそれを自分の状況に適用する方法を理解するのに苦労しています。XSLTグループ間のIDによるBizTalk WCF-SQLアダプタスキーマからのMuenchianグループ化

基本的に、私がポーリングしているデータは、すべてのテーブルにわたって同じプライマリキーを共有する1対1リレーションシップと1対多リレーションシップが混在する複数のテーブルに分散されています。 1対多の関係のため、1つのSELECT文を使用してさまざまなテーブルからすべてのデータを抽出することはできず、代わりに画像に表示されているソーススキーマを生成したPolling Dataステートメントにmultiple queriesというように分割しました以下。

私がしようとしているのは、単純に "SharedID"でソーススキーマのすべてのレコードを分離し、それらを宛先スキーマの適切なレコードに入れることです。 (サブグループには2次インスタンス番号IDもありますが、それらは同じ方法で解決されると思います)。私が見たすべての例では、XSLTキーがsingle nodeまたはmultiple nodesから派生したときにこれを行う方法を示しています。複数のノードから同じIDが来たときにどのように考慮すべきかを示していません。

私は可能な限り多くの情報源からサンプルを分析しましたが、私はまだXSLTに新しいので、このアプローチに対応するためにキーと各文を設定する方法がわかりません。どのように私はこれを行うに行く必要がありますdemystifyingどのような助けを大いに感謝します。ありがとう!

次は、ソースとデスティネーションのスキーマ構造の一般化されたバージョンを使用したマップのスクリーンショットです。ここで

enter image description here

上記マップは、私は私の出発点として使用していた、生成XSLTです。

<?xml version="1.0" encoding="UTF-16"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
       xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" 
       exclude-result-prefixes="msxsl var s0" 
       version="1.0" 
       xmlns:s0="http://SmallGenericSchemaTest.Schemas/SourceSchema" 
       xmlns:ns0="http://SmallGenericSchemaTest.Schemas/DestinationSchema"> 
    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> 

    <xsl:template match="/"> 
     <xsl:apply-templates select="/s0:TypedPolling" /> 
    </xsl:template> 

    <xsl:template match="/s0:TypedPolling"> 
     <ns0:AllRecords> 
      <ns0:SingleRecord> 
       <xsl:for-each select="s0:TypedPollingResultSet0"> 
        <xsl:for-each select="s0:TypedPollingResultSet0"> 
         <ns0:GroupA> 
          <xsl:if test="s0:SharedID"> 
           <ns0:SharedID> 
            <xsl:value-of select="s0:SharedID/text()" /> 
           </ns0:SharedID> 
          </xsl:if> 

          <xsl:if test="s0:MiscInfoA1"> 
           <ns0:MiscInfoA1> 
            <xsl:value-of select="s0:MiscInfoA1/text()" /> 
           </ns0:MiscInfoA1> 
          </xsl:if> 

          <xsl:if test="s0:MiscInfoA2"> 
           <ns0:MiscInfoA2> 
            <xsl:value-of select="s0:MiscInfoA2/text()" /> 
           </ns0:MiscInfoA2> 
          </xsl:if> 
         </ns0:GroupA> 
        </xsl:for-each> 
       </xsl:for-each> 

       <xsl:for-each select="s0:TypedPollingResultSet1"> 
        <xsl:for-each select="s0:TypedPollingResultSet1"> 
         <ns0:GroupB> 
          <xsl:if test="s0:MiscInfoB1"> 
           <ns0:MiscInfoB1> 
            <xsl:value-of select="s0:MiscInfoB1/text()" /> 
           </ns0:MiscInfoB1> 
          </xsl:if> 

          <xsl:if test="s0:MiscInfoB2"> 
           <ns0:MiscInfoB2> 
            <xsl:value-of select="s0:MiscInfoB2/text()" /> 
           </ns0:MiscInfoB2> 
          </xsl:if> 

          <ns0:SubGroupBAContainer> 
           <xsl:for-each select="../../s0:TypedPollingResultSet2"> 
            <xsl:for-each select="s0:TypedPollingResultSet2"> 
             <ns0:SubGroupBA> 
              <xsl:if test="s0:MiscInfoBA1"> 
               <ns0:MiscInfoBA1> 
                <xsl:value-of select="s0:MiscInfoBA1/text()" /> 
               </ns0:MiscInfoBA1> 
              </xsl:if> 

              <xsl:if test="s0:MiscInfoBA2"> 
               <ns0:MiscInfoBA2> 
                <xsl:value-of select="s0:MiscInfoBA2/text()" /> 
               </ns0:MiscInfoBA2> 
              </xsl:if> 
             </ns0:SubGroupBA> 
            </xsl:for-each> 
           </xsl:for-each> 
          </ns0:SubGroupBAContainer> 

          <ns0:SubGroupBBContainer> 
           <xsl:for-each select="../../s0:TypedPollingResultSet3"> 
            <xsl:for-each select="s0:TypedPollingResultSet3"> 
             <ns0:SubGroupBB> 
              <xsl:if test="s0:MiscInfoBB1"> 
               <ns0:MiscInfoBB1> 
                <xsl:value-of select="s0:MiscInfoBB1/text()" /> 
               </ns0:MiscInfoBB1> 
              </xsl:if> 

              <xsl:if test="s0:MiscInfoBB2"> 
               <ns0:MiscInfoBB2> 
                <xsl:value-of select="s0:MiscInfoBB2/text()" /> 
               </ns0:MiscInfoBB2> 
              </xsl:if> 
             </ns0:SubGroupBB> 
            </xsl:for-each> 
           </xsl:for-each> 
          </ns0:SubGroupBBContainer> 
         </ns0:GroupB> 
        </xsl:for-each> 
       </xsl:for-each> 

       <ns0:GroupCContainer> 
        <xsl:for-each select="s0:TypedPollingResultSet4"> 
         <xsl:for-each select="s0:TypedPollingResultSet4"> 
          <ns0:GroupC> 
           <xsl:if test="s0:GroupCInstanceID"> 
            <ns0:GroupCInstanceID> 
             <xsl:value-of select="s0:GroupCInstanceID/text()" /> 
            </ns0:GroupCInstanceID> 
           </xsl:if> 

           <xsl:if test="s0:MiscInfoC1"> 
            <ns0:MiscInfoC1> 
             <xsl:value-of select="s0:MiscInfoC1/text()" /> 
            </ns0:MiscInfoC1> 
           </xsl:if> 

           <xsl:if test="s0:MiscInfoC2"> 
            <ns0:MiscInfoC2> 
             <xsl:value-of select="s0:MiscInfoC2/text()" /> 
            </ns0:MiscInfoC2> 
           </xsl:if> 
          </ns0:GroupC> 
         </xsl:for-each> 
        </xsl:for-each> 
       </ns0:GroupCContainer> 

       <ns0:GroupDContainer> 
        <xsl:for-each select="s0:TypedPollingResultSet5"> 
         <xsl:for-each select="s0:TypedPollingResultSet5"> 
          <ns0:GroupD> 
           <xsl:if test="s0:GroupDInstanceID"> 
            <ns0:GroupDInstanceID> 
             <xsl:value-of select="s0:GroupDInstanceID/text()" /> 
            </ns0:GroupDInstanceID> 
           </xsl:if> 

           <xsl:if test="s0:MiscInfoD1"> 
            <ns0:MiscInfoD1> 
             <xsl:value-of select="s0:MiscInfoD1/text()" /> 
            </ns0:MiscInfoD1> 
           </xsl:if> 

           <xsl:if test="s0:MiscInfoD2"> 
            <ns0:MiscInfoD2> 
             <xsl:value-of select="s0:MiscInfoD2/text()" /> 
            </ns0:MiscInfoD2> 
           </xsl:if> 
           <xsl:for-each select="../../s0:TypedPollingResultSet6"> 
            <xsl:for-each select="s0:TypedPollingResultSet6"> 
             <ns0:SubGroupDA> 
              <xsl:if test="s0:MiscInfoDA1"> 
               <ns0:MiscInfoDA1> 
                <xsl:value-of select="s0:MiscInfoDA1/text()" /> 
               </ns0:MiscInfoDA1> 
              </xsl:if> 

              <xsl:if test="s0:MiscInfoDA2"> 
               <ns0:MiscInfoDA2> 
                <xsl:value-of select="s0:MiscInfoDA2/text()" /> 
               </ns0:MiscInfoDA2> 
              </xsl:if> 
             </ns0:SubGroupDA> 
            </xsl:for-each> 
           </xsl:for-each> 

           <ns0:SubGroupDBContainer> 
            <xsl:for-each select="../../s0:TypedPollingResultSet7"> 
             <xsl:for-each select="s0:TypedPollingResultSet7"> 
              <ns0:SubGroupDB> 
               <xsl:if test="s0:MiscInfoDB1"> 
                <ns0:MiscInfoDB1> 
                 <xsl:value-of select="s0:MiscInfoDB1/text()" /> 
                </ns0:MiscInfoDB1> 
               </xsl:if> 

               <xsl:if test="s0:MiscInfoDB2"> 
                <ns0:MiscInfoDB2> 
                 <xsl:value-of select="s0:MiscInfoDB2/text()" /> 
                </ns0:MiscInfoDB2> 
               </xsl:if> 
              </ns0:SubGroupDB> 
             </xsl:for-each> 
            </xsl:for-each> 
           </ns0:SubGroupDBContainer> 
          </ns0:GroupD> 
         </xsl:for-each> 
        </xsl:for-each> 
       </ns0:GroupDContainer> 
      </ns0:SingleRecord> 
     </ns0:AllRecords> 
    </xsl:template> 
</xsl:stylesheet> 

EDIT:

ここでは、サンプル入力XML文書と所望の出力です。

サンプル入力:

<ns0:TypedPolling xmlns:ns0="http://SmallGenericSchemaTest.Schemas/SourceSchema"> 
    <ns0:TypedPollingResultSet0> 
     <ns0:TypedPollingResultSet0> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoA1>A1_1</ns0:MiscInfoA1> 
      <ns0:MiscInfoA2>A2_1</ns0:MiscInfoA2> 
     </ns0:TypedPollingResultSet0> 

     <ns0:TypedPollingResultSet0> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoA1>A1_2</ns0:MiscInfoA1> 
      <ns0:MiscInfoA2>A2_2</ns0:MiscInfoA2> 
     </ns0:TypedPollingResultSet0> 
    </ns0:TypedPollingResultSet0> 

    <ns0:TypedPollingResultSet1> 
     <ns0:TypedPollingResultSet1> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoB1>B1_1</ns0:MiscInfoB1> 
      <ns0:MiscInfoB2>B2_1</ns0:MiscInfoB2> 
     </ns0:TypedPollingResultSet1> 

     <ns0:TypedPollingResultSet1> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoB1>B1_2</ns0:MiscInfoB1> 
      <ns0:MiscInfoB2>B2_2</ns0:MiscInfoB2> 
     </ns0:TypedPollingResultSet1> 
    </ns0:TypedPollingResultSet1> 

    <ns0:TypedPollingResultSet2> 
     <ns0:TypedPollingResultSet2> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoBA1>BA1_1A</ns0:MiscInfoBA1> 
      <ns0:MiscInfoBA2>BA2_1A</ns0:MiscInfoBA2> 
     </ns0:TypedPollingResultSet2> 

     <ns0:TypedPollingResultSet2> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoBA1>BA1_1B</ns0:MiscInfoBA1> 
      <ns0:MiscInfoBA2>BA2_1B</ns0:MiscInfoBA2> 
     </ns0:TypedPollingResultSet2> 

     <ns0:TypedPollingResultSet2> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoBA1>BA1_2A</ns0:MiscInfoBA1> 
      <ns0:MiscInfoBA2>BA2_2A</ns0:MiscInfoBA2> 
     </ns0:TypedPollingResultSet2> 

     <ns0:TypedPollingResultSet2> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoBA1>BA1_2B</ns0:MiscInfoBA1> 
      <ns0:MiscInfoBA2>BA2_2B</ns0:MiscInfoBA2> 
     </ns0:TypedPollingResultSet2> 
    </ns0:TypedPollingResultSet2> 

    <ns0:TypedPollingResultSet3> 
     <ns0:TypedPollingResultSet3> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoBB1>BB1_1A</ns0:MiscInfoBB1> 
      <ns0:MiscInfoBB2>BB2_1A</ns0:MiscInfoBB2> 
     </ns0:TypedPollingResultSet3> 

     <ns0:TypedPollingResultSet3> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoBB1>BB1_1B</ns0:MiscInfoBB1> 
      <ns0:MiscInfoBB2>BB2_1B</ns0:MiscInfoBB2> 
     </ns0:TypedPollingResultSet3> 

     <ns0:TypedPollingResultSet3> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoBB1>BB1_2</ns0:MiscInfoBB1> 
      <ns0:MiscInfoBB2>BB2_2</ns0:MiscInfoBB2> 
     </ns0:TypedPollingResultSet3> 
    </ns0:TypedPollingResultSet3> 

    <ns0:TypedPollingResultSet4> 
     <ns0:TypedPollingResultSet4> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupCInstanceID>GroupCInstanceID_1A</ns0:GroupCInstanceID> 
      <ns0:MiscInfoC1>C1_1A</ns0:MiscInfoC1> 
      <ns0:MiscInfoC2>C2_1A</ns0:MiscInfoC2> 
     </ns0:TypedPollingResultSet4> 

     <ns0:TypedPollingResultSet4> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupCInstanceID>GroupCInstanceID_1B</ns0:GroupCInstanceID> 
      <ns0:MiscInfoC1>C1_1B</ns0:MiscInfoC1> 
      <ns0:MiscInfoC2>C2_1B</ns0:MiscInfoC2> 
     </ns0:TypedPollingResultSet4> 

     <ns0:TypedPollingResultSet4> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:GroupCInstanceID>GroupCInstanceID_2</ns0:GroupCInstanceID> 
      <ns0:MiscInfoC1>C1_2</ns0:MiscInfoC1> 
      <ns0:MiscInfoC2>C2_2</ns0:MiscInfoC2> 
     </ns0:TypedPollingResultSet4> 
    </ns0:TypedPollingResultSet4> 

    <ns0:TypedPollingResultSet5> 
     <ns0:TypedPollingResultSet5> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1A</ns0:GroupDInstanceID> 
      <ns0:MiscInfoD1>D1_1A</ns0:MiscInfoD1> 
      <ns0:MiscInfoD2>D2_1A</ns0:MiscInfoD2> 
     </ns0:TypedPollingResultSet5> 

     <ns0:TypedPollingResultSet5> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1B</ns0:GroupDInstanceID> 
      <ns0:MiscInfoD1>D1_1B</ns0:MiscInfoD1> 
      <ns0:MiscInfoD2>D2_1B</ns0:MiscInfoD2> 
     </ns0:TypedPollingResultSet5> 

     <ns0:TypedPollingResultSet5> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_2</ns0:GroupDInstanceID> 
      <ns0:MiscInfoD1>D1_2</ns0:MiscInfoD1> 
      <ns0:MiscInfoD2>D2_2</ns0:MiscInfoD2> 
     </ns0:TypedPollingResultSet5> 
    </ns0:TypedPollingResultSet5> 

    <ns0:TypedPollingResultSet6> 
     <ns0:TypedPollingResultSet6> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1A</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDA1>DA1_1A</ns0:MiscInfoDA1> 
      <ns0:MiscInfoDA2>DA2_1A</ns0:MiscInfoDA2> 
     </ns0:TypedPollingResultSet6> 

     <ns0:TypedPollingResultSet6> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1B</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDA1>DA1_1B</ns0:MiscInfoDA1> 
      <ns0:MiscInfoDA2>DA2_1B</ns0:MiscInfoDA2> 
     </ns0:TypedPollingResultSet6> 

     <ns0:TypedPollingResultSet6> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_2</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDA1>DA1_2</ns0:MiscInfoDA1> 
      <ns0:MiscInfoDA2>DA2_2</ns0:MiscInfoDA2> 
     </ns0:TypedPollingResultSet6> 
    </ns0:TypedPollingResultSet6> 

    <ns0:TypedPollingResultSet7> 
     <ns0:TypedPollingResultSet7> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1A</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDB1>DB1_1A</ns0:MiscInfoDB1> 
      <ns0:MiscInfoDB2>DB2_1A</ns0:MiscInfoDB2> 
     </ns0:TypedPollingResultSet7> 

     <ns0:TypedPollingResultSet7> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_1B</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDB1>DB1_1B</ns0:MiscInfoDB1> 
      <ns0:MiscInfoDB2>DB2_1B</ns0:MiscInfoDB2> 
     </ns0:TypedPollingResultSet7> 

     <ns0:TypedPollingResultSet7> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:GroupDInstanceID>GroupDInstanceID_2</ns0:GroupDInstanceID> 
      <ns0:MiscInfoDB1>DB1_2</ns0:MiscInfoDB1> 
      <ns0:MiscInfoDB2>DB2_2</ns0:MiscInfoDB2> 
     </ns0:TypedPollingResultSet7> 
    </ns0:TypedPollingResultSet7> 
</ns0:TypedPolling> 

所望の出力:ジョンズ-305の提案を1として

<ns0:AllRecords xmlns:ns0="http://SmallGenericSchemaTest.Schemas/DestinationSchema"> 
    <ns0:SingleRecord> 
     <ns0:GroupA> 
      <ns0:SharedID>SharedID_1</ns0:SharedID> 
      <ns0:MiscInfoA1>A1_1</ns0:MiscInfoA1> 
      <ns0:MiscInfoA2>A2_1</ns0:MiscInfoA2> 
     </ns0:GroupA> 

     <ns0:GroupB> 
      <ns0:MiscInfoB1>B1_1</ns0:MiscInfoB1> 
      <ns0:MiscInfoB2>B2_1</ns0:MiscInfoB2> 

      <ns0:SubGroupBAContainer> 
       <ns0:SubGroupBA> 
        <ns0:MiscInfoBA1>BA1_1A</ns0:MiscInfoBA1> 
        <ns0:MiscInfoBA2>BA2_1A</ns0:MiscInfoBA2> 
       </ns0:SubGroupBA> 

       <ns0:SubGroupBA> 
        <ns0:MiscInfoBA1>BA1_1B</ns0:MiscInfoBA1> 
        <ns0:MiscInfoBA2>BA2_1B</ns0:MiscInfoBA2> 
       </ns0:SubGroupBA> 
      </ns0:SubGroupBAContainer> 

      <ns0:SubGroupBBContainer> 
       <ns0:SubGroupBB> 
        <ns0:MiscInfoBB1>BB1_1A</ns0:MiscInfoBB1> 
        <ns0:MiscInfoBB2>BB2_1A</ns0:MiscInfoBB2> 
       </ns0:SubGroupBB> 

       <ns0:SubGroupBB> 
        <ns0:MiscInfoBB1>BB1_1B</ns0:MiscInfoBB1> 
        <ns0:MiscInfoBB2>BB2_1B</ns0:MiscInfoBB2> 
       </ns0:SubGroupBB> 
      </ns0:SubGroupBBContainer> 
     </ns0:GroupB> 

     <ns0:GroupCContainer> 
      <ns0:GroupC> 
       <ns0:GroupCInstanceID>GroupCInstanceID_1A</ns0:GroupCInstanceID> 
       <ns0:MiscInfoC1>C1_1A</ns0:MiscInfoC1> 
       <ns0:MiscInfoC2>C2_1A</ns0:MiscInfoC2> 
      </ns0:GroupC> 

      <ns0:GroupC> 
       <ns0:GroupCInstanceID>GroupCInstanceID_1B</ns0:GroupCInstanceID> 
       <ns0:MiscInfoC1>C1_1B</ns0:MiscInfoC1> 
       <ns0:MiscInfoC2>C2_1B</ns0:MiscInfoC2> 
      </ns0:GroupC> 
     </ns0:GroupCContainer> 

     <ns0:GroupDContainer> 
      <ns0:GroupD> 
       <ns0:GroupDInstanceID>GroupDInstanceID_1A</ns0:GroupDInstanceID> 
       <ns0:MiscInfoD1>D1_1A</ns0:MiscInfoD1> 
       <ns0:MiscInfoD2>D2_1A</ns0:MiscInfoD2> 

       <ns0:SubGroupDA> 
        <ns0:MiscInfoDA1>DA1_1A</ns0:MiscInfoDA1> 
        <ns0:MiscInfoDA2>DA2_1A</ns0:MiscInfoDA2> 
       </ns0:SubGroupDA> 

       <ns0:SubGroupDBContainer> 
        <ns0:SubGroupDB> 
         <ns0:MiscInfoDB1>DB1_1A</ns0:MiscInfoDB1> 
         <ns0:MiscInfoDB2>DB2_1A</ns0:MiscInfoDB2> 
        </ns0:SubGroupDB> 
       </ns0:SubGroupDBContainer> 
      </ns0:GroupD> 

      <ns0:GroupD> 
       <ns0:GroupDInstanceID>GroupDInstanceID_1B</ns0:GroupDInstanceID> 
       <ns0:MiscInfoD1>D1_1B</ns0:MiscInfoD1> 
       <ns0:MiscInfoD2>D2_1B</ns0:MiscInfoD2> 

       <ns0:SubGroupDA> 
        <ns0:MiscInfoDA1>DA1_1B</ns0:MiscInfoDA1> 
        <ns0:MiscInfoDA2>DA2_1B</ns0:MiscInfoDA2> 
       </ns0:SubGroupDA> 

       <ns0:SubGroupDBContainer> 
        <ns0:SubGroupDB> 
         <ns0:MiscInfoDB1>DB1_1B</ns0:MiscInfoDB1> 
         <ns0:MiscInfoDB2>DB2_1B</ns0:MiscInfoDB2> 
        </ns0:SubGroupDB> 
       </ns0:SubGroupDBContainer> 
      </ns0:GroupD> 
     </ns0:GroupDContainer> 
    </ns0:SingleRecord> 

    <ns0:SingleRecord> 
     <ns0:GroupA> 
      <ns0:SharedID>SharedID_2</ns0:SharedID> 
      <ns0:MiscInfoA1>A1_2</ns0:MiscInfoA1> 
      <ns0:MiscInfoA2>A2_2</ns0:MiscInfoA2> 
     </ns0:GroupA> 

     <ns0:GroupB> 
      <ns0:MiscInfoB1>B1_2</ns0:MiscInfoB1> 
      <ns0:MiscInfoB2>B2_2</ns0:MiscInfoB2> 

      <ns0:SubGroupBAContainer> 
       <ns0:SubGroupBA> 
        <ns0:MiscInfoBA1>BA1_2A</ns0:MiscInfoBA1> 
        <ns0:MiscInfoBA2>BA2_2A</ns0:MiscInfoBA2> 
       </ns0:SubGroupBA> 

       <ns0:SubGroupBA> 
        <ns0:MiscInfoBA1>BA1_2B</ns0:MiscInfoBA1> 
        <ns0:MiscInfoBA2>BA2_2B</ns0:MiscInfoBA2> 
       </ns0:SubGroupBA> 
      </ns0:SubGroupBAContainer> 

      <ns0:SubGroupBBContainer> 
       <ns0:SubGroupBB> 
        <ns0:MiscInfoBB1>BB1_2</ns0:MiscInfoBB1> 
        <ns0:MiscInfoBB2>BB2_2</ns0:MiscInfoBB2> 
       </ns0:SubGroupBB> 
      </ns0:SubGroupBBContainer> 
     </ns0:GroupB> 

     <ns0:GroupCContainer> 
      <ns0:GroupC> 
       <ns0:GroupCInstanceID>GroupCInstanceID_2</ns0:GroupCInstanceID> 
       <ns0:MiscInfoC1>C1_2</ns0:MiscInfoC1> 
       <ns0:MiscInfoC2>C2_2</ns0:MiscInfoC2> 
      </ns0:GroupC> 
     </ns0:GroupCContainer> 

     <ns0:GroupDContainer> 
      <ns0:GroupD> 
       <ns0:GroupDInstanceID>GroupDInstanceID_2</ns0:GroupDInstanceID> 
       <ns0:MiscInfoD1>D1_2</ns0:MiscInfoD1> 
       <ns0:MiscInfoD2>D2_2</ns0:MiscInfoD2> 

       <ns0:SubGroupDA> 
        <ns0:MiscInfoDA1>DA1_2</ns0:MiscInfoDA1> 
        <ns0:MiscInfoDA2>DA2_2</ns0:MiscInfoDA2> 
       </ns0:SubGroupDA> 

       <ns0:SubGroupDBContainer> 
        <ns0:SubGroupDB> 
         <ns0:MiscInfoDB1>DB1_2</ns0:MiscInfoDB1> 
         <ns0:MiscInfoDB2>DB2_2</ns0:MiscInfoDB2> 
        </ns0:SubGroupDB> 
       </ns0:SubGroupDBContainer> 
      </ns0:GroupD> 
     </ns0:GroupDContainer> 
    </ns0:SingleRecord> 
</ns0:AllRecords> 
+0

サンプルのペイロードがないと、人が再現するのが少し難しいです。あなたはそれを追加できますか?また、現在の出力と何が必要かを強調表示することも役立ちます。 – Dijkgraaf

+0

FOR XMLクエリを試しましたか?その場合、SQL Serverはすべてのグループ化を管理します。 –

+0

実際、非常に重要なことに、これはMuenchianのケースではないかもしれません。結果セットごとにTypedPollingResultSet0のSharedIDが一意ですか?もしそうなら、これはMuenchian事件ではなく、ずっと簡単です。 –

答えて

0

、私はMuenchianグループへの代替を見て、として働いているように見える、それ以下ソリューションに到着しました意図されました。確かに、私はMuenchian法を調べた後、自分自身にトンネルビジョンを与えていたようです。最終的な結果はずっと簡単になりましたが、XSLTを経験していないため、あまり明確ではありませんでした。

誰かがこれを行うより良い方法を知っている場合や、改善の余地がある場合は、お気軽にご意見をお寄せください。私はより良いものが来る場合にこの答えを受け入れる前に、質問を数日間開いたままにしておきます。ありがとう!

<?xml version="1.0" encoding="UTF-16"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
       xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" 
       exclude-result-prefixes="msxsl var s0" 
       version="1.0" 
       xmlns:s0="http://SmallGenericSchemaTest.Schemas/SourceSchema" 
       xmlns:ns0="http://SmallGenericSchemaTest.Schemas/DestinationSchema"> 
    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> 

    <xsl:template match="/"> 
     <xsl:apply-templates select="/s0:TypedPolling" /> 
    </xsl:template> 

    <xsl:template match="/s0:TypedPolling"> 
     <ns0:AllRecords> 
      <xsl:for-each select="s0:TypedPollingResultSet0/s0:TypedPollingResultSet0"> 
       <ns0:SingleRecord> 

        <ns0:GroupA> 
         <xsl:if test="s0:SharedID"> 
          <ns0:SharedID> 
           <xsl:value-of select="s0:SharedID/text()" /> 
          </ns0:SharedID> 
         </xsl:if> 

         <xsl:if test="s0:MiscInfoA1"> 
          <ns0:MiscInfoA1> 
           <xsl:value-of select="s0:MiscInfoA1/text()" /> 
          </ns0:MiscInfoA1> 
         </xsl:if> 

         <xsl:if test="s0:MiscInfoA2"> 
          <ns0:MiscInfoA2> 
           <xsl:value-of select="s0:MiscInfoA2/text()" /> 
          </ns0:MiscInfoA2> 
         </xsl:if> 
        </ns0:GroupA> 


        <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet1/s0:TypedPollingResultSet1[s0:SharedID = current()/s0:SharedID]"> 
         <ns0:GroupB> 
          <xsl:if test="s0:MiscInfoB1"> 
           <ns0:MiscInfoB1> 
            <xsl:value-of select="s0:MiscInfoB1/text()" /> 
           </ns0:MiscInfoB1> 
          </xsl:if> 

          <xsl:if test="s0:MiscInfoB2"> 
           <ns0:MiscInfoB2> 
            <xsl:value-of select="s0:MiscInfoB2/text()" /> 
           </ns0:MiscInfoB2> 
          </xsl:if> 

          <ns0:SubGroupBAContainer> 
           <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet2/s0:TypedPollingResultSet2[s0:SharedID = current()/s0:SharedID]"> 
            <ns0:SubGroupBA> 
             <xsl:if test="s0:MiscInfoBA1"> 
              <ns0:MiscInfoBA1> 
               <xsl:value-of select="s0:MiscInfoBA1/text()" /> 
              </ns0:MiscInfoBA1> 
             </xsl:if> 

             <xsl:if test="s0:MiscInfoBA2"> 
              <ns0:MiscInfoBA2> 
               <xsl:value-of select="s0:MiscInfoBA2/text()" /> 
              </ns0:MiscInfoBA2> 
             </xsl:if> 
            </ns0:SubGroupBA> 
           </xsl:for-each> 
          </ns0:SubGroupBAContainer> 

          <ns0:SubGroupBBContainer> 
           <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet3/s0:TypedPollingResultSet3[s0:SharedID = current()/s0:SharedID]"> 
            <ns0:SubGroupBB> 
             <xsl:if test="s0:MiscInfoBB1"> 
              <ns0:MiscInfoBB1> 
               <xsl:value-of select="s0:MiscInfoBB1/text()" /> 
              </ns0:MiscInfoBB1> 
             </xsl:if> 

             <xsl:if test="s0:MiscInfoBB2"> 
              <ns0:MiscInfoBB2> 
               <xsl:value-of select="s0:MiscInfoBB2/text()" /> 
              </ns0:MiscInfoBB2> 
             </xsl:if> 
            </ns0:SubGroupBB> 
           </xsl:for-each> 
          </ns0:SubGroupBBContainer> 
         </ns0:GroupB> 
        </xsl:for-each> 


        <xsl:if test="/s0:TypedPolling/s0:TypedPollingResultSet4/s0:TypedPollingResultSet4[s0:SharedID = current()/s0:SharedID]"> 
         <ns0:GroupCContainer> 
          <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet4/s0:TypedPollingResultSet4[s0:SharedID = current()/s0:SharedID]"> 
           <ns0:GroupC> 
            <xsl:if test="s0:GroupCInstanceID"> 
             <ns0:GroupCInstanceID> 
              <xsl:value-of select="s0:GroupCInstanceID/text()" /> 
             </ns0:GroupCInstanceID> 
            </xsl:if> 

            <xsl:if test="s0:MiscInfoC1"> 
             <ns0:MiscInfoC1> 
              <xsl:value-of select="s0:MiscInfoC1/text()" /> 
             </ns0:MiscInfoC1> 
            </xsl:if> 

            <xsl:if test="s0:MiscInfoC2"> 
             <ns0:MiscInfoC2> 
              <xsl:value-of select="s0:MiscInfoC2/text()" /> 
             </ns0:MiscInfoC2> 
            </xsl:if> 
           </ns0:GroupC> 
          </xsl:for-each> 
         </ns0:GroupCContainer> 
        </xsl:if> 


        <xsl:if test="/s0:TypedPolling/s0:TypedPollingResultSet5/s0:TypedPollingResultSet5[s0:SharedID = current()/s0:SharedID]"> 
         <ns0:GroupDContainer> 
          <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet5/s0:TypedPollingResultSet5[s0:SharedID = current()/s0:SharedID]"> 
           <ns0:GroupD> 
            <xsl:if test="s0:GroupDInstanceID"> 
             <ns0:GroupDInstanceID> 
              <xsl:value-of select="s0:GroupDInstanceID/text()" /> 
             </ns0:GroupDInstanceID> 
            </xsl:if> 

            <xsl:if test="s0:MiscInfoD1"> 
             <ns0:MiscInfoD1> 
              <xsl:value-of select="s0:MiscInfoD1/text()" /> 
             </ns0:MiscInfoD1> 
            </xsl:if> 

            <xsl:if test="s0:MiscInfoD2"> 
             <ns0:MiscInfoD2> 
              <xsl:value-of select="s0:MiscInfoD2/text()" /> 
             </ns0:MiscInfoD2> 
            </xsl:if> 

            <xsl:if test="/s0:TypedPolling/s0:TypedPollingResultSet6/s0:TypedPollingResultSet6[s0:SharedID = current()/s0:SharedID] 
              and /s0:TypedPolling/s0:TypedPollingResultSet6/s0:TypedPollingResultSet6[s0:GroupDInstanceID = current()/s0:GroupDInstanceID]"> 
             <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet6/s0:TypedPollingResultSet6[s0:SharedID = current()/s0:SharedID 
                 and s0:GroupDInstanceID = current()/s0:GroupDInstanceID]"> 
              <ns0:SubGroupDA> 
               <xsl:if test="s0:MiscInfoDA1"> 
                <ns0:MiscInfoDA1> 
                 <xsl:value-of select="s0:MiscInfoDA1/text()" /> 
                </ns0:MiscInfoDA1> 
               </xsl:if> 

               <xsl:if test="s0:MiscInfoDA2"> 
                <ns0:MiscInfoDA2> 
                 <xsl:value-of select="s0:MiscInfoDA2/text()" /> 
                </ns0:MiscInfoDA2> 
               </xsl:if> 
              </ns0:SubGroupDA> 
             </xsl:for-each> 
            </xsl:if> 

            <xsl:if test="/s0:TypedPolling/s0:TypedPollingResultSet7/s0:TypedPollingResultSet7[s0:SharedID = current()/s0:SharedID] 
              and /s0:TypedPolling/s0:TypedPollingResultSet7/s0:TypedPollingResultSet7[s0:GroupDInstanceID = current()/s0:GroupDInstanceID]"> 
             <ns0:SubGroupDBContainer> 
              <xsl:for-each select="/s0:TypedPolling/s0:TypedPollingResultSet7/s0:TypedPollingResultSet7[s0:SharedID = current()/s0:SharedID 
                  and s0:GroupDInstanceID = current()/s0:GroupDInstanceID]"> 
               <ns0:SubGroupDB> 
                <xsl:if test="s0:MiscInfoDB1"> 
                 <ns0:MiscInfoDB1> 
                  <xsl:value-of select="s0:MiscInfoDB1/text()" /> 
                 </ns0:MiscInfoDB1> 
                </xsl:if> 

                <xsl:if test="s0:MiscInfoDB2"> 
                 <ns0:MiscInfoDB2> 
                  <xsl:value-of select="s0:MiscInfoDB2/text()" /> 
                 </ns0:MiscInfoDB2> 
                </xsl:if> 
               </ns0:SubGroupDB> 
              </xsl:for-each> 
             </ns0:SubGroupDBContainer> 
            </xsl:if> 
           </ns0:GroupD> 
          </xsl:for-each> 
         </ns0:GroupDContainer> 
        </xsl:if> 

       </ns0:SingleRecord> 
      </xsl:for-each> 
     </ns0:AllRecords> 
    </xsl:template> 
</xsl:stylesheet> 
関連する問題