homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

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

 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="." />
Full text
<xsl:if test="position()!=last()"> </xsl:if>



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

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.


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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved