getting namespace uri by giving prefix in xslt -
i using xsl 1.0. need namespace uri prefix.
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a1="http://example.com/arthemetic/integers/a1"> <soapenv:header> </soapenv:header> <soapenv:body> <a1:add> </a1:add> </soapenv:body> </soapenv:envelope>
i want namespace uri prefix a1 http://example.com/arthemetic/integers/v1
here code trying out,
<xsl:template match="/"> <xsl:variable name="operationname"> <xsl:value-of select="name(/*[local-name()='envelope']/*[local-name()='body']/*[1])"></xsl:value-of> </xsl:variable> <xsl:variable name="prefix"> <xsl:value-of select="substring-before($operationname, ':')"></xsl:value-of> </xsl:variable> <xsl:variable name="ns-node" select="namespace::node()[.= $prefix]" /> dfadsfdfadsf <xsl:value-of select="$ns-node" /> </xsl:template> </xsl:stylesheet>
but not receiving namespace.
use:
<xsl:value-of select="/*/namespace::a1"/>
here complete transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:value-of select="/*/namespace::a1"/> </xsl:template> </xsl:stylesheet>
when transformation applied on provided xml document:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a1="http://abc.com/arthemetic/integers/a1"> <soapenv:header></soapenv:header> <soapenv:body> <a1:add></a1:add> </soapenv:body> </soapenv:envelope>
the wanted, correct result produced:
http://abc.com/arthemetic/integers/a1
Comments
Post a Comment