homepage Welcome to WebmasterWorld Guest from 54.227.141.230
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Visit PubCon.com
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
maartenN




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

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




msg:3990920
 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.

httpwebwitch




msg:3990923
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved