Msg#: 3981086 posted 8:31 am on Aug 31, 2009 (gmt 0)
I have the following issue: a database gives a certain xml document which is styled and then showed using a xsl file. we can only change the xsl file, so adjustments have to be made here. the xml file contains a value named <ext_doc> which contains an url. we want to check if the ip of the requesting computer is from or internal network (192.168.x.x) or from someone external. when the requester is coming from our internal network, the url just has to be shown, but when it's an other visitor; the url has to be changed to [ourProxy.com...]
how can I make this such that the xsl file can read the visitors ip-address and when needed change the url?
thanks in advance for your help
the template for the url in the xsl file now looks like this:
<xsl:template match="ext_doc"> <a target="_blank"> <xsl:attribute name="href"> <xsl:value-of select="." /> </xsl:attribute> Full text </a> <xsl:if test="position()!=last()"> ¦ </xsl:if> </xsl:template>
XSLT won't be able to do this on its own. you'll need a platform that can perform more complex tasks.
for instance, in PHP there is gethostbyname [ca.php.net]($ip) which will tell you the IP associated with a URL's host name, and $_SERVER['REMOTE_ADDR'] which tells you the user's IP.
If all you can do is edit an XSLT file, then your hands are tied... perhaps you should be sending all your outbound links through the proxy, and let the proxy script decide which ones to proxify, and which ones to redirect directly to the passed-in URL.