Welcome to WebmasterWorld Guest from 50.19.135.67

Forum Moderators: httpwebwitch

Message Too Old, No Replies

xml/xsl: change url for unknown ip-addres within xsl

xml xsl change content

     

maartenN

8:31 am on Aug 31, 2009 (gmt 0)

5+ Year Member



Hi,

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>

httpwebwitch

1:17 pm on Sep 17, 2009 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, maartenN!

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.

httpwebwitch

1:28 pm on Sep 17, 2009 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



if the XML included the user's IP address, then you could do it with an <xsl:if> condition
 

Featured Threads

Hot Threads This Week

Hot Threads This Month