|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Pass variables through URL
Jen Jiang wrote:
Here's the xslt file that has the url:Hi Jen, xsl:output method should be either "text", "xml" or "html". Saxon refuses method="text/html", but with method="html" (and without the imports) produces the desired result. I think Werner is right, maybe you're changing the context somewhere, and using "/ROOT" might fix it. But... <div align="center"> <xsl:for-each select="ROOT"> <xsl:variable name="age1"> <xsl:value-of select="AGE1"/> </xsl:variable> THIS IS AGE1:<xsl:value-of select="$age1"/> <xsl:variable name="age2"> <xsl:value-of select="AGE2"/> </xsl:variable> <xsl:variable name="age3"> <xsl:value-of select="AGE3"/> </xsl:variable> <xsl:variable name="age4"> <xsl:value-of select="AGE4"/> </xsl:variable> <xsl:variable name="age5"> <xsl:value-of select="AGE5"/> </xsl:variable> <xsl:variable name="age6"> <xsl:value-of select="AGE6"/> </xsl:variable> <xsl:variable name="age7"> <xsl:value-of select="AGE7"/> </xsl:variable> <xsl:variable name="age8"> <xsl:value-of select="AGE8"/> </xsl:variable> <xsl:element name='img'> <xsl:attribute name='src'> <xsl:text>./php/chart_age.php?age1=</xsl:text> <xsl:value-of select='$age1'/> <xsl:text>&age2=</xsl:text> <xsl:value-of select='$age2'/> <xsl:text>&age3=</xsl:text> <xsl:value-of select='$age3'/> <xsl:text>&age4=</xsl:text> <xsl:value-of select='$age4'/> <xsl:text>&age5=</xsl:text> <xsl:value-of select='$age5'/> <xsl:text>&age6=</xsl:text> <xsl:value-of select='$age6'/> <xsl:text>&age7=</xsl:text> <xsl:value-of select='$age7'/> <xsl:text>&age8=</xsl:text> <xsl:value-of select='$age8'/> </xsl:attribute> </xsl:element> </xsl:for-each> </div> Why would you make it so complicated? Why not pass the values directly, instead of first collecting them into 8 variables: <xsl:for-each select="/ROOT">
<img>
<xsl:attribute name='src'>
<xsl:text>./php/chart_age.php?age1=</xsl:text>
<xsl:value-of select='AGE1'/>
<xsl:text>&age2=</xsl:text>
<xsl:value-of select='AGE2'/>
<xsl:text>&age3=</xsl:text>
<xsl:value-of select='AGE3'/>
<xsl:text>&age4=</xsl:text>
<xsl:value-of select='AGE4'/>
<xsl:text>&age5=</xsl:text>
<xsl:value-of select='AGE5'/>
<xsl:text>&age6=</xsl:text>
<xsl:value-of select='AGE6'/>
<xsl:text>&age7=</xsl:text>
<xsl:value-of select='AGE7'/>
<xsl:text>&age8=</xsl:text>
<xsl:value-of select='AGE8'/>
</xsl:attribute>
</img>
</xsl:for-each>Or even iterate through the AGE elements to build up the url: <xsl:for-each select="/ROOT"> <img> <xsl:attribute name='src'> <xsl:text>./php/chart_age.php?</xsl:text> <xsl:for-each select="*"> <xsl:if test="position() > 1">&</xsl:if> <xsl:value-of select="translate(name(),$upper,$lower)"/> <xsl:text>=</xsl:text> <xsl:value-of select="."/> </xsl:for-each> </xsl:attribute> </img> </xsl:for-each> Here you'll need the upper and lower variables: <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> (mind the double quotes in the select attribute!) Best regards, Anton
|
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
|

Cart








