[Building Sakai] How to make Dynamic Url for xslt
Juan José Meroño Sánchez
jjmerono at um.es
Mon Feb 7 00:05:18 PST 2011
Try this
<xsl:variable name="userurl">
<xsl:choose>
<xsl:when test="currentUser/first!= ''">
<xsl:value-of select="currentUser/first"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="currentUser/userid"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="url">
<xsl:value-of select="concat('http://localhost:8080/xsl-portal/site/~',$userurl,'/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c')"/>
</xsl:variable>
<xsl:text>|</xsl:text> *<xsl:value-of select="normalize-space($url)" disable-output-escaping="yes"/>* <xsl:text>Search</xsl:text>
The use of {$variable} is only valid inside destination xml attributes,
for example, something like this,
<a href="{$url}">xxx</a> instead of <a><xsl:attribute
name="href"><xsl:value-of select="$url"/></xsl:attribute>xxx</a>
To avoid the /normalize-space/ function, compact xsl nodes like this,
<xsl:variable name="userurl">
<xsl:choose>
<xsl:when test="currentUser/first!= ''"><xsl:value-of select="currentUser/first"/></xsl:when>
<xsl:otherwise><xsl:value-of select="currentUser/userid"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="url"><xsl:value-of select="concat('http://localhost:8080/xsl-portal/site/~',$userurl,'/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c')"/></xsl:variable>
<xsl:text>|</xsl:text> <xsl:value-of select="/normalize/-space($url)" disable-output-escaping="yes"/> <xsl:text>Search</xsl:text>
You should obtain something like this,
http://localhost:8080/xsl-portal/site/~heretheuserid/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c
Bye.
El 07/02/2011 8:38, Bhanu.T.Motupalli escribió:
> Hi,
>
> I need to concatenate 3 strings to make URL dynamically.
>
> XML, XSLT and XPATH Syntax (Toggle Plain Text)
>
> 1.
> <xsl:variable name="userurl">
> 2.
> <xsl:choose>
> 3.
> <xsl:when test="currentUser/first != ''">
> 4.
> <xsl:value-of select="currentUser/first"/>
> 5.
> </xsl:when>
> 6.
> <xsl:otherwise>
> 7.
> <xsl:value-of select="currentUser/userid"/>
> 8.
> </xsl:otherwise>
> 9.
> </xsl:choose>
> 10.
> </xsl:variable>
> 11.
>
> 12.
> <xsl:variable name="url">
> 13.
> <xsl:value-of
> select="concat('http://localhost:8080/xsl-portal/site/~',$userurl,'/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c')"/>
> 14.
> </xsl:variable>
> 15.
> <xsl:text>|</xsl:text>
> 16.
> {$url}
> 17.
> <xsl:text>Search</xsl:text>
> 18.
>
>
> <xsl:variable name="userurl"> <xsl:choose> <xsl:when test="currentUser/first
> != ''"> <xsl:value-of select="currentUser/first"/> </xsl:when>
> <xsl:otherwise> <xsl:value-of select="currentUser/userid"/> </xsl:otherwise>
> </xsl:choose> </xsl:variable> <xsl:variable name="url"> <xsl:value-of
> select="concat('http://localhost:8080/xsl-portal/site/~',$userurl,'/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c')"/>
> </xsl:variable> <xsl:text>|</xsl:text> {$url}<xsl:text>Search</xsl:text>
>
> Here i am not able to get the link, The link is coming like
> http://localhost:8080/%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%09concat%28%27http://localhost:8080/xsl-portal/site/~%27,$userurl,%27/page/487d2e0a-ca50-440b-a8c2-e98a2cee632c%27%29%0A
>
> Can any one help me to Solve this. I am new to XSLT so please help...
>
> Regards
> Bhanu.
--
**************************************
Juan José Meroño Sánchez
Area de Tecnologías de la Información
y las Comunicaciones Aplicadas (ATICA)
http://www.um.es/atica
Universidad de Murcia
**************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20110207/83771d89/attachment.html
More information about the sakai-dev
mailing list