Thomas DeWeese: > I think there will be issues since the interfaces from the DOM > packages won't be available in the global ECMAScript namespace. This > is obviously not as important in ECMAScript as other languages (where > you need to cast etc). But I suspect that some valid ECMAScript code > will fail without the imports.
Right, so I think it’s relatively common to use the constants on those interface objects (e.g. Node.ELEMENT_NODE). > Before this goes into SVN someone needs to carefully analyze the > actual ECMAScript implications. SVG 1.1 doesn’t really give concrete requirements for what should happen in the ECMAScript binding; the binding appendix is pretty high level. But I think even still, by not exposing those interfaces on the global object, you would get a non-conforming scripting environment. > The other alternative as Cameron suggested would be to replace the > package imports with the needed individual class imports. Yes, I think this is the best option. John C. Turnbull: > With the other alternative of importing the classes individually, do you > know exactly which classes will need to be imported? I would like to try > out the performance of implementing this option. Currently, the following packages are imported (see TO_BE_IMPORTED in http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/sources/org/apache/batik/script/rhino/RhinoInterpreter.java): java.lang org.w3c.dom org.w3c.dom.css org.w3c.dom.events org.w3c.dom.smil org.w3c.dom.stylesheets org.w3c.dom.svg org.w3c.dom.views org.w3c.dom.xpath For those DOM packages, we can inspect the JARs that contain the interfaces to find out which specific ones to import. jet:~/work/svn/batik/trunk/lib $ for x in xml-apis.jar xml-apis-ext.jar; do jar tf $x | egrep '^org/w3c/dom/(css/|events/|smil/|stylesheets/|svg/|views/|xpath/)?[^/]*\.class' | sed 's/\.class$//' | tr / .; done org.w3c.dom.Attr org.w3c.dom.CDATASection org.w3c.dom.CharacterData org.w3c.dom.Comment org.w3c.dom.DOMConfiguration org.w3c.dom.DOMError org.w3c.dom.DOMErrorHandler org.w3c.dom.DOMException org.w3c.dom.DOMImplementation org.w3c.dom.DOMImplementationList org.w3c.dom.DOMImplementationSource org.w3c.dom.DOMLocator org.w3c.dom.DOMStringList org.w3c.dom.Document org.w3c.dom.DocumentFragment org.w3c.dom.DocumentType org.w3c.dom.Element org.w3c.dom.Entity org.w3c.dom.EntityReference org.w3c.dom.NameList org.w3c.dom.NamedNodeMap org.w3c.dom.Node org.w3c.dom.NodeList org.w3c.dom.Notation org.w3c.dom.ProcessingInstruction org.w3c.dom.Text org.w3c.dom.TypeInfo org.w3c.dom.UserDataHandler org.w3c.dom.css.CSS2Properties org.w3c.dom.css.CSSCharsetRule org.w3c.dom.css.CSSFontFaceRule org.w3c.dom.css.CSSImportRule org.w3c.dom.css.CSSMediaRule org.w3c.dom.css.CSSPageRule org.w3c.dom.css.CSSPrimitiveValue org.w3c.dom.css.CSSRule org.w3c.dom.css.CSSRuleList org.w3c.dom.css.CSSStyleDeclaration org.w3c.dom.css.CSSStyleRule org.w3c.dom.css.CSSStyleSheet org.w3c.dom.css.CSSUnknownRule org.w3c.dom.css.CSSValue org.w3c.dom.css.CSSValueList org.w3c.dom.css.Counter org.w3c.dom.css.DOMImplementationCSS org.w3c.dom.css.DocumentCSS org.w3c.dom.css.ElementCSSInlineStyle org.w3c.dom.css.RGBColor org.w3c.dom.css.Rect org.w3c.dom.css.ViewCSS org.w3c.dom.events.DocumentEvent org.w3c.dom.events.Event org.w3c.dom.events.EventException org.w3c.dom.events.EventListener org.w3c.dom.events.EventTarget org.w3c.dom.events.MouseEvent org.w3c.dom.events.MutationEvent org.w3c.dom.events.UIEvent org.w3c.dom.stylesheets.DocumentStyle org.w3c.dom.stylesheets.LinkStyle org.w3c.dom.stylesheets.MediaList org.w3c.dom.stylesheets.StyleSheet org.w3c.dom.stylesheets.StyleSheetList org.w3c.dom.views.AbstractView org.w3c.dom.views.DocumentView org.w3c.dom.xpath.XPathEvaluator org.w3c.dom.xpath.XPathException org.w3c.dom.xpath.XPathExpression org.w3c.dom.xpath.XPathNSResolver org.w3c.dom.xpath.XPathNamespace org.w3c.dom.xpath.XPathResult org.w3c.dom.smil.ElementTimeControl org.w3c.dom.smil.TimeEvent org.w3c.dom.svg.EventListenerInitializer org.w3c.dom.svg.GetSVGDocument org.w3c.dom.svg.SVGAElement org.w3c.dom.svg.SVGAltGlyphDefElement org.w3c.dom.svg.SVGAltGlyphElement org.w3c.dom.svg.SVGAltGlyphItemElement org.w3c.dom.svg.SVGAngle org.w3c.dom.svg.SVGAnimateColorElement org.w3c.dom.svg.SVGAnimateElement org.w3c.dom.svg.SVGAnimateMotionElement org.w3c.dom.svg.SVGAnimateTransformElement org.w3c.dom.svg.SVGAnimatedAngle org.w3c.dom.svg.SVGAnimatedBoolean org.w3c.dom.svg.SVGAnimatedEnumeration org.w3c.dom.svg.SVGAnimatedInteger org.w3c.dom.svg.SVGAnimatedLength org.w3c.dom.svg.SVGAnimatedLengthList org.w3c.dom.svg.SVGAnimatedNumber org.w3c.dom.svg.SVGAnimatedNumberList org.w3c.dom.svg.SVGAnimatedPathData org.w3c.dom.svg.SVGAnimatedPoints org.w3c.dom.svg.SVGAnimatedPreserveAspectRatio org.w3c.dom.svg.SVGAnimatedRect org.w3c.dom.svg.SVGAnimatedString org.w3c.dom.svg.SVGAnimatedTransformList org.w3c.dom.svg.SVGAnimationElement org.w3c.dom.svg.SVGCSSRule org.w3c.dom.svg.SVGCircleElement org.w3c.dom.svg.SVGClipPathElement org.w3c.dom.svg.SVGColor org.w3c.dom.svg.SVGColorProfileElement org.w3c.dom.svg.SVGColorProfileRule org.w3c.dom.svg.SVGComponentTransferFunctionElement org.w3c.dom.svg.SVGCursorElement org.w3c.dom.svg.SVGDefinitionSrcElement org.w3c.dom.svg.SVGDefsElement org.w3c.dom.svg.SVGDescElement org.w3c.dom.svg.SVGDocument org.w3c.dom.svg.SVGElement org.w3c.dom.svg.SVGElementInstance org.w3c.dom.svg.SVGElementInstanceList org.w3c.dom.svg.SVGEllipseElement org.w3c.dom.svg.SVGEvent org.w3c.dom.svg.SVGException org.w3c.dom.svg.SVGExternalResourcesRequired org.w3c.dom.svg.SVGFEBlendElement org.w3c.dom.svg.SVGFEColorMatrixElement org.w3c.dom.svg.SVGFEComponentTransferElement org.w3c.dom.svg.SVGFECompositeElement org.w3c.dom.svg.SVGFEConvolveMatrixElement org.w3c.dom.svg.SVGFEDiffuseLightingElement org.w3c.dom.svg.SVGFEDisplacementMapElement org.w3c.dom.svg.SVGFEDistantLightElement org.w3c.dom.svg.SVGFEFloodElement org.w3c.dom.svg.SVGFEFuncAElement org.w3c.dom.svg.SVGFEFuncBElement org.w3c.dom.svg.SVGFEFuncGElement org.w3c.dom.svg.SVGFEFuncRElement org.w3c.dom.svg.SVGFEGaussianBlurElement org.w3c.dom.svg.SVGFEImageElement org.w3c.dom.svg.SVGFEMergeElement org.w3c.dom.svg.SVGFEMergeNodeElement org.w3c.dom.svg.SVGFEMorphologyElement org.w3c.dom.svg.SVGFEOffsetElement org.w3c.dom.svg.SVGFEPointLightElement org.w3c.dom.svg.SVGFESpecularLightingElement org.w3c.dom.svg.SVGFESpotLightElement org.w3c.dom.svg.SVGFETileElement org.w3c.dom.svg.SVGFETurbulenceElement org.w3c.dom.svg.SVGFilterElement org.w3c.dom.svg.SVGFilterPrimitiveStandardAttributes org.w3c.dom.svg.SVGFitToViewBox org.w3c.dom.svg.SVGFontElement org.w3c.dom.svg.SVGFontFaceElement org.w3c.dom.svg.SVGFontFaceFormatElement org.w3c.dom.svg.SVGFontFaceNameElement org.w3c.dom.svg.SVGFontFaceSrcElement org.w3c.dom.svg.SVGFontFaceUriElement org.w3c.dom.svg.SVGForeignObjectElement org.w3c.dom.svg.SVGGElement org.w3c.dom.svg.SVGGlyphElement org.w3c.dom.svg.SVGGlyphRefElement org.w3c.dom.svg.SVGGradientElement org.w3c.dom.svg.SVGHKernElement org.w3c.dom.svg.SVGICCColor org.w3c.dom.svg.SVGImageElement org.w3c.dom.svg.SVGLangSpace org.w3c.dom.svg.SVGLength org.w3c.dom.svg.SVGLengthList org.w3c.dom.svg.SVGLineElement org.w3c.dom.svg.SVGLinearGradientElement org.w3c.dom.svg.SVGLocatable org.w3c.dom.svg.SVGMPathElement org.w3c.dom.svg.SVGMarkerElement org.w3c.dom.svg.SVGMaskElement org.w3c.dom.svg.SVGMatrix org.w3c.dom.svg.SVGMetadataElement org.w3c.dom.svg.SVGMissingGlyphElement org.w3c.dom.svg.SVGNumber org.w3c.dom.svg.SVGNumberList org.w3c.dom.svg.SVGPaint org.w3c.dom.svg.SVGPathElement org.w3c.dom.svg.SVGPathSeg org.w3c.dom.svg.SVGPathSegArcAbs org.w3c.dom.svg.SVGPathSegArcRel org.w3c.dom.svg.SVGPathSegClosePath org.w3c.dom.svg.SVGPathSegCurvetoCubicAbs org.w3c.dom.svg.SVGPathSegCurvetoCubicRel org.w3c.dom.svg.SVGPathSegCurvetoCubicSmoothAbs org.w3c.dom.svg.SVGPathSegCurvetoCubicSmoothRel org.w3c.dom.svg.SVGPathSegCurvetoQuadraticAbs org.w3c.dom.svg.SVGPathSegCurvetoQuadraticRel org.w3c.dom.svg.SVGPathSegCurvetoQuadraticSmoothAbs org.w3c.dom.svg.SVGPathSegCurvetoQuadraticSmoothRel org.w3c.dom.svg.SVGPathSegLinetoAbs org.w3c.dom.svg.SVGPathSegLinetoHorizontalAbs org.w3c.dom.svg.SVGPathSegLinetoHorizontalRel org.w3c.dom.svg.SVGPathSegLinetoRel org.w3c.dom.svg.SVGPathSegLinetoVerticalAbs org.w3c.dom.svg.SVGPathSegLinetoVerticalRel org.w3c.dom.svg.SVGPathSegList org.w3c.dom.svg.SVGPathSegMovetoAbs org.w3c.dom.svg.SVGPathSegMovetoRel org.w3c.dom.svg.SVGPatternElement org.w3c.dom.svg.SVGPoint org.w3c.dom.svg.SVGPointList org.w3c.dom.svg.SVGPolygonElement org.w3c.dom.svg.SVGPolylineElement org.w3c.dom.svg.SVGPreserveAspectRatio org.w3c.dom.svg.SVGRadialGradientElement org.w3c.dom.svg.SVGRect org.w3c.dom.svg.SVGRectElement org.w3c.dom.svg.SVGRenderingIntent org.w3c.dom.svg.SVGSVGElement org.w3c.dom.svg.SVGScriptElement org.w3c.dom.svg.SVGSetElement org.w3c.dom.svg.SVGStopElement org.w3c.dom.svg.SVGStringList org.w3c.dom.svg.SVGStylable org.w3c.dom.svg.SVGStyleElement org.w3c.dom.svg.SVGSwitchElement org.w3c.dom.svg.SVGSymbolElement org.w3c.dom.svg.SVGTRefElement org.w3c.dom.svg.SVGTSpanElement org.w3c.dom.svg.SVGTests org.w3c.dom.svg.SVGTextContentElement org.w3c.dom.svg.SVGTextElement org.w3c.dom.svg.SVGTextPathElement org.w3c.dom.svg.SVGTextPositioningElement org.w3c.dom.svg.SVGTitleElement org.w3c.dom.svg.SVGTransform org.w3c.dom.svg.SVGTransformList org.w3c.dom.svg.SVGTransformable org.w3c.dom.svg.SVGURIReference org.w3c.dom.svg.SVGUnitTypes org.w3c.dom.svg.SVGUseElement org.w3c.dom.svg.SVGVKernElement org.w3c.dom.svg.SVGViewElement org.w3c.dom.svg.SVGViewSpec org.w3c.dom.svg.SVGZoomAndPan org.w3c.dom.svg.SVGZoomEvent Plus, there are a few that are included in source form: jet:~/work/svn/batik/trunk/sources $ find org/w3c/dom -name '*.java' | sed 's/\.java$//' | tr / . org.w3c.dom.events.CustomEvent org.w3c.dom.events.DocumentEvent org.w3c.dom.events.EventException org.w3c.dom.events.Event org.w3c.dom.events.EventListener org.w3c.dom.events.EventTarget org.w3c.dom.events.KeyboardEvent org.w3c.dom.events.MouseEvent org.w3c.dom.events.MutationEvent org.w3c.dom.events.MutationNameEvent org.w3c.dom.events.TextEvent org.w3c.dom.events.UIEvent org.w3c.dom.ElementTraversal org.w3c.dom.Window org.w3c.dom.Location The java.lang import isn’t needed for conformance to the spec, obviously. I suspect that it is used most commonly for use of the System class, to allow code like: <script> System.out.println("whatever"); </script> instead of: <script> java.lang.System.out.println("whatever"); </script> or even: <script> Packages.java.lang.System.out.println("whatever"); </script> (I notice that some files under the samples/ directory use the System class.) Rhino itself effectively does: java = Packages.java; when it initialises. If we want to keep importing the java.lang.* classes, then we could manually import all of the classes/interfaces listed here: http://java.sun.com/javase/6/docs/api/java/lang/package-summary.html but many of those seem like they would be unneccessary. I really don’t know which would be needed. If there were a way to enumerate at run time the classes in java.lang, so that they could all be imported manually, that would be a good solution (and would also be better than listing all of the above org.w3c.dom.* interface manually, too) but I don’t know that there is a way to do that. -- Cameron McCormack ≝ http://mcc.id.au/ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
