Dinesh Bali
asked on
Adding condition in href string in XSLT
Hi,
I need help in XSLT.
In my XSLT, I have many links in href previously.
For sme reason I need to move entire web app to virtual folder.
Now, I have to place another variable before all href link with
{$virtualFolderPath}
so, previously, link was
{//web/menu[@title='Contac t Us']/@url}
Now after modifying link become as below
{$virtualFolderPath}{//web /menu[@tit le='Contac t Us']/@url}
Sample XSLT code below:
<xsl:if test="//web/menu[@title = 'Contact Us']">
<a href="{$virtualFolderPath} {//web/men u[@title=' Contact Us']/@url}" class="dropdown-toggle main-links">Contact Us</a>
</xsl:if>
Problem Statement:
If link is full link like:
http://www.somewebapp.com/somepage
then href link become
/b2chttp://www.somewebapp.com/somepage
as path in
{$virtualFolderPath} is /b2c
How should I fix so that if URL starts from
http://
then do not add my path:
{$virtualFolderPath}
and URL should be direct
Please guide.
I need help in XSLT.
In my XSLT, I have many links in href previously.
For sme reason I need to move entire web app to virtual folder.
Now, I have to place another variable before all href link with
{$virtualFolderPath}
so, previously, link was
{//web/menu[@title='Contac
Now after modifying link become as below
{$virtualFolderPath}{//web
Sample XSLT code below:
<xsl:if test="//web/menu[@title = 'Contact Us']">
<a href="{$virtualFolderPath}
</xsl:if>
Problem Statement:
If link is full link like:
http://www.somewebapp.com/somepage
then href link become
/b2chttp://www.somewebapp.com/somepage
as path in
{$virtualFolderPath} is /b2c
How should I fix so that if URL starts from
http://
then do not add my path:
{$virtualFolderPath}
and URL should be direct
Please guide.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That is a lot more robust
ASKER
Many Many Thanks for your help.
welcome
create the attribute with an xsl:attribute and have the conditional inside
Note that I made a choose, so you can have more conditions such as https:// etc...
Open in new window