Jump to content

Transform values from 2 different parent elements into one element


smandape

Recommended Posts

Hello seniors,The following is the XML code..I am trying to extract data, can I extract it in such a way that I get the name and full name together as output under one elementlike:(XSLT output) <field name="name">GTR3_HUMAN; Solute carrier family 2, facilitated glucose transporter member 3 </field>if it would had been under the same element then I could have used 'xsl:if'..but as the values are under two different elements, i can't use it right??..Could you please help me..Thank you for your help..<entry><name>GTR3_HUMAN</name><protein><recommendedName><fullName>Solute carrier family 2, facilitated glucose transporter member 3</fullName></recommendedName></entry>

Link to comment
Share on other sites

With XSLT 2.0:

<xsl:template match="entry">   <field name="name"><xsl:value-of select="name, protein/recommendedName/fullName" separator="; "/></field></xsl:template>

with XSLT 1.0

<xsl:template match="entry">   <field name="name">	  <xsl:value-of select="name"/>	  <xsl:text>; </xsl:text>	  <xsl:value-of select="protein/recommendedName/fullName"/>   </field></xsl:template>

Link to comment
Share on other sites

The XSLT 1.0 part can be reduced to

<xsl:template match="entry">	<field name="name"><xsl:value-of select="name"/>; <xsl:value-of select="protein/recommendedName/fullName"/></field></xsl:template>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...