Jump to content

Extracting substring


Recommended Posts

Hello Seniors,well, here is something I am trying to do with the XML code below:I need your help

<Gene-commentary_type value="comment">254</Gene-commentary_type>            <Gene-commentary_heading>Pathways</Gene-commentary_heading>            <Gene-commentary_comment>                <Gene-commentary>                    <Gene-commentary_type value="comment">254</Gene-commentary_type>                    <Gene-commentary_text>KEGG pathway: Melanogenesis</Gene-commentary_text>

I want to extract the <Gene-commentary_text> after the ':',ie, i just want 'Melanogenesis'.I used the following XSLT code:

<field name="Pathways"><xsl:for-each select="Entrezgene_comments/Gene-commentary[string(Gene-commentary_heading)='Pathways']/Gene-commentary_comment/Gene-commentary">					<field name="Pathway_name"><xsl:value-of select="Gene-commentary_text[substring-after(text(),':')]"/> </field></xsl:for-each> </field>I also tried <field name="Pathway_name"><xsl:value-of select="Gene-commentary_text[substring-after(.,':')]"/>

Thank you for your help..Thank you,Sammed

Link to comment
Share on other sites

A predicate is a lot like an if - you're saying "get the whole thing if this thing is true".Instead, you want to get a part of a thing. So, instead of

<field name="Pathway_name"><xsl:value-of select="Gene-commentary_text[substring-after(text(),':')]"/> </field>


<field name="Pathway_name"><xsl:value-of select="substring-after(Gene-commentary_text,':')"/> </field>

Link to comment
Share on other sites


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

  • Create New...