I am trying to extract the value of the messageIdentifier in the following XML request:
<?xml version="1.0"?> <ordersRequest> <requestHeader> <verb>get</verb> <transaction>OrderRequest</transaction> <version>1.0</version> <consumer>Web</consumer> <messageIdentifier>123456789</messageIdentifier> </requestHeader> </ordersRequest> The intention is to pass the XPath information to the stylesheet so that the same XSL can be used for any other request (paymentRequest/requestHeader/messageIdentifier) and for any other node under requestHeader (paymentRequest/requestHeader/consumer). I came up with the following XSL for it:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes" /> <xsl:param name="xpath" select="/" /> <xsl:template match="/"> <xsl:value-of select="concat('/*/requestHeader/',$xpath)" /> </xsl:template> </xsl:stylesheet> The output here comes out as /*/requestHeader/messageIdentifier. When I apply the above stylesheet with the the following edit <xsl:value-of select="/*/messageHeader/messageIdentifier" /> , I get the value 123456789 in the output. Why is there a difference in the output. Please help.