Hi Tanya,

That worked like a charm. :) Thanks a lot.

Regards,
Bhathiya

On Fri, Feb 27, 2015 at 12:00 AM, Tanya Madurapperuma <[email protected]>
wrote:

> Hi Bhathiya,
>
> Try changing your line 13 to
>            var dataSourceXml = new XML(new String(dataSource));
>
> Thanks,
> Tanya
>
> On Thu, Feb 26, 2015 at 10:39 PM, Bhathiya Jayasekara <[email protected]>
> wrote:
>
>> Email was sent by mistake while typing. Sorry about that.
>>
>> I could resolve above parsing issue with below code.
>>
>> var dataSourceXml = new XML("'" + dataSource + "'");
>>
>> But I still can't read values from it. My code is like this.
>>
>> var url = dataSourceXml.*::['url'].text();
>> log.info(url);
>> log.info(dataSourceXml.url.text());
>>
>> Both above logs give empty outputs. What am I doing wrong here?
>>
>> @Rajith: I tried your suggestion. But it says
>>
>> [2015-02-26 22:37:56,928] ERROR - RhinoEngine
>> org.mozilla.javascript.EcmaError: TypeError: Cannot find function
>> toXMLString in object <configuration><url>https://localhost:9445
>> </url><username>admin</username><password>admin</password><driverClassName>com.mysql.jdbc.Driver</driverClassName>
>> </configuration>. (/admin-dashboard/modules/analytics/list.jag#64)
>> [2015-02-26 22:37:56,928] ERROR - WebAppManager
>> org.mozilla.javascript.EcmaError: TypeError: Cannot find function
>> toXMLString in object <configuration><url>https://localhost:9445
>> </url><username>admin</username><password>admin</password><driverClassName>com.mysql.jdbc.Driver</driverClassName>
>> </configuration>. (/admin-dashboard/modules/analytics/list.jag#64)
>> org.jaggeryjs.scriptengine.exceptions.ScriptException:
>> org.mozilla.javascript.EcmaError: TypeError: Cannot find function
>> toXMLString in object <configuration><url>https://localhost:9445
>> </url><username>admin</username><password>admin</password><driverClassName>com.mysql.jdbc.Driver</driverClassName>
>>
>> Thanks,
>> Bhathiya
>>
>>
>>
>> On Thu, Feb 26, 2015 at 10:17 PM, Bhathiya Jayasekara <[email protected]>
>> wrote:
>>
>>> Hi all,
>>>
>>> I'm facing some issues while trying to read some values from a
>>> datasource XML. My code is like this.
>>>
>>> 1   var stub = new 
>>> org.wso2.carbon.ndatasource.ui.stub.NDataSourceAdminStub('https://localhost:9443/services/NDataSourceAdmin');
>>> 2   var client = stub._getServiceClient();
>>> 3   var options = client.getOptions();
>>> 4   var authenticator = new 
>>> org.apache.axis2.transport.http.HttpTransportProperties.Authenticator();
>>> 5   authenticator.setUsername(username);
>>> 6   authenticator.setPassword(password);
>>> 7   authenticator.setPreemptiveAuthentication(true);
>>> 8   
>>> options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
>>>  authenticator);
>>> 9   client.setOptions(options);
>>>
>>> 10  var dsName = "WSO2_STAT_DB";
>>>
>>> 11  var dataSource = 
>>> stub.getDataSource(dsName).getDsMetaInfo().getDefinition().getDsXMLConfiguration();
>>> 12  //var dataSource = 
>>> <configuration><url>https://localhost:9445</url><username>admin</username><password>admin</password><driverClassName>com.mysql.jdbc.Driver</driverClassName></configuration>;
>>> 13  var dataSourceXml = new XML(dataSource);
>>>
>>> Above code gives below error.
>>>
>>> [2015-02-26 22:09:57,153] ERROR - RhinoEngine 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>> [2015-02-26 22:09:57,153] ERROR - WebAppManager 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>> org.jaggeryjs.scriptengine.exceptions.ScriptException: 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>>
>>>
>>> If I uncomment *line 12* and comment *line 11*, I don't get above
>>> error. but if I log both lines (11 and 12), they still give the same
>>> output. How do I get *line 11 *working like *line 12*?
>>>
>>> Thanks,
>>> Bhathiya
>>>
>>>
>>>
>>>
>>>
>>> var dataSourceXml = new XML("'" + dataSource + "'");
>>>
>>>
>>> --
>>> *Bhathiya Jayasekara*
>>> *Software Engineer,*
>>> *WSO2 inc., http://wso2.com <http://wso2.com>*
>>>
>>> *Phone: +94715478185 <%2B94715478185>*
>>> *LinkedIn: http://www.linkedin.com/in/bhathiyaj
>>> <http://www.linkedin.com/in/bhathiyaj>*
>>> *Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
>>> *Blog: http://movingaheadblog.blogspot.com
>>> <http://movingaheadblog.blogspot.com/>*
>>>
>>
>>
>>
>> --
>> *Bhathiya Jayasekara*
>> *Software Engineer,*
>> *WSO2 inc., http://wso2.com <http://wso2.com>*
>>
>> *Phone: +94715478185 <%2B94715478185>*
>> *LinkedIn: http://www.linkedin.com/in/bhathiyaj
>> <http://www.linkedin.com/in/bhathiyaj>*
>> *Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
>> *Blog: http://movingaheadblog.blogspot.com
>> <http://movingaheadblog.blogspot.com/>*
>>
>> On Thu, Feb 26, 2015 at 10:17 PM, Bhathiya Jayasekara <[email protected]>
>> wrote:
>>
>>> Hi all,
>>>
>>> I'm facing some issues while trying to read some values from a
>>> datasource XML. My code is like this.
>>>
>>> 1   var stub = new 
>>> org.wso2.carbon.ndatasource.ui.stub.NDataSourceAdminStub('https://localhost:9443/services/NDataSourceAdmin');
>>> 2   var client = stub._getServiceClient();
>>> 3   var options = client.getOptions();
>>> 4   var authenticator = new 
>>> org.apache.axis2.transport.http.HttpTransportProperties.Authenticator();
>>> 5   authenticator.setUsername(username);
>>> 6   authenticator.setPassword(password);
>>> 7   authenticator.setPreemptiveAuthentication(true);
>>> 8   
>>> options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
>>>  authenticator);
>>> 9   client.setOptions(options);
>>>
>>> 10  var dsName = "WSO2_STAT_DB";
>>>
>>> 11  var dataSource = 
>>> stub.getDataSource(dsName).getDsMetaInfo().getDefinition().getDsXMLConfiguration();
>>> 12  //var dataSource = 
>>> <configuration><url>https://localhost:9445</url><username>admin</username><password>admin</password><driverClassName>com.mysql.jdbc.Driver</driverClassName></configuration>;
>>> 13  var dataSourceXml = new XML(dataSource);
>>>
>>> Above code gives below error.
>>>
>>> [2015-02-26 22:09:57,153] ERROR - RhinoEngine 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>> [2015-02-26 22:09:57,153] ERROR - WebAppManager 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>> org.jaggeryjs.scriptengine.exceptions.ScriptException: 
>>> org.mozilla.javascript.EvaluatorException: The choice of Java method 
>>> java.lang.String.replace matching JavaScript argument types 
>>> (function,string) is ambiguous; candidate methods are:
>>>     class java.lang.String 
>>> replace(java.lang.CharSequence,java.lang.CharSequence)
>>>     class java.lang.String replace(char,char) (xml#4)
>>>
>>>
>>> If I uncomment *line 12* and comment *line 11*, I don't get above
>>> error. but if I log both lines (11 and 12), they still give the same
>>> output. How do I get *line 11 *working like *line 12*?
>>>
>>> Thanks,
>>> Bhathiya
>>>
>>>
>>>
>>>
>>>
>>> var dataSourceXml = new XML("'" + dataSource + "'");
>>>
>>>
>>> --
>>> *Bhathiya Jayasekara*
>>> *Software Engineer,*
>>> *WSO2 inc., http://wso2.com <http://wso2.com>*
>>>
>>> *Phone: +94715478185 <%2B94715478185>*
>>> *LinkedIn: http://www.linkedin.com/in/bhathiyaj
>>> <http://www.linkedin.com/in/bhathiyaj>*
>>> *Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
>>> *Blog: http://movingaheadblog.blogspot.com
>>> <http://movingaheadblog.blogspot.com/>*
>>>
>>
>>
>>
>> --
>> *Bhathiya Jayasekara*
>> *Software Engineer,*
>> *WSO2 inc., http://wso2.com <http://wso2.com>*
>>
>> *Phone: +94715478185 <%2B94715478185>*
>> *LinkedIn: http://www.linkedin.com/in/bhathiyaj
>> <http://www.linkedin.com/in/bhathiyaj>*
>> *Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
>> *Blog: http://movingaheadblog.blogspot.com
>> <http://movingaheadblog.blogspot.com/>*
>>
>
>
>
> --
> Tanya Madurapperuma
>
> Software Engineer,
> WSO2 Inc. : wso2.com
> Mobile : +94718184439
> Blog : http://tanyamadurapperuma.blogspot.com
>



-- 
*Bhathiya Jayasekara*
*Software Engineer,*
*WSO2 inc., http://wso2.com <http://wso2.com>*

*Phone: +94715478185*
*LinkedIn: http://www.linkedin.com/in/bhathiyaj
<http://www.linkedin.com/in/bhathiyaj>*
*Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
*Blog: http://movingaheadblog.blogspot.com
<http://movingaheadblog.blogspot.com/>*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to