Could you someone enlightme about the best way to exchange XML with a
JavaScript function writen in Rhino back and fordward?
I have been looking in the documentation, see some clues about
changing the E4X implmentation to AXIOM, but not much detail.
What I need to do is:
- Set an already parsed XML in the scope.
- Get a E4X XML from the scope
In the Java side I'm working with AXIOM, since I will send that using
Axis.
My idea was to use Rhino JavaScript to modify the WS payload before
sending it.
I already succed passing just a string and reparsing, but performance
will be bettter if I could exchange back and ford an already parsed
XML.
Any suggestion or idea will be more than wellcome.
Thanks !
Carlos
>
> Hi everyone,
>
> Could you someone enlightme about the best way to exchange XML with a
> JavaScript function writen in Rhino back and fordward?
>
> I have been looking in the documentation, see some clues about
> changing the E4X implmentation to AXIOM, but not much detail.
>
> What I need to do is:
>
> - Set an already parsed XML in the scope.
> - Get a E4X XML from the scope
It does not work that way. You would need to serialize out your axiom
document to a form that can be used by E4X.
Why not just use the axiom document in rhino?
best,
-Rob
>
>
> In the Java side I'm working with AXIOM, since I will send that using
> Axis.
> My idea was to use Rhino JavaScript to modify the WS payload before
> sending it.
>
> I already succed passing just a string and reparsing, but performance
> will be bettter if I could exchange back and ford an already parsed
> XML.
>
> Any suggestion or idea will be more than wellcome.
>
> Thanks !
>
> Carlos
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> dev-tech-js-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
best,
-Rob
On Sep 5, 2008, at 11:01 AM, Carlos Montagut wrote:
> Hi Rob,
>
> > Why not just use the axiom document in rhino?
>
> Well, I wanted to use inside the script all the functionally
> provided by E4X... In some cases the full payload will generated by
> the script, so E4X was a very easy way to generate them.
>
> When I return a XML from JavaScript and I get it in Java, the object
> I get is an org.mozilla.javascript.xmlimpl.XML (which I don't have
> access, is not a public class).
>
> Do you know which object should I instatiate in the Java side, that
> once I pass it to the Scope, in the JavaScrit side I see it as an
> XML of E4X (I could create this kind of object from using the AXIOM
> doc)?
> At least something that is not a serialized string that I should
> parse again...
>
> Thanks again!
>
> Carlos
>
> 2008/9/5 Robert Koberg <r...@koberg.com>
>
> On Sep 5, 2008, at 10:15 AM, Carlos Montagut wrote:
>
>
> Hi everyone,
>
> Could you someone enlightme about the best way to exchange XML with a
> JavaScript function writen in Rhino back and fordward?
>
> I have been looking in the documentation, see some clues about
> changing the E4X implmentation to AXIOM, but not much detail.
>
> What I need to do is:
>
> - Set an already parsed XML in the scope.
> - Get a E4X XML from the scope
>
>
> It does not work that way. You would need to serialize out your
> axiom document to a form that can be used by E4X.
>
> Why not just use the axiom document in rhino?
>
> best,
> -Rob
>
>
>
>
> In the Java side I'm working with AXIOM, since I will send that using
> Axis.
> My idea was to use Rhino JavaScript to modify the WS payload before
> sending it.
>
> I already succed passing just a string and reparsing, but performance
> will be bettter if I could exchange back and ford an already parsed
> XML.
>
> Any suggestion or idea will be more than wellcome.
>
> Thanks !
>
> Carlos
/** Utility method that converts a W3C DOM Node into an E4X XML object.
*
* @param node The Node to be converted.
*
* @param cx The current JavaScript context.
*
* @param scope The current JavaScript scope.
*
* @return A Scriptable representing an E4X XML object.
*/
public static Scriptable domToE4X(org.w3c.dom.Node node, Context cx,
Scriptable scope) {
if (node == null) {
return null;
}
return cx.newObject(scope, "XML", new org.w3c.dom.Node[] { node });
}
/** Utility method that converts an E4X XML object into a W3C DOM Node.
*
* @param node The E4X XML node to be converted.
*
* @return A W3C DOM Node.
*/
public static org.w3c.dom.Node e4xToDOM(Scriptable node) {
return org.mozilla.javascript.xmlimpl.XMLLibImpl.toDomNode(node);
Thanks Rob!
> Ok, I see, will try with on that.
>
> Was any particular reason why you gave up E4X? (peformance, etc?)
> (I'm just new with it and any pit fall that I could avoid would be good to know).
Somebody please correct me if I am wrong!
E4X basically wraps your XML parser's (probably Xerces) W3 DOM
implementation, which is pretty heavy, memory-wise. If you deal with
alot of complex XML, you will probably want to keep an eye on your
memory usage.
Currently, I tend toward XML DBs with XQuery and XSL when dealing with
XML.
best,
-Rob
> > dev-tech-js-engine-rh...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
I just tried and worked perfectly. Is just perfect for what I was
needing.
Thanks a lot for your post!
bye
> Why not just use the axiom document in rhino?
Well, I wanted to use inside the script all the functionally provided by
E4X... In some cases the full payload will generated by the script, so E4X
was a very easy way to generate them.
When I return a XML from JavaScript and I get it in Java, the object I get
is an org.mozilla.javascript.xmlimpl.XML (which I don't have access, is not
a public class).
Do you know which object should I instatiate in the Java side, that once I
pass it to the Scope, in the JavaScrit side I see it as an XML of E4X (I
could create this kind of object from using the AXIOM doc)?
At least something that is not a serialized string that I should parse
again...
Thanks again!
Carlos
2008/9/5 Robert Koberg <r...@koberg.com>
>
> On Sep 5, 2008, at 10:15 AM, Carlos Montagut wrote:
>
>
>> Hi everyone,
>>
>> Could you someone enlightme about the best way to exchange XML with a
>> JavaScript function writen in Rhino back and fordward?
>>
>> I have been looking in the documentation, see some clues about
>> changing the E4X implmentation to AXIOM, but not much detail.
>>
>> What I need to do is:
>>
>> - Set an already parsed XML in the scope.
>> - Get a E4X XML from the scope
>>
>
>
> It does not work that way. You would need to serialize out your axiom
> document to a form that can be used by E4X.
>
> Why not just use the axiom document in rhino?
>
> best,
> -Rob
>
>
>
>>
>> In the Java side I'm working with AXIOM, since I will send that using
>> Axis.
>> My idea was to use Rhino JavaScript to modify the WS payload before
>> sending it.
>>
>> I already succed passing just a string and reparsing, but performance
>> will be bettter if I could exchange back and ford an already parsed
>> XML.
>>
>> Any suggestion or idea will be more than wellcome.
>>
>> Thanks !
>>
>> Carlos