i wish change the xml into desire format. For that i am using xslt and my request xml is like this
REQUEST
<?xml version="1.0" encoding="UTF-8" ?>
<usersCollection xmlns="http://ws.wso2.org/dataservice">
<users>
<username>1</username>
<password>2</password>
</users>
<users>
<username>faisal</username>
<password>sps123</password>
</users>
<users>
<username>youtility</username>
<password>sps123</password>
</users>
<users>
<username>yout</username>
<password>sp3</password>
</users>
</usersCollection>
and my desire format is look like this
RESPONSE
<ns:getResponse xmlns:ns="http://ws.wso2.org/dataservice">
<ns:user>
<ns:myname>1</ns:myname>
<ns:pwd>2</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>faisal</ns:myname>
<ns:pwd>sps123</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>youtility</ns:myname>
<ns:pwd>sps123</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>yout</ns:myname>
<ns:pwd>sp3</ns:pwd>
</ns:user>
</ns:getResponse>
and i write xslt for this like below
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:ns="http://ws.wso2.org/dataservice"
exclude-result-prefixes="ns fn">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//ns:usersCollection"/>
</xsl:template>
<xsl:template match="//ns:usersCollection">
<ns:getResponse xmlns:ns="http://ws.wso2.org/dataservice">
<xsl:for-each select="//ns:usersCollection/ns:users">
<ns:user>
<ns:myname>
<xsl:value-of select="//ns:usersCollection/ns:users/ns:username/."/>
</ns:myname>
<ns:pwd>
<xsl:value-of select="//ns:usersCollection/ns:users/ns:password/."/>
</ns:pwd>
</ns:user>
</xsl:for-each>
</ns:getResponse>
</xsl:template>
</xsl:stylesheet>
but its not giving my desired format out put i think i am mistaking in selecting xpath elements how would i add single elements for this i am getting like this result
<ns:getResponse xmlns:ns="http://ws.wso2.org/dataservice">
<ns:user>
<ns:myname>1 faisal youtility yout</ns:myname>
<ns:pwd>2 sps123 sps123 sp3</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>1 faisal youtility yout</ns:myname>
<ns:pwd>2 sps123 sps123 sp3</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>1 faisal youtility yout</ns:myname>
<ns:pwd>2 sps123 sps123 sp3</ns:pwd>
</ns:user>
<ns:user>
<ns:myname>1 faisal youtility yout</ns:myname>
<ns:pwd>2 sps123 sps123 sp3</ns:pwd>
</ns:user>
</ns:getResponse>
thanks in advance how would i get as per my desire format