none
Mapping: How to detect Source of Looping RRS feed

  • Question

  • Hi there,

    I have the following source. The .xml contains multiple "Item" and may contain "Extracode".

    In case the Item contains 3 Extracode, I need 4 lines in destination.

    3 of the lines in destination become ExtracodeId mapped, the forth has to get a static text.

    My mapping works fine (a static text is written in destination:extracodeid), in case the Item has no Extracodes below. But even there is 1+ Extracode below, no "empty" line is generated, the first "extracode" is used twice.

    Thanks in advance,

    Daniel



    Thursday, June 8, 2017 1:41 PM

All replies

  • Hi Daniel,

    You may want to post snippets of your source XML, your current result XML and the XML you desire. That will help us understand your issue better.

    Looking at your map you will have one RevitPlanItemGLD/RevitPlanGLD_1 element for each ExtraCode element.

    So elaborate a bit more on what you want and give us the snippets. Here is a hint. You may want to write what you want in custom XSLT.


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com



    Thursday, June 8, 2017 2:51 PM
  • Daniel,

    Looking further at the map and what you describe, I would try using direct links from ProjId and ExtraCode to RevitPlanIOtemGLD_1. The Exists functoid is having trouble knowing which record you are referring to, and that may be because of the Looping functoid with 2 input links. Give it a shot.

    If you post snippets I'll play with it and figure it out later today.


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com

    Thursday, June 8, 2017 3:21 PM
  • Thanks for your help, Mauricio :)

    This is an example of my input:

    <ns0:Root xmlns:ns0="http://AX_SalesItem.uebergabe">
      <UserName>user</UserName>
      <Project ProjId="prj">
        <SalesItem SalesId="si0021">
          <Item ItemId="P8">
            <Qty>4</Qty>
            <ElementCount>6</ElementCount>
          </Item>
        </SalesItem>
        <SalesItem SalesId="si0021">
          <Item ItemId="P1">
            <Qty>2</Qty>
            <ElementCount>8</ElementCount>
            <Extracode ExtraCodeId="Code">
              <Qty>12</Qty>
            </Extracode>        
          </Item>
        </SalesItem>
      </Project>
    </ns0:Root>

    Currently I get this:

    <ns3:RevitPlanImpGLD>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
      	<ns3:ExtraPartCode>Basis</ns3:ExtraPartCode>
      	<ns3:ItemId>P8</ns3:ItemId>
      	<ns3:ProjId>prj</ns3:ProjId>
      	<ns3:Qty>4</ns3:Qty>  	
      	<ns3:SalesId>si0021</ns3:SalesId>  	
      </ns3:RevitPlanItemGLD_1>  
      
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
      	<ns3:ExtraPartCode>Code</ns3:ExtraPartCode>
      	<ns3:ExtraPartQty>12</ns3:ExtraPartQty>
      	<ns3:ItemId>P1</ns3:ItemId>
      	<ns3:ProjId>prj</ns3:ProjId>
      	<ns3:Qty>2</ns3:Qty>  	
      	<ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
    </ns3:RevitPlanImpGLD>  

    But I want to have this:

    <ns3:RevitPlanImpGLD>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
      	<ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
      	<ns3:ItemId>P8</ns3:ItemId>
      	<ns3:ProjId>prj</ns3:ProjId>
      	<ns3:Qty>4</ns3:Qty>  	
      	<ns3:SalesId>si0021</ns3:SalesId>  	
      </ns3:RevitPlanItemGLD_1>  
      
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
      	<ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
      	<ns3:ItemId>P1</ns3:ItemId>
      	<ns3:ProjId>prj</ns3:ProjId>
      	<ns3:Qty>2</ns3:Qty>  	
      	<ns3:SalesId>si0021</ns3:SalesId>  	
      </ns3:RevitPlanItemGLD_1>   
      
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
      	<ns3:ExtraPartCode>Code</ns3:ExtraPartCode>
      	<ns3:ExtraPartQty>12</ns3:ExtraPartQty>
      	<ns3:ItemId>P1</ns3:ItemId>
      	<ns3:ProjId>prj</ns3:ProjId>
      	<ns3:Qty>2</ns3:Qty>  	
      	<ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
    
    </ns3:RevitPlanImpGLD>

    As you can see, I need a record without extracode, even extracode exists.

    It works fine when there is no extracode. In this case a record with a static text in field "extrapartcode" is generated.

    In case there is a extracode in record, I need this base-record too. And after that another record(s) with the extrapart and extrapartQty.

    Greetings, Daniel


    Friday, June 9, 2017 6:51 AM
  • Daniel,

    Looking further at the map and what you describe, I would try using direct links from ProjId and ExtraCode to RevitPlanIOtemGLD_1. The Exists functoid is having trouble knowing which record you are referring to, and that may be because of the Looping functoid with 2 input links. Give it a shot.

    If you post snippets I'll play with it and figure it out later today.


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com

    I tried direct links. Now only extracodes were generatet, no pure items.
    Friday, June 9, 2017 7:50 AM
  • Validate the map and look at the generated xslt. 


    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool/

    Friday, June 9, 2017 9:28 AM
    Answerer
  • Imo calls for custom xslt
    Might be possible with a complex table looping functiod build up or maybe a scripting functiod with an xslt template

    It's a bit difficult to add extra records using only functiods in the mapping tool

    rgds /Peter

    Friday, June 9, 2017 10:58 AM
  • Imo calls for custom xslt
    Might be possible with a complex table looping functiod build up or maybe a scripting functiod with an xslt template

    It's a bit difficult to add extra records using only functiods in the mapping tool

    rgds /Peter

    I see. Unfortunatelly I have no experience with xslt. It seems I have to work on that.

    Friday, June 9, 2017 11:21 AM
  • The flexibility you get as developer and reviewer is ten fold worth the effort

    You can 
    1) add code comments 
    2) comment out out blocks of code and work with only a subset
    3) debug code

    rgds /Peter

    Friday, June 9, 2017 11:30 AM
  • Hi Daniel,

    Use custom XSLT.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    >
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="/">
        <ns3:RevitPlanImpGLD xmlns:ns3="http://UpdateWithCorrectNamespace">
    
          <xsl:for-each select="/*[local-name()='Root' and namespace-uri()='http://AX_SalesItem.uebergabe']/*[local-name()='Project']/*[local-name()='SalesItem']/*[local-name()='Item']">
            <ns3:RevitPlanItemGLD_1 class="entity">
              <ns3:Elementcount>
                <xsl:value-of select="./*[local-name()='ElementCount']"/>
              </ns3:Elementcount>
              <ns3:ExtraPartCode>
                <xsl:text>static_text</xsl:text>
              </ns3:ExtraPartCode>
              <ns3:ItemId>
                <xsl:value-of select="./@*[local-name()='ItemId']"/>
              </ns3:ItemId>
              <ns3:ProjId>
                <xsl:value-of select="/*[local-name()='Root' and namespace-uri()='http://AX_SalesItem.uebergabe']/*[local-name()='Project']/@*[local-name()='ProjId']"/>
              </ns3:ProjId>
              <ns3:Qty>
                <xsl:value-of select="./*[local-name()='Qty']"/>
              </ns3:Qty>
              <ns3:SalesId>
                <xsl:value-of select="../@*[local-name()='SalesId']"/>
              </ns3:SalesId>
            </ns3:RevitPlanItemGLD_1>
    
            <xsl:if test="./*[local-name()='Extracode']">
              <xsl:for-each select="./*[local-name()='Extracode']">
                <ns3:RevitPlanItemGLD_1 class="entity">
                  <ns3:Elementcount>
                    <xsl:value-of select="../*[local-name()='ElementCount']"/>
                  </ns3:Elementcount>
                  <ns3:ExtraPartCode>
                    <xsl:text>static_text</xsl:text>
                  </ns3:ExtraPartCode>
                  <ns3:ItemId>
                    <xsl:value-of select="../@*[local-name()='ItemId']"/>
                  </ns3:ItemId>
                  <ns3:ProjId>
                    <xsl:value-of select="/*[local-name()='Root' and namespace-uri()='http://AX_SalesItem.uebergabe']/*[local-name()='Project']/@*[local-name()='ProjId']"/>
                  </ns3:ProjId>
                  <ns3:Qty>
                    <xsl:value-of select="./*[local-name()='Qty']"/>
                  </ns3:Qty>
                  <ns3:SalesId>
                    <xsl:value-of select="../../@*[local-name()='SalesId']"/>
                  </ns3:SalesId>
                </ns3:RevitPlanItemGLD_1>
              </xsl:for-each>
            </xsl:if>
          </xsl:for-each>
        </ns3:RevitPlanImpGLD>
      </xsl:template>
    </xsl:stylesheet>
    
    

    Input File:

    <ns0:Root xmlns:ns0="http://AX_SalesItem.uebergabe">
      <UserName>user</UserName>
      <Project ProjId="prj">
        <SalesItem SalesId="si0020">
          <Item ItemId="P8">
            <Qty>4</Qty>
            <ElementCount>6</ElementCount>
          </Item>
        </SalesItem>
        <SalesItem SalesId="si0021">
          <Item ItemId="P1">
            <Qty>2</Qty>
            <ElementCount>8</ElementCount>
            <Extracode ExtraCodeId="Code">
              <Qty>12</Qty>
            </Extracode>
            <Extracode ExtraCodeId="Code">
              <Qty>11</Qty>
            </Extracode>
            <Extracode ExtraCodeId="Code">
              <Qty>10</Qty>
            </Extracode>
            <Extracode ExtraCodeId="Code">
              <Qty>9</Qty>
            </Extracode>
          </Item>
        </SalesItem>
      </Project>
    </ns0:Root>

    Output:

    <?xml version="1.0" encoding="utf-8"?>
    <ns3:RevitPlanImpGLD xmlns:ns3="http://UpdateWithCorrectNamespace">
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>6</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P8</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>4</ns3:Qty>
        <ns3:SalesId>si0020</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>8</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P1</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>2</ns3:Qty>
        <ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>8</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P1</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>12</ns3:Qty>
        <ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>8</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P1</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>11</ns3:Qty>
        <ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>8</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P1</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>10</ns3:Qty>
        <ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
      <ns3:RevitPlanItemGLD_1 class="entity">
        <ns3:Elementcount>8</ns3:Elementcount>
        <ns3:ExtraPartCode>static_text</ns3:ExtraPartCode>
        <ns3:ItemId>P1</ns3:ItemId>
        <ns3:ProjId>prj</ns3:ProjId>
        <ns3:Qty>9</ns3:Qty>
        <ns3:SalesId>si0021</ns3:SalesId>
      </ns3:RevitPlanItemGLD_1>
    </ns3:RevitPlanImpGLD>

    Best regards

    Rasmus Jaeger

    Thursday, June 15, 2017 12:28 PM