Jump to content

Extracting substring


smandape
 Share

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>

Try

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...