xml - XSLT transformation with keyed Param -


i have piece of xslt file looks this:

<xsl:template match="request">     <instrument>         <identifiertype>                  <xsl:value-of select="idcontext"/>         </identifiertype>         <identifier>                  <xsl:value-of select="identifier"/>         </identifier>         <userdefinedidentifier>                  <xsl:value-of select="userdefinedidentifier"/>         </userdefinedidentifier>         <xsl:if test="param[@key='exchange']">                  <exchange>                            <xsl:value-of select="param[@key='exchange']"/>                  </exchange>         </xsl:if>     </instrument> </xsl:template> 

and 1 input xml piece this:

<request>     <identifier>xxx</identifier>     <idcontext>isin</idcontext> </request> 

now want modify input xml little bit, output this:

<instrument>     <identifiertype>isin</identifiertype>     <identifier>xxx</identifier>                                 <exchange>ex</exchange> </instrument> 

how should modify input xml file? thank you!

the xslt looking param element child of current request element being matched. means expect xml this:

<request>     <identifier>xxx</identifier>     <idcontext>isin</idcontext>     <param key='exchange'>ex</param> </request> 

having said that, generates following output:

<instrument>    <identifiertype>isin</identifiertype>    <identifier>xxx</identifier>    <userdefinedidentifier/>    <exchange>ex</exchange> </instrument> 

the template have shown creates userdefinedidentifier request element, regardless of whether userdefinedidentifier element exists in xml or not. way around change xslt handle 1 not being present.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -