smandape Posted January 15, 2011 Share Posted January 15, 2011 Hello Seniors, I need your help... kindly help me on the code I am trying to work on...This is the XML code I am working on...<dbReference type="Pfam" id="PF00106" key="53"> <property type="entry name" value="adh_short" /> <property type="match status" value="1" /> </dbReference>- <dbReference type="PRINTS" id="PR00081" key="54"> <property type="entry name" value="GDHRDH" /> </dbReference><dbReference type="GO" id="GO:0005576" key="44"> <property type="term" value="C:extracellular region" /> <property type="evidence" value="IEA:UniProtKB-SubCell" /> </dbReference>- <dbReference type="GO" id="GO:0005488" key="45"> <property type="term" value="F:binding" /> <property type="evidence" value="IEA:InterPro" /><dbReference type="GO" id="GO:0055114" key="47"> <property type="term" value="P:oxidation reduction" /> <property type="evidence" value="IEA:UniProtKB-KW" /> </dbReference>I am trying to extract the attribute value based on the starting letter C:,F: or P: I tried the code by WYLBUR in one of the previous posts..I am not getting th values..could you please tell me how can i go for this...The XSLT code with different field names is as follows..<xsl:for-each select="dbReference[@type=GO]"> <field name="GO_1"> <xsl:value-of select="property[@type=term]/@value[starts-with(property/@value,'P:')]"/></field> <field name="GO_2"> <xsl:value-of select="property[@type=term]/@value[starts-with(property/@value,'F:')]"/></field> <field name="GO_3"> <xsl:value-of select="property[@type=term]/@value[starts-with(property/@value,'C:')]"/></field> </xsl:for-each>Any help is appreciated..Thank you for your help...Sammed Link to comment Share on other sites More sharing options...
boen_robot Posted January 15, 2011 Share Posted January 15, 2011 Expressions in predicates are relative to the current point in the XPath expression, not the starting point of the XPath expression. If you want the starting point of the XPath expression, you need to use XSLT's current() function instead. In this case though, you can just use "." to target the current attribute itself, like: <xsl:for-each select="dbReference[@type='GO']"> <field name="GO_1"> <xsl:value-of select="property[@type='term']/@value[starts-with(.,'P:')]"/></field> <field name="GO_2"> <xsl:value-of select="property[@type='term']/@value[starts-with(.,'F:')]"/></field> <field name="GO_3"> <xsl:value-of select="property[@type='term']/@value[starts-with(.,'C:')]"/></field> </xsl:for-each> Link to comment Share on other sites More sharing options...
smandape Posted January 15, 2011 Author Share Posted January 15, 2011 Thank you for your help... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.