Subject: Re: [xsl] Putting parameter into XPATH expression From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 22 Jun 2001 16:06:19 +0100 |
Hi,
In the code extract below, I always get the result "OneOneOne" instead of "OneTwoThree" which I am expecting.
I found a work around (based on my previous experience writing compilers) that gets XSL processor to do what I want: "<xsl:value-of select="a/b[$Position + 0 ]/c"/>"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> <xsl:for-each select="//c"> <xsl:apply-templates/> </xsl:for-each> </xsl:template>
Regards, Wendell
Can someone tell me a better (more correct) way to do this?
XML ------------------ <?xml version="1.0" encoding="ISO-8859-1"?> <a> <b> <c>One</c> </b> <b> <c>Two</c> </b> <b> <c>Three</c> </b> </a>
In my XSL, I do the following to write out the words One, Two and Three ---------------
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/"> <xsl:call-template name="Jump"> <xsl:with-param name="Position" select="'1'"/> </xsl:call-template>
<xsl:call-template name="Jump"> <xsl:with-param name="Position" select="'2'"/> </xsl:call-template>
<xsl:call-template name="Jump"> <xsl:with-param name="Position" select="'3'"/> </xsl:call-template> </xsl:template>
<xsl:template name="Jump"> <xsl:param name="Position"/>
<xsl:value-of select="a/b[$Position ]/c"/>
</xsl:template>
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Putting parameter into XPATH , MacEwan, James (Info | Thread | RE: [xsl] Putting parameter into XP, Evan Lenz |
Re: [xsl] Summing a Calculation, Thomas B. Passin | Date | RE: [xsl] Difference between "/" an, Rene de Vries |
Month |