[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] How to execute an expression XPATH in String
Hi all the experts,
I'm a beginner in XSLT and i'm meet some problem so difficult. I have an webpage XHTML and I want to extract all the value at address XPATH as: /html/body/table/tr[1]/td[2]/p /html/body/table/tr[1]/td[3]/p /html/body/table/tr[1]/td[4]/p ...... and so on as well as /html/body/table/tr[2]/td[2]/p /html/body/table/tr[3]/td[2]/p ...... so i write a template with 3 parameter: $path: for an expression XPATH $tag: for the tag at which the index change repeatly as: TR, TD, p, a, Table,.. $index: for the index to change. and call the template recursively. <xsl:template name="GetAllValue"> <xsl:param name="path" /> <xsl:param name="tag" /> <xsl:param name="index" /> <xsl:variable name= "tagindex" select "concat($tag,'[',$index,']')" /> <xsl:variable name="titi" select= "xalan:evaluate(concat(substring-before($path,$tagindex),$tagindex,substring-after($path,$tagindex)))"/> <xsl:choose> <xsl:when test="string-length($titi) = 0" /> <xsl:otherwise> <Value> <xsl:value-of select="$titi" disable-output-escaping="yes"/> </Value> <xsl:call-template name= "GetAllValue"> <xsl:with-param name="path" select="$path"/> <xsl:with-param name="path" select="$tag"/> <xsl:with-param name="index" select="$index+1"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template>oose> </xsl:template> and i call template <xsl:template match="/"> <HTML> <BODY> <xsl:call-template name= "GetAllValue"> <xsl:with-param name="path" select="'/html/body/table/tr/td[1]/font/a'" /> <xsl:with-param name="tag" select=" 'td' " /> <xsl:with-param name="index" select="1"/> </xsl:call-template> </BODY> </HTML> </xsl:template>sl:template> because i have to using concat function to calcule new address after each template call, so i have use value XPATH as String and use xalan:evaluate but when i run this XSL i meet always error: Call to extension function failed: http://xml.apache.org/xalan How to solve this problem, can we avoid to use String? Please help me if you have any idea. Best wish. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|