Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Replacing a string segment inside a variable?

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 7/21/2009 5:39:00 PM
Chris Gannon wrote:
> I've got a variable that's being used as a hyperlink...
> <a href="{@ows_URL}&amp;Source={$PageUrl}">Click This</a>
> 
>  The link attribute {@ows_URL} has the value "http://mySiteUrl/
> DispForm.aspx?ID=6"
> 
> I'd like to change "/DispForm.aspx?" to /EditForm.aspx?"
> 
> My guess is that I have to convert @ows_URL to a string first, replace
> the piece I want, and use the a new variable as the link.
> 
> Can anyone show me how to do this?

XSLT 2.0:
   <a href="{replace(@ows_URL, '/DispForm', 
'/EditForm')}&amp;Source={$PageUrl}">Click This</a>
Note that replace takes a regular expression pattern as the second 
argument, I think I have choosen a string with '/DispForm' that does not 
contain any characters that need to be escaped but be careful if you 
want to change the above sample so that you escape anything that needs 
to be escaped.

With XSLT 1.0 there is no replace unless you implement it with a named 
template that you then need to call inside of an xsl:attribute. On the 
other hand for the string you have doing
   <a href="{concat(substring-before(@ows_URL, '/'), 
'/EditForm.aspx')}&amp;Source={$PageUrl}">Click This</a>
should suffice.

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent