smandape Posted January 3, 2011 Share Posted January 3, 2011 I have the following XML code<gene><name type="primary">SLC2A3</name><name type="synonym">GLUT3</name></gene>i m trying to get the values as<field name="gene_name">SLC2A3</field><field name="gene_aliases">GLUT3</field>If i try using for-each loop i would get the output for the same field name and without for-each loop i get only the first value (gene_name = SLC2A3), how do I get the different values using the attribute name??Another query is with the XML code as follows:<dbReference type="GeneID" id="6515" key="45" /><dbReference type="KEGG" id="hsa:6515" key="46" /><dbReference type="UCSC" id="uc001qtr.1" key="47">I have to output the data such that I want only the id: 6515...how can i do this??Kindly help me..any help is appreciated..Thank you.. Link to comment Share on other sites More sharing options...
Martin Honnen Posted January 3, 2011 Share Posted January 3, 2011 <xsl:template match="gene/name[@type = 'primary']"> <field type="gene_name"><xsl:value-of select="."/></field></xsl:template><xsl:template match="gene/name[@type = 'synonym']"> <field type="gene_aliases"><xsl:value-of select="."/></field></xsl:template> should suffice (as long as you processing of those templates is reached with apply-templates; the default templates do that). Link to comment Share on other sites More sharing options...
smandape Posted January 3, 2011 Author Share Posted January 3, 2011 @ Martin. Thank you for your reply...I really appreciate your help..could you,also, please help me with my second querythe XML code is as follows:<dbReference type="PRIDE" id="O15403" key="28" /><dbReference type="GeneID" id="6515" key="45" /><dbReference type="KEGG" id="hsa:6515" key="46" /><dbReference type="UCSC" id="uc001qtr.1" key="47">I have to output the data such that I want only the id: 6515...how can i do this??Thank you Link to comment Share on other sites More sharing options...
smandape Posted January 3, 2011 Author Share Posted January 3, 2011 Hello seniors..i got the answer..the code would be..<xsl:value-of select="dbReference[@type=GeneID]/@id"/>I tried it from the code mentioned by Martin..Thank you once again Martin...Thank you for reading Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.