Using xpath / xslt to get the anchor portion of the page url
I am writing a template in xslt with xpath 1.0 and need to access the anchor tag from the url of the current page. For example url:
http: //localhost/destinations/london.aspx#accommodation
I need to get #accommodation and assign it to a variable. I realize that I am a bit limited using xpath 1.0 - does anyone have any experience?
Thanks Adam
a source to share
Why is this an xpath problem? The url is not an XML document, ergo xpath is not applied.
XSLT is completely unaware of state such as page layout. Guessing what you are trying to do, you are probably best off getting #accomodation from inline manipulation or frameworks in the layer that calls XSLT by passing a value as a parameter.
OTOH maybe this is pointless and your question just needs clarification.
a source to share
As @Annakata said this is not an XPath issue. This is not an XSLT problem either, although I could be wrong. If it has to do with parsing an XSLT string, then you need something like this question .
Instead, you will most likely need Javascript to get the current url ( document.location
) and then parse the Javascript string on it.
a source to share
There is no way in standard XSLT to access the document url: http://www.dpawson.co.uk/xsl/sect2/nono.html#d1974e804
Some vendors may provide this information through custom properties, but then you will depend on the XSLT processor.
If you've managed to get the URL in XSLT somehow, I suggest you resort to simple string manipulation to get the anchor.
a source to share