Reputation: 851
I am trying to get the current URL of the page that I am on in XSLT. I need to use that URL and append something to the end of the URL and use that as an href of an anchor tag.
I'm able to get it in JavaScript but not able to assign it to xsl:variable. I tried setting to transformer using set Parameter function but in that case i have to set everywhere since the home page will be called every time.
Any help would be great.
Upvotes: 1
Views: 968
Reputation: 1250
Pure XSLT doesn't know anything about the environment it is running in (for complete independence, I guess). Because this is inconvenient, some host environments have implemented ways to get data into the transformation. Generate parameters is one way you mentioned. Sorry I don't know java, but e.g. PHP allows to call PHP functions from XSLT (see Can PHP communicate with XSLT?). Maybe something similar is possible with java too.
Javascript can't communicate into the transformation as long as it is running from the generated source, because it gets started after the transformation job is completely done. It might be possible when Javascript acts as the transformation host, which is javascript triggers the transformation.
P.S. That downvote is not from me
Upvotes: 2