Hi, I deployed the jaggery app in the wso2 cep. It works as expected.
"utility.js" is not supported when the jaggery app is deployed in the jaggery server. Thank you everybody for the help. On Tue, Jan 27, 2015 at 11:49 PM, Lakshman Udayakantha <[email protected]> wrote: > Hi, > > I saw in EMM code this have done using utility.js file[1]. I have tested > it and it works properly.below is the code I used. > > var log = new Log(); > > var utility = require('/modules/utility.js').rxt_utility(); > > var data = > '<employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>'; > > var xml = new XML(data) > > var employeesJson = utility.xml.convertE4XtoJSON(xml); > > log.info(employeesJson); > > > you have to copy the utility.js file to modules directory to get the > required functionality. > > > [1] > https://github.com/wso2/product-emm/blob/master/modules/apps/publisher/modules/utility.js > > > Thanks > > On Tue, Jan 27, 2015 at 11:47 PM, Farasath Ahamed <[email protected]> > wrote: > >> I think utils.convertE4XtoJSON() expects the root element of the XML file >> as the argument not the whole XML file as a string. >> >> >> >> On Tue, Jan 27, 2015 at 11:19 PM, Sabra Ossen <[email protected]> wrote: >> >>> I didn't include it in any of my code yet. I tried it to the above >>> mentioned simple xml string. Here is the code. >>> >>> <% >>> var utils = require('utils').xml; >>> var xmlString = >>> "<employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>"; >>> var employeesJson = utils.convertE4XtoJSON(xmlString); >>> print(employeesJson); >>> %> >>> >>> On Tue, Jan 27, 2015 at 11:07 PM, Farasath Ahamed <[email protected]> >>> wrote: >>> >>>> Can you please post your code here? (the part you use this conversion >>>> may be) >>>> >>>> On Tue, Jan 27, 2015 at 10:35 PM, Sabra Ossen <[email protected]> wrote: >>>> >>>>> Hi, >>>>> >>>>> The parameter passed for the method convertE4XtoJSON is String right. >>>>> But I get the following error when I use the code. >>>>> >>>>> *org.mozilla.javascript.EcmaError: TypeError: Cannot find function >>>>> localName in object >>>>> <employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>. >>>>> (xml#49)* >>>>> >>>>> Is there any specific format the string needs to be in? >>>>> >>>>> On Tue, Jan 27, 2015 at 9:56 PM, Sabra Ossen <[email protected]> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I will try the package as suggested. >>>>>> >>>>>> Thanks. >>>>>> >>>>>> On Tue, Jan 27, 2015 at 9:28 PM, Buddhima Wijeweera < >>>>>> [email protected]> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> This package will help you on this: >>>>>>> >>>>>>> https://github.com/wso2/product-es/tree/greg-changes-asset-extensions/modules/jaggery-modules/utils >>>>>>> >>>>>>> Sample usage : >>>>>>> var utils=require('utils').xml; >>>>>>> utils.convertE4XtoJSON(<XML String>) >>>>>>> >>>>>>> Thanks! >>>>>>> >>>>>>> On Tue, Jan 27, 2015 at 9:23 PM, Sabra Ossen <[email protected]> wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> Is there any method to convert an xml string (ex : >>>>>>>> "<employees><person><name>Tove</name><age>32</age></person><person><name>Jani</name><age>26</age></person></employees>") >>>>>>>> to a json object using jaggery, I need to access the JSON object in >>>>>>>> jaggery. >>>>>>>> >>>>>>>> Currently I am using JAXB to convert the xml to a Java Object and >>>>>>>> the write the json in jaggery. Is there any work-around to achieve the >>>>>>>> mentioned functionality. >>>>>>>> >>>>>>>> Any help is appreciated. >>>>>>>> >>>>>>>> Thanks. >>>>>>>> >>>>>>>> -- >>>>>>>> Sabra Ossen >>>>>>>> *Software Engineering Intern* >>>>>>>> Mobile : +94 (0) 785 227 769 >>>>>>>> [email protected] >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> Dev mailing list >>>>>>>> [email protected] >>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Buddhima Wijeweera >>>>>>> Software Engineer; WSO2 Inc.; http://wso2.com , >>>>>>> >>>>>>> Mobile: +94 71 427 9966 >>>>>>> Email: [email protected] >>>>>>> Blog: https://buddhimawijeweera.wordpress.com >>>>>>> GitHub Profile: https://github.com/Buddhima >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Sabra Ossen >>>>>> *Software Engineering Intern* >>>>>> Mobile : +94 (0) 785 227 769 >>>>>> [email protected] >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Sabra Ossen >>>>> *Software Engineering Intern* >>>>> Mobile : +94 (0) 785 227 769 >>>>> [email protected] >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> [email protected] >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> *Farasath Ahamed* >>>> Software Engineering Intern >>>> WSO2 Inc.; http://wso2.com >>>> >>>> Mobile: +94 777 603 866 >>>> E-Mail: farasath <http://goog_1999535192>[email protected] >>>> >>> >>> >>> >>> -- >>> Sabra Ossen >>> *Software Engineering Intern* >>> Mobile : +94 (0) 785 227 769 >>> [email protected] >>> >> >> >> >> -- >> *Farasath Ahamed* >> Software Engineering Intern >> WSO2 Inc.; http://wso2.com >> >> Mobile: +94 777 603 866 >> E-Mail: farasath <http://goog_1999535192>[email protected] >> >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Lakshman Udayakantha > WSO2 Inc. www.wso2.com > lean.enterprise.middleware > Mobile: *0711241005* > > -- Sabra Ossen *Software Engineering Intern* Mobile : +94 (0) 785 227 769 [email protected]
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
