Retrieving the namespaces of an XML document

0 views
Skip to first unread message

Brilt

unread,
Dec 10, 2009, 6:21:34 AM12/10/09
to XSLT
Hi,

I am using an XSL style sheet to process a WSDL XML file, but need to
access the name spaces of the document in the definitions element to
insert into the output. If I iterate the attributes of the element,
the name space attributes are missing. Can XSL access this
information?

For example, this XSL
<xsl:for-each select="/wsdl:definitions/@*">
<xsl:value-of select="name(.)" /><xsl:text> = </
xsl:text><xsl:value-of select="." /><xsl:text>&#10;</xsl:text>
</xsl:for-each>
<xsl:text>&#10;</xsl:text>

produces only:
name = test
targetNamespace = https://localhost:5006/

My WSDL document definitions element looks like:
<definitions name="test"
targetNamespace="https://localhost:5006/"
xmlns:tns="https://localhost:5006/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="https://localhost:5006/"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">

I need to be able to produce a list of the prefixes and url's used in
the XML file.

Regards,
Simon

Christian

unread,
Jan 15, 2010, 2:51:43 AM1/15/10
to XSLT
I don't know if it makes any sense in your case, but maybe you could
use the function namespace-uri(). It returns the namespace of the
current element.

XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:t="http://testuri">
<xsl:template match="t:root">
<xsl:value-of select="namespace-uri()"/>
</xsl:template>
</xsl:stylesheet>

XML:
<t:root xmlns:t="http://testuri" title="Testelement"></t:root>

Returns:
<?xml version="1.0" encoding="UTF-8"?>
http://testuri

Christian

On 10 Dec. 2009, 12:21, Brilt <simonjpaul...@gmail.com> wrote:
> Hi,
>
> I am using an XSL style sheet to process a WSDL XML file, but need to
> access the name spaces of the document in the definitions element to
> insert into the output. If I iterate the attributes of the element,
> the name space attributes are missing. Can XSL access this
> information?
>
> For example, this XSL
> <xsl:for-each select="/wsdl:definitions/@*">
>     <xsl:value-of select="name(.)" /><xsl:text> = </
> xsl:text><xsl:value-of select="." /><xsl:text>&#10;</xsl:text>
> </xsl:for-each>
> <xsl:text>&#10;</xsl:text>
>
> produces only:
> name = test

> targetNamespace =https://localhost:5006/

Reply all
Reply to author
Forward
0 new messages