AnsweredAssumed Answered

how To achieve choose/when,for-loop in map with xpath

Question asked by akshaysachdeva91015733 on Jul 5, 2017
Latest reply on Jul 7, 2017 by daniel.santana

How to achieve the following in a map like we used to achieve in xsl:-

 

XML:

<A>

   <B>

            <C>abc</C>

            <D>mapAsPerC</D>

             <E>map This if D stringLength is 0</E>

   </B>  

<B>

            <C>def</C>

            <D>mapAsPerC</D>

            <E>map This if D stringLength is 0</E>

   </B>

</A>

 

Want to achieve the following(map the value to the target element  <FinalMappingElementValue>):-

 

choose
when test='/A/B[C/text() = "abc"]'
   choose
        when test='string-length(/A/B[C/text() = "abc"]/D) = 0.0'>
         <FinalMappingElementValue>
         <value-of select='/A/B[C/text() = "abc"]/E/text()'/>
         </FinalMappingElementValue>
          /when
          otherwise
         <FinalMappingElementValue>
         <xsl:value-of select='/A/B[C/text() = "abc"]/D/text()'/>
         </FinalMappingElementValue>
         /otherwise
   /choose

/when

otherwise
<FinalMappingElementValue/>(map as null)
/otherwise
/choose

Outcomes