I am using WSO2 BPS 3.2.0 and I want to assign namespace-uri of element to string. Problem is that I don't know element name at design time.
I have XML data
<message>
<Header xmlns="http://schemas.org/Message"/>
<Body xmlns="http://schemas.org/Message">
<Container xmlns="http://schemas.org/Container/1.0">
<Object>
<document xmlns="http://schemas.org/doc/1.1">dfjgf...ash</document>
</Object>
<Object>
<picture xmlns="http://schemas.org/pic/jpeg/2.0">we54uiytas...h</document >
</Object>
</Container>
</Body>
</message>
I try to use XSLT transformation to get namespace
bpel:doXslTransform("getNamespace.xsl", $Var.message/tns1:Body/tns2:Container/tns2:Object[1])
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml"/>
<xsl:template match="child::node[position()=1]">
<xsl:value-of select="namespace-uri(.)"/>
</xsl:template>
it returns nothing.
If I use output method text it returns all texts contained in xml data.
Where I do mistake?
The following stylesheet:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:value-of select="namespace-uri(*/*[1])"/>
</xsl:template>
</xsl:stylesheet>
will return the namespace of the first child of the root element.
In your example, the root element is message
and its first child is Header
- so the result here will be:
http://schemas.org/Message