Hi, I would like to submit enhancement for batik SVG DOM in regards default attribute.
Because batik always (for certain element) add default attribute, this enhancement allows whether the default attribute is/are generated or not by setting the flag on ExtensibleSVGDOMImplementation.setInitializeAttribute(boolean). The default value is true to keep backward compatible Here is the bugzilla (enhancement) id:28081 I also include the diff attached to this email. Regards Tonny Kohar -- Sketsa SVG Graphics Editor http://www.kiyut.com
? .nbattrs Index: AbstractElement.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/dom/svg/AbstractElement.java,v retrieving revision 1.10 diff -u -r1.10 AbstractElement.java --- AbstractElement.java 8 Aug 2003 11:38:59 -0000 1.10 +++ AbstractElement.java 31 Mar 2004 09:53:06 -0000 @@ -91,7 +91,7 @@ protected AbstractElement(String prefix, AbstractDocument owner) { ownerDocument = owner; setPrefix(prefix); - initializeAttributes(); + //initializeAttributes(); } // NodeEventTarget //////////////////////////////////////////////////// @@ -144,7 +144,7 @@ /** * Initializes the attributes of this element to their default value. */ - protected void initializeAttributes() { + public void initializeAttributes() { AttributeInitializer ai = getAttributeInitializer(); if (ai != null) { ai.initializeAttributes(this); Index: ExtensibleSVGDOMImplementation.java =================================================================== RCS file: /home/cvspublic/xml-batik/sources/org/apache/batik/dom/svg/ExtensibleSVGDOMImplementation.java,v retrieving revision 1.8 diff -u -r1.8 ExtensibleSVGDOMImplementation.java --- ExtensibleSVGDOMImplementation.java 8 Aug 2003 11:38:59 -0000 1.8 +++ ExtensibleSVGDOMImplementation.java 31 Mar 2004 09:53:08 -0000 @@ -114,6 +114,12 @@ public static DOMImplementation getDOMImplementation() { return DOM_IMPLEMENTATION; } + + /** + * flag indicating wheter the new created attribute will be initialized with default value + * the default value = true to keep backward compatible + */ + protected boolean initializeAttribute = true; /** * Creates a new DOMImplementation. @@ -229,8 +235,9 @@ /** * Implements the behavior of Document.createElementNS() for this * DOM implementation. + * This is the original method */ - public Element createElementNS(AbstractDocument document, + public Element createElementNSOriginal(AbstractDocument document, String namespaceURI, String qualifiedName) { if (SVG_NAMESPACE_URI.equals(namespaceURI)) { @@ -263,6 +270,29 @@ } } + public void setInitializeAttribute(boolean flag) { + this.initializeAttribute = flag; + } + + /** This is the overiden method + */ + public Element createElementNS(AbstractDocument document, + String namespaceURI, + String qualifiedName) { + Element elt = createElementNSOriginal(document, namespaceURI, qualifiedName); + // special case for SVGElement + if (elt instanceof SVGOMSVGElement) { + ((AbstractElement)elt).initializeAttributes(); + return elt; + } + if (initializeAttribute == true) { + if (elt instanceof AbstractElement) { + ((AbstractElement)elt).initializeAttributes(); + } + } + return elt; + } + // Service ///////////////////////////////////////////////////////// protected static List extensions = null;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]