XML:
<Report xmlns="https://defaultnamespace/abc">
<Conversion>
<Type>FirstElement</Type>
</Conversion>
<Conversion>
<Type>SecondElement</Type>
</Conversion>
<Conversion>
<Type>ThirdElement</Type>
</Conversion>
</Report>
wso2 code:
<inSequence>
<iterate xmlns:cs="https://defaultnamespace/abc" continueparent="true" expression="//cs:Report/cs:Conversion" attachPath="//cs:Report">
<target>
<sequence>
<xslt ket="SampleXSLT.xslt"/>
</sequence>
</target>
</iterate>
</inSequence>
The issue is the above iterate mediator works only if the input XML as above works only if it contains namespace "https://defaultnamespace/abc".
Requirement:
The iterate mediator does not work if the above XML has different namespace. So, I need alternative solutions so that the iterate mediator takes namespace that comes from XML dynamically and the transformation happens. Help me with the best solution with minor modification in the code.
New Requirement:
I have a similar requirement in XSLT also.
XML:
<Report xmlns="https://defaultnamespace/abc">
<Conversion>
<Type>FirstElement</Type>
</Conversion>
<Conversion>
<Type>SecondElement</Type>
</Conversion>
<Conversion>
<Type>ThirdElement</Type>
</Conversion>
<Last>This is last element</Last>
</Report>
XSLT:
<?xml version=1.0 encoding=UTF-8?>
<xsl:stylesheet xmlns:cs="https://defaultnamespace/abc">
<xsl:template match="/">
<xsl:for-each select="/cs:Report/cs:Conversion/cs:Type">
<xsl:element name="Converting"><xsl:value-of select="."/></xsl:element>
</xsl:for-each>
<xsl:element name="LastOne"><xsl:value-of select="/cs:Report/cs:Last"/> </xsl:element>
</xsl:template>
</xsl:stylesheet>
The above XSLT fails when the input XML has a different namespace. So, I need an XSLT that will dynamically get the namespace from input XML and does the transformation.