While converting xml to xslt values are not mapping -
hi new xslt transformation trying convert following xml using xslt not getting value of title in result xml.
input xml: <exam:orderreq> <exam:item> <exam:title>r</exam:title> </exam:item> </exam:orderreq> xslt: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:exam="http://www.jboss.org/bpel/examples" xmlns:prod="http://www.jboss.org/bpel/examples/product"> <xsl:template match="/"> <prod:productorderreq> <prod:product xmlns:prod="http://www.jboss.org/bpel/examples/product"> <xsl:for-each select="exam:orderreq"> <prod:name><xsl:value-of select="exam:title"/></prod:name> </xsl:for-each> </prod:product> </prod:productorderreq> </xsl:template> </xsl:stylesheet>
i got below result iin not able value element
<?xml version="1.0" encoding="utf-8"?> <prod:productorderreq xmlns:prod="http://www.jboss.org/bpel/examples/product" xmlns:exam="http://www.jboss.org/bpel/examples"> <prod:product> <prod:name /> </prod:product> </prod:productorderreq>
i got solution while writing xslt missed each tag item shown below. previous xslt: xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:exam="http://www.jboss.org/bpel/examples" xmlns:prod="http://www.jboss.org/bpel/examples/product"> <xsl:template match="/"> <prod:productorderreq> <prod:product xmlns:prod="http://www.jboss.org/bpel/examples/product"> <xsl:for-each select="exam:orderreq"> <prod:name><xsl:value-of select="exam:title"/></prod:name> </xsl:for-each> </prod:product> </prod:productorderreq> </xsl:template> </xsl:stylesheet> modified xslt: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:exam="http://www.jboss.org/bpel/examples" xmlns:prod="http://www.jboss.org/bpel/examples/product"> <xsl:template match="/"> <prod:productorderreq> <xsl:for-each select="exam:orderreq" xmlns:exam="http://www.jboss.org/bpel/examples"> <prod:product> <xsl:for-each select="exam:item"> <prod:name><xsl:value-of select="exam:title"/></prod:name> </xsl:for-each> </prod:product> </xsl:for-each> </prod:productorderreq> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment