Click here to Skip to main content
14,771,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Here is my below input request, Since my input request and XSLT is lengthy I made it short here. I will be getting nearly 10 ProdustID's, I have to fetch all of them and I want to write it without using "template match" since I cannot use template as child element in my xslt. How should i write this in XSLT to get the wanted output ?

Input:

<ChannelPartnerMembershipProfile>
<Dimension actionCode="4 ">
                                <ProductID>10000091</ProductID>
                                <ReceiverProductID>800GB</ReceiverProductID>
                                <DimensionStatusCode>02</DimensionStatusCode>
                                <StartDate>2020-12-07</StartDate>
                                <EndDate>2023-12-19</EndDate>
                            </Dimension>
                            <Dimension actionCode="4 ">
                                <ProductID>10000085</ProductID>
                                <ReceiverProductID>50GB</ReceiverProductID>
                                <DimensionStatusCode>02</DimensionStatusCode>
                                <StartDate>2020-12-06</StartDate>
                                <EndDate>2023-12-25</EndDate>
                            </Dimension>
</ChannelPartnerMembershipProfile>


XSLT:

<xsl:for-each select="//Dimension">
                    <eep:EemblInternalProduct>
                      <xsl:value-of select="following-sibling::EndDate[1]"/>
                       <eep:EndDate> 
                     <xsl:value-of select="$EndDate"/>
                     </eep:EndDate>
                     <eep:Name>
                       <xsl:value-of select="$ReceiverProductID"/>
                       </eep:Name>
                       <eep:Part>
                           <xsl:value-of select="ProductID"/>
                      </eep:Part>
                       <eep:StartDate>
                         <xsl:value-of select="$StartDate"/>
                      </eep:StartDate>
                      </eep:EemblInternalProduct>
                     </xsl:for-each>  


My expected Output:

<eep:EemblInternalProduct>
                     <eep:EndDate>2023-12-19</eep:EndDate>
                     <eep:Name>800GB</eep:Name>
                     <eep:Part>10000091</eep:Part>
                     <eep:StartDate>2020-12-07</eep:StartDate>
                  </eep:EemblInternalProduct>
                  <eep:EemblInternalProduct>
                     <eep:EndDate>2023-12-25</eep:EndDate>
                     <eep:Name>50GB</eep:Name>
                     <eep:Part>10000085</eep:Part>
                     <eep:StartDate>2020-12-06</eep:StartDate>
                  </eep:EemblInternalProduct>


What I have tried:

<xsl:for-each select="//Dimension">
                    <eep:EemblInternalProduct>
                      <xsl:value-of select="following-sibling::EndDate[1]"/>
                       <eep:EndDate> 
                     <xsl:value-of select="$EndDate"/>
                     </eep:EndDate>
                     <eep:Name>
                       <xsl:value-of select="$ReceiverProductID"/>
                       </eep:Name>
                       <eep:Part>
                           <xsl:value-of select="ProductID"/>
                      </eep:Part>
                       <eep:StartDate>
                         <xsl:value-of select="$StartDate"/>
                      </eep:StartDate>
                      </eep:EemblInternalProduct>
                     </xsl:for-each> 
Posted
Updated 28-Dec-20 22:52pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900