xslt - Mule - Transform XML to SOAP message -


i receive json message mule flow this:

{   "book": {     "author": "gambardella, matthew",     "title": "xml developer's guide",     "genre": "computer",     "price": "44.95",     "publish_date": "2000-10-01",     "description": "an in-depth xml"   } } 

and use json xml transformer mule , returns:

   <book >       <author>gambardella, matthew</author>       <title>xml developer's guide</title>       <genre>computer</genre>       <price>44.95</price>       <publish_date>2000-10-01</publish_date>       <description>an in-depth xml</description>    </book> 

this actual mule flow:

http --> json xml --> logger --> ws consumer

i want transform xml soap message adding uri , prefix.

why need prefix , soap message? need send web service , send follows:

...     <pref:author>gambardella, matthew</pref:author> ... 

i tried add xslt component return me error when use : or &#x3a; (hex code).

i thought use dataweave (mapper) component works mule enterprise edition.

this result want:

<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"  xmlns:pref="uri_soap_ws"> <soap:body>    <pref:book>           <pref:author>gambardella, matthew</pref:author>           <pref:title>xml developer's guide</pref:title>           <pref:genre>computer</pref:genre>           <pref:price>44.95</pref:price>           <pref:publish_date>2000-10-01</pref:publish_date>           <pref:description>an in-depth xml</pref:description>        </pref:book> </soap:body> </soap:envelope> 

what best way transformation?

the following stylesheet:

xslt 1.0

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:pref="uri_soap_ws"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/>  <xsl:template match="/">     <soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" xmlns:pref="uri_soap_ws">         <soap:body>             <xsl:apply-templates/>         </soap:body>     </soap:envelope> </xsl:template>  <xsl:template match="*">     <xsl:element name="pref:{local-name()}">         <xsl:apply-templates/>     </xsl:element> </xsl:template>  </xsl:stylesheet> 

when applied xml example, return:

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" xmlns:pref="uri_soap_ws">    <soap:body>       <pref:book>          <pref:author>gambardella, matthew</pref:author>          <pref:title>xml developer's guide</pref:title>          <pref:genre>computer</pref:genre>          <pref:price>44.95</pref:price>          <pref:publish_date>2000-10-01</pref:publish_date>          <pref:description>an in-depth xml</pref:description>       </pref:book>    </soap:body> </soap:envelope> 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -