<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Harvesting web technologies &#187; XML</title>
	<atom:link href="http://www.webfarmr.eu/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webfarmr.eu</link>
	<description>SOA, Security, Cloud, XML, XSLT, XML Security Gateways, WS-*, XACML, web services</description>
	<lastBuildDate>Wed, 01 Feb 2012 11:21:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Replace an XML element value using XSLT</title>
		<link>http://www.webfarmr.eu/2008/10/replace-an-xml-element-value-using-xslt/</link>
		<comments>http://www.webfarmr.eu/2008/10/replace-an-xml-element-value-using-xslt/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 08:40:21 +0000</pubDate>
		<dc:creator>David Brossard</dc:creator>
				<category><![CDATA[Identity & Access Management]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[ws-addressing]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://www.webfarmr.eu/webfarmr/?p=3</guid>
		<description><![CDATA[The aim is to take a document, look for a specific element (by local name and URI rather than name including prefix) and replace its value.
Where is this useful? Imagine a gateway protecting an internal web service. If that web service is WS-A enabled, it therefores has a wsa:From field which  [...]]]></description>
			<content:encoded><![CDATA[<p>The aim is to take a document, look for a specific element (by local name and URI rather than name including prefix) and replace its value.</p>
<p>Where is this useful? Imagine a gateway protecting an internal web service. If that web service is WS-A enabled, it therefores has a wsa:From field which contains its internal URI. Obviously the gateway abstracts the internal service from what is seen outside as a &#8216;virtual&#8217; or &#8216;logical&#8217; service. One therefore needs to update the wsa:From field to reflect an external URI.</p>
<p>Sample XML:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;soap12:Envelope xmlns:soap12=&#8221;http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsd=&#8221;http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:wsa05=&#8221;http://www.w3.org/2005/08/addressing&#8221; xmlns:uddi=&#8221;urn:uddi-org:api_v2&#8243; xmlns:ns1=&#8221;http://ws.samples.engage.bt.com&#8221; xsi:schemaLocation=&#8221;http://schemas.xmlsoap.org/soap/envelope/ http://schemas.xmlsoap.org/soap/envelope/&#8221;&gt;<br />
&lt;soap12:Header&gt;<br />
&lt;wsa05:To&gt;http://somelocation&lt;/wsa05:To&gt;<br />
&lt;wsa05:Action&gt;urn:greet&lt;/wsa05:Action&gt;<br />
&lt;wsa05:From&gt;<br />
&lt;wsa05:Address&gt;http://internaluri.intra.mycompany.com&lt;/wsa05:Address&gt;<br />
&lt;/wsa05:From&gt;<br />
&lt;/soap12:Header&gt;<br />
&lt;soap12:Body&gt;<br />
&lt;ns1:greet soap12:encodingStyle=&#8221;http://schemas.xmlsoap.org/soap/encoding/&#8221;&gt;<br />
&lt;in0 xsi:type=&#8221;xsd:string&#8221;&gt;Philip&lt;/in0&gt;<br />
&lt;/ns1:greet&gt;<br />
&lt;/soap12:Body&gt;<br />
&lt;/soap12:Envelope&gt;</p>
<p>The XSL to be applied here is</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;xsl:stylesheet version=&#8221;2.0&#8243; xmlns:xsl=&#8221;http://www.w3.org/1999/XSL/Transform&#8221; xmlns:xs=&#8221;http://www.w3.org/2001/XMLSchema&#8221; xmlns:fn=&#8221;http://www.w3.org/2005/xpath-functions&#8221; xmlns:soapenv=&#8221;http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:wsa=&#8221;http://www.w3.org/2005/08/addressing&#8221;&gt;<br />
&lt;xsl:output method=&#8221;xml&#8221; version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243; indent=&#8221;yes&#8221;/&gt;<br />
&lt;xsl:variable name=&#8221;fromVirtualUri&#8221;&gt;http://virtualFromValue&lt;/xsl:variable&gt;<br />
&lt;xsl:template match=&#8221;node()|@*&#8221;&gt;<br />
&lt;xsl:copy&gt;<br />
&lt;xsl:choose&gt;<br />
&lt;xsl:when test=&#8221;local-name()=&#8217;Address&#8217;&#8221;&gt;<br />
&lt;xsl:if test=&#8221;namespace-uri()=&#8217;http://www.w3.org/2005/08/addressing&#8217;&#8221;&gt;<br />
&lt;xsl:value-of disable-output-escaping=&#8221;yes&#8221; select=&#8221;$fromVirtualUri&#8221;&gt;&lt;/xsl:value-of&gt;<br />
&lt;/xsl:if&gt;<br />
&lt;/xsl:when&gt;<br />
&lt;xsl:otherwise&gt;<br />
&lt;xsl:apply-templates select=&#8221;@*|*|processing-instruction()|comment()|text()&#8221;&gt;<br />
&lt;xsl:with-param name=&#8221;virtualUri&#8221;&gt;&lt;/xsl:with-param&gt;<br />
&lt;/xsl:apply-templates&gt;<br />
&lt;/xsl:otherwise&gt;<br />
&lt;/xsl:choose&gt;<br />
&lt;/xsl:copy&gt;<br />
&lt;/xsl:template&gt;<br />
&lt;/xsl:stylesheet&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webfarmr.eu/2008/10/replace-an-xml-element-value-using-xslt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

