On May 27, 1:05 pm, ktm <[EMAIL PROTECTED]> wrote: > This only works as expected if I remove the hyphen from the > reservation-request: > > var baseDocument = > <create-reservation-request> > <reservation-request> > <product><id>XXX</id></product> > </reservation-request> > </create-reservation-request> > > print(baseDocument.reservation-request.product[0]); > > With the hyphen, I get this: > script error in file createReservation.js : > org.mozilla.javascript.EcmaError: ReferenceError: "request" is not > defined. > > I think the interpreter is trying to subtract request from > reservation. Is this a bug in rhino (using 1_7R1), or am I not > supposed to have hyphens in my tags?
You're right that the '-' in the argument to print is interpreted as a minus. Rhino is correct; identifier names outside of XML literals must follow normal JavaScript rules. You can use [] instead of '.' to work around this rule: js> print(baseDocument["reservation-request"].product[0]); <product> <id>XXX</id> </product> --N _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
