I am trying to use a function that I have added to the XSLTHelper class. The function returns a location value dependant on the IP address. What I can't get to work is if I use the RequestServerVariables it returns the IP address without error. If I statically type the IP address into the XSLTHelper:GetLocation it returns the locality, however, if I put the variable name into the GetLocation I get 'IndexOutOfRangeException', here is the code:
Now I don't know this particular extension, but have you tried adding a test for non-empty ip address before the GetLocation, i.e. something like this (out of my head):
<xsl:variable name="locality" <xsl:choose"> <xsl:when test="$ipAddress != ''> <xsl:value-of select="RaymondGubbayLib.XSLTHelper:GetLocation($ipAddress)"/> </xsl:when> <xsl:otherwise> whatever is necessary here </xsl:otherwise> </xsl:choose>
Hmm, if you are sure it's the GetLocation call that fails it's probably because it cannot validate that $ipAddress is an non-empty string. You could try adding a string cast
Yeah, we have IPs' for Scotland, London, Sheffield and Coventry as it is an arbitrary GeoLocation service we're looking to provide. It seems like when the IP address is not localhost (127.0.0.1) it works fine.
Index outside of bounds of the array
Hi all,
I am trying to use a function that I have added to the XSLTHelper class. The function returns a location value dependant on the IP address. What I can't get to work is if I use the RequestServerVariables it returns the IP address without error. If I statically type the IP address into the XSLTHelper:GetLocation it returns the locality, however, if I put the variable name into the GetLocation I get 'IndexOutOfRangeException', here is the code:
Do you get the error when saving, or at runtime?
When saving.
Now I don't know this particular extension, but have you tried adding a test for non-empty ip address before the GetLocation, i.e. something like this (out of my head):
Nope, still doing it:
Hmm, if you are sure it's the GetLocation call that fails it's probably because it cannot validate that $ipAddress is an non-empty string. You could try adding a string cast
RaymondGubbayLib.XSLTHelper:GetLocation(string($ipAddress))
I think it's to do with the web being on my local machine, if I test to see that 'LOCAL_ADDR' is not 127.0.0.1 it works fine, strange.
Yep, works with this:
Thanks for your help guys.
Have you tried with testing for others ip's also - it sounds a bit weird
Yeah, we have IPs' for Scotland, London, Sheffield and Coventry as it is an arbitrary GeoLocation service we're looking to provide. It seems like when the IP address is not localhost (127.0.0.1) it works fine.
This is the final (working) XSL:
is working on a reply...