Conditionally grab attribute in map

Home Page Forums BizTalk 2004 – BizTalk 2010 Conditionally grab attribute in map

Viewing 1 reply thread
  • Author
    Posts
    • #17833

      Hello All,

      This is a very simple question, but I like to provide detail…

      Thanks -wa for the prior help.

      I have a map. The schema on the left has a repeating node, where the node has two attributes, say "att1" and "att2". Keep in mind that this node only appears once in the schema the left, it just happens to be repeatable. The schema on the right is flat, a bunch of nodes at the same level. I need to map the att2 values to the nodes on the right, but their location is dependant on att1. That is:

      On the left
      ===========
      <base>
      <foo att1="mostfavorite" att2="apple"/>
      </base>
      <base>
      <foo att1="leastfavorite" att2="pear"/>
      </base>

      and I need on right
      ===================
      <loveit>apple</loveit>
      <hateit>pear</hateit>

      <nextnode/>

      The <loveit> node gets populated with the att2 in <foo> where att1="mostfavorite", and similarly with leastfavorite. 'loveit' and 'hateit' are both required, and will always be supplied on the left.

      For loveit, I tried using an equals functoid (looking for att1="mostfavorite"), then sending to to a value mapper (the second parameter of which is att2) and sending it out. When I use this same technique to try and populate 'hateit' , I get this error:

      Output validation error: The element 'Body' (the root of the destination) has invalid child element 'nextnode'. List of possible elements expected: 'hateit'

      It seems as though that when there's more than one <base> element, it can find anything other than the first one I match on. It's not pickiting it up when I try to match on the second. I tried if-then-else construct too, with it always going to what's in the else clause.

      Any help would be helpful. Details appreciated.

      Thanks,

      Chris

    • #17835

      Chris,

      You would laugh at yourself if I tell you the solution.

      Wht u did is perfectly fine.

      Just right Click your Map….Properties.

      Set "Validate Test Map Output"  to False.

      Or

      Set Min Occurs to 0 for both HateIt and LoveIt node in Output Schema.

      The Obvious reason is…..the first time the "mostFavourite" node is selected so the node "Loveit" is created at Destination.

      Now the next node to be created is "HateIt" in Output Xml File as Min occurs is not set to 0.

      Hope you find it Useful.

      • #17838

        [quote user="NISHIL"]

        Chris,

        You would laugh at yourself if I tell you the solution.

        Wht u did is perfectly fine.

        Just right Click your Map….Properties.

        Set "Validate Test Map Output"  to False.

        Or

        Set Min Occurs to 0 for both HateIt and LoveIt node in Output Schema.

        The Obvious reason is…..the first time the "mostFavourite" node is selected so the node "Loveit" is created at Destination.

        Now the next node to be created is "HateIt" in Output Xml File as Min occurs is not set to 0.

        Hope you find it Useful.

        [/quote]

        Nishil – this solution doesn't give him a valid message – he requires both loveit and hateit. What he really wants to do is populate the data as shown, and he says he always gets "mostfavorite" and "leastfavorite."

        Chris

        – tie "foo" to a looping functoid and tie that to both "loveit" and "hateit".

        – turn off validation and see that you'll get 2 occurs of mostfavorite and 2 occurs of leastfavorite when you run. You need to now kill the empty iterations of loveit and hateit.

        – tie the logical output from both "= mostfavorite" and "= leastfavorite" functoids, which you used for the value mappers, to "loveit" and "hateit" respectively. What this does is sent a 'false' to the node and keep it from being created when not true.  

        in summary, create all possible iterations and kill the unwanted ones.

        – weak architect

         

         

        • #17839

          oops – this should actually say:

          – turn off validation and see that you'll get 2 occurs of loveit
          and 2 occurs of hateit when you run. You need to now kill the
          empty iterations of loveit and hateit.

           – wa
           

          • #17846

            Chris…

            If u cant kill the empty iterations use a custom XSLT.

            I have experienced  the power of it and yours is a simple thing to be done using XSLT.

            • #17879

              Thanks NISHIL and wa, between the two of you – I got it.

               

              This group has always been very helpful, so thanks for your continued support.

               

              Chris

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.