hillion 02/03/19 01:25:41 Modified: sources/org/apache/batik/bridge CSSUtilities.java SVGAElementBridge.java SVGTextElementBridge.java ScriptingEnvironment.java UpdateManager.java sources/org/apache/batik/dom AbstractDocument.java AbstractElement.java AbstractParentNode.java sources/org/apache/batik/dom/util SAXDocumentFactory.java test-resources/org/apache/batik/dom unitTesting.xml Added: test-resources/org/apache/batik/dom dummyXML3.xml test-sources/org/apache/batik/dom NullNamespaceTest.java Log: - Fixed a bug with anchors and <use>, - fixed a bug with null namespaces, - fixed getElementByTagName(). Revision Changes Path 1.37 +1 -29 xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java Index: CSSUtilities.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CSSUtilities.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- CSSUtilities.java 18 Mar 2002 10:28:19 -0000 1.36 +++ CSSUtilities.java 19 Mar 2002 09:25:40 -0000 1.37 @@ -67,7 +67,7 @@ * concrete objects regarding to CSS properties. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: CSSUtilities.java,v 1.36 2002/03/18 10:28:19 hillion Exp $ + * @version $Id: CSSUtilities.java,v 1.37 2002/03/19 09:25:40 hillion Exp $ */ public abstract class CSSUtilities implements CSSConstants, ErrorConstants, XMLConstants { @@ -842,34 +842,6 @@ CSSEngine refEngine = CSSUtilities.getCSSEngine(refElement); engine.importCascadedStyleMaps(refElement, refEngine, localRefElement); - - /* - Attr xmlBase = localRefElement.getAttributeNodeNS - (XML_NAMESPACE_URI, "xml:base"); - if (xmlBase != null) { - // We have a current base so merge it with our new base and - // set the result... - ParsedURL purl = new ParsedURL(uri, xmlBase.getNodeValue()); - uri = purl.toString(); - } - localRefElement.setAttributeNS(XML_NAMESPACE_URI, - "xml:base", - uri); - - SVGOMDocument document - = (SVGOMDocument)localRefElement.getOwnerDocument(); - AbstractViewCSS view = (AbstractViewCSS)document.getDefaultView(); - - - SVGOMDocument refDocument - = (SVGOMDocument)refElement.getOwnerDocument(); - AbstractViewCSS refView = (AbstractViewCSS)refDocument.getDefaultView(); - - HiddenChildElementSupport.setStyle(localRefElement, - view, - refElement, - refView); - */ } ///////////////////////////////////////////////////////////////////////// 1.15 +4 -28 xml-batik/sources/org/apache/batik/bridge/SVGAElementBridge.java Index: SVGAElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAElementBridge.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- SVGAElementBridge.java 18 Mar 2002 10:28:19 -0000 1.14 +++ SVGAElementBridge.java 19 Mar 2002 09:25:40 -0000 1.15 @@ -24,7 +24,7 @@ * Bridge class for the <a> element. * * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> - * @version $Id: SVGAElementBridge.java,v 1.14 2002/03/18 10:28:19 hillion Exp $ + * @version $Id: SVGAElementBridge.java,v 1.15 2002/03/19 09:25:40 hillion Exp $ */ public class SVGAElementBridge extends AbstractGraphicsNodeBridge { @@ -95,15 +95,7 @@ } public void handleEvent(Event evt) { - SVGAElement elt = null; - for (Element e = (Element)evt.getTarget(); - e != null; - e = SVGUtilities.getParentElement(e)) { - if (e instanceof SVGAElement) { - elt = (SVGAElement)e; - break; - } - } + SVGAElement elt = (SVGAElement)evt.getCurrentTarget(); Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); userAgent.setSVGCursor(cursor); userAgent.openLink(elt); @@ -123,15 +115,7 @@ } public void handleEvent(Event evt) { - SVGAElement elt = null; - for (Element e = (Element)evt.getTarget(); - e != null; - e = SVGUtilities.getParentElement(e)) { - if (e instanceof SVGAElement) { - elt = (SVGAElement)e; - break; - } - } + SVGAElement elt = (SVGAElement)evt.getCurrentTarget(); Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); userAgent.setSVGCursor(cursor); if (elt != null) { @@ -154,15 +138,7 @@ } public void handleEvent(Event evt) { - SVGAElement elt = null; - for (Element e = (Element)evt.getTarget(); - e != null; - e = SVGUtilities.getParentElement(e)) { - if (e instanceof SVGAElement) { - elt = (SVGAElement)e; - break; - } - } + SVGAElement elt = (SVGAElement)evt.getCurrentTarget(); Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); userAgent.setSVGCursor(cursor); userAgent.displayMessage(""); 1.53 +24 -2 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java Index: SVGTextElementBridge.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- SVGTextElementBridge.java 18 Mar 2002 10:28:20 -0000 1.52 +++ SVGTextElementBridge.java 19 Mar 2002 09:25:40 -0000 1.53 @@ -66,7 +66,7 @@ * * @author <a href="[EMAIL PROTECTED]">Stephane Hillion</a> * @author <a href="[EMAIL PROTECTED]">Bill Haneman</a> - * @version $Id: SVGTextElementBridge.java,v 1.52 2002/03/18 10:28:20 hillion Exp $ + * @version $Id: SVGTextElementBridge.java,v 1.53 2002/03/19 09:25:40 hillion Exp $ */ public class SVGTextElementBridge extends AbstractSVGBridge implements BridgeUpdateHandler, GraphicsNodeBridge, ErrorConstants { @@ -1083,7 +1083,7 @@ GVTAttributedCharacterIterator. TextAttribute.ORIENTATION_AUTO); break; - default: + case CSSPrimitiveValue.CSS_DEG: result.put(GVTAttributedCharacterIterator. TextAttribute.VERTICAL_ORIENTATION, GVTAttributedCharacterIterator. @@ -1091,6 +1091,28 @@ result.put(GVTAttributedCharacterIterator. TextAttribute.VERTICAL_ORIENTATION_ANGLE, new Float(val.getFloatValue())); + break; + case CSSPrimitiveValue.CSS_RAD: + result.put(GVTAttributedCharacterIterator. + TextAttribute.VERTICAL_ORIENTATION, + GVTAttributedCharacterIterator. + TextAttribute.ORIENTATION_ANGLE); + result.put(GVTAttributedCharacterIterator. + TextAttribute.VERTICAL_ORIENTATION_ANGLE, + new Float(val.getFloatValue() * 180 / Math.PI)); + break; + case CSSPrimitiveValue.CSS_GRAD: + result.put(GVTAttributedCharacterIterator. + TextAttribute.VERTICAL_ORIENTATION, + GVTAttributedCharacterIterator. + TextAttribute.ORIENTATION_ANGLE); + result.put(GVTAttributedCharacterIterator. + TextAttribute.VERTICAL_ORIENTATION_ANGLE, + new Float(val.getFloatValue() * 9 / 5)); + break; + default: + // Cannot happen + throw new InternalError(); } // text spacing properties... 1.15 +5 -5 xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java Index: ScriptingEnvironment.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ScriptingEnvironment.java 18 Mar 2002 12:46:13 -0000 1.14 +++ ScriptingEnvironment.java 19 Mar 2002 09:25:40 -0000 1.15 @@ -29,7 +29,7 @@ * This class contains the informations needed by the SVG scripting. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: ScriptingEnvironment.java,v 1.14 2002/03/18 12:46:13 hillion Exp $ + * @version $Id: ScriptingEnvironment.java,v 1.15 2002/03/19 09:25:40 hillion Exp $ */ public class ScriptingEnvironment extends BaseScriptingEnvironment { @@ -658,10 +658,10 @@ Element elt = (Element)evt.getCurrentTarget(); // Find the scripting language Element e = elt; - while (e == null || - !SVGConstants.SVG_NAMESPACE_URI.equals - (e.getNamespaceURI()) || - !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName())) { + while (e != null && + (!SVGConstants.SVG_NAMESPACE_URI.equals + (e.getNamespaceURI()) || + !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName()))) { e = SVGUtilities.getParentElement(e); } if (e == null) { 1.16 +2 -2 xml-batik/sources/org/apache/batik/bridge/UpdateManager.java Index: UpdateManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UpdateManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- UpdateManager.java 6 Mar 2002 17:14:44 -0000 1.15 +++ UpdateManager.java 19 Mar 2002 09:25:40 -0000 1.16 @@ -41,7 +41,7 @@ * This class provides features to manage the update of an SVG document. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: UpdateManager.java,v 1.15 2002/03/06 17:14:44 tkormann Exp $ + * @version $Id: UpdateManager.java,v 1.16 2002/03/19 09:25:40 hillion Exp $ */ public class UpdateManager implements RunnableQueue.RunHandler { @@ -268,7 +268,7 @@ throw new IllegalStateException("UpdateManager not started."); } - // Invoke first to cancel the pending [EMAIL PROTECTED] + // Invoke first to cancel the pending tasks updateRunnableQueue.preemptLater(new Runnable() { public void run() { synchronized (UpdateManager.this) { 1.14 +42 -7 xml-batik/sources/org/apache/batik/dom/AbstractDocument.java Index: AbstractDocument.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractDocument.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- AbstractDocument.java 25 Feb 2002 15:55:21 -0000 1.13 +++ AbstractDocument.java 19 Mar 2002 09:25:40 -0000 1.14 @@ -49,7 +49,7 @@ * This class implements the {@link org.w3c.dom.Document} interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: AbstractDocument.java,v 1.13 2002/02/25 15:55:21 hillion Exp $ + * @version $Id: AbstractDocument.java,v 1.14 2002/03/19 09:25:40 hillion Exp $ */ public abstract class AbstractDocument extends AbstractParentNode @@ -96,6 +96,11 @@ protected transient WeakHashMap elementsByTagNames; /** + * The ElementsByTagNameNS lists. + */ + protected transient WeakHashMap elementsByTagNamesNS; + + /** * Creates a new document. */ protected AbstractDocument() { @@ -302,9 +307,7 @@ /** * Returns an ElementsByTagName object from the cache, if any. */ - public ElementsByTagName getElementsByTagName(Node n, - String ns, - String ln) { + public ElementsByTagName getElementsByTagName(Node n, String ln) { if (elementsByTagNames == null) { return null; } @@ -313,14 +316,13 @@ if (t == null) { return null; } - return (ElementsByTagName)t.get(ns, ln); + return (ElementsByTagName)t.get(null, ln); } /** * Puts an ElementsByTagName object in the cache. */ - public void putElementsByTagName(Node n, String ns, String ln, - ElementsByTagName l) { + public void putElementsByTagName(Node n, String ln, ElementsByTagName l) { if (elementsByTagNames == null) { elementsByTagNames = new WeakHashMap(11); } @@ -328,6 +330,39 @@ t = (SoftDoublyIndexedTable)elementsByTagNames.get(n); if (t == null) { elementsByTagNames.put(n, t = new SoftDoublyIndexedTable()); + } + t.put(null, ln, l); + } + + /** + * Returns an ElementsByTagNameNS object from the cache, if any. + */ + public ElementsByTagNameNS getElementsByTagNameNS(Node n, + String ns, + String ln) { + if (elementsByTagNamesNS == null) { + return null; + } + SoftDoublyIndexedTable t; + t = (SoftDoublyIndexedTable)elementsByTagNamesNS.get(n); + if (t == null) { + return null; + } + return (ElementsByTagNameNS)t.get(ns, ln); + } + + /** + * Puts an ElementsByTagNameNS object in the cache. + */ + public void putElementsByTagNameNS(Node n, String ns, String ln, + ElementsByTagNameNS l) { + if (elementsByTagNamesNS == null) { + elementsByTagNamesNS = new WeakHashMap(11); + } + SoftDoublyIndexedTable t; + t = (SoftDoublyIndexedTable)elementsByTagNamesNS.get(n); + if (t == null) { + elementsByTagNamesNS.put(n, t = new SoftDoublyIndexedTable()); } t.put(ns, ln, l); } 1.15 +18 -9 xml-batik/sources/org/apache/batik/dom/AbstractElement.java Index: AbstractElement.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- AbstractElement.java 11 Mar 2002 09:04:37 -0000 1.14 +++ AbstractElement.java 19 Mar 2002 09:25:40 -0000 1.15 @@ -29,7 +29,7 @@ * This class implements the {@link org.w3c.dom.Element} interface. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: AbstractElement.java,v 1.14 2002/03/11 09:04:37 hillion Exp $ + * @version $Id: AbstractElement.java,v 1.15 2002/03/19 09:25:40 hillion Exp $ */ public abstract class AbstractElement extends AbstractParentChildNode @@ -302,26 +302,35 @@ } AbstractDocument ad = getCurrentDocument(); String ns = node.getNamespaceURI(); + String nm = node.getNodeName(); String ln = (ns == null) ? node.getNodeName() : node.getLocalName(); for (Node n = this; n != null; n = n.getParentNode()) { switch (n.getNodeType()) { case ELEMENT_NODE: case DOCUMENT_NODE: - ElementsByTagName l = ad.getElementsByTagName(n, ns, ln); + ElementsByTagName l = ad.getElementsByTagName(n, nm); if (l != null) { l.invalidate(); } - l = ad.getElementsByTagName(n, "*", ln); + l = ad.getElementsByTagName(n, "*"); if (l != null) { l.invalidate(); } - l = ad.getElementsByTagName(n, ns, "*"); - if (l != null) { - l.invalidate(); + ElementsByTagNameNS lns = ad.getElementsByTagNameNS(n, ns, ln); + if (lns != null) { + lns.invalidate(); } - l = ad.getElementsByTagName(n, "*", "*"); - if (l != null) { - l.invalidate(); + lns = ad.getElementsByTagNameNS(n, "*", ln); + if (lns != null) { + lns.invalidate(); + } + lns = ad.getElementsByTagNameNS(n, ns, "*"); + if (lns != null) { + lns.invalidate(); + } + lns = ad.getElementsByTagNameNS(n, "*", "*"); + if (lns != null) { + lns.invalidate(); } } } 1.13 +112 -10 xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java Index: AbstractParentNode.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- AbstractParentNode.java 11 Mar 2002 09:04:37 -0000 1.12 +++ AbstractParentNode.java 19 Mar 2002 09:25:40 -0000 1.13 @@ -24,7 +24,7 @@ * This class implements the Node interface with support for children. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: AbstractParentNode.java,v 1.12 2002/03/11 09:04:37 hillion Exp $ + * @version $Id: AbstractParentNode.java,v 1.13 2002/03/19 09:25:40 hillion Exp $ */ public abstract class AbstractParentNode extends AbstractNode { @@ -256,10 +256,10 @@ return EMPTY_NODE_LIST; } AbstractDocument ad = getCurrentDocument(); - ElementsByTagName result = ad.getElementsByTagName(this, null, name); + ElementsByTagName result = ad.getElementsByTagName(this, name); if (result == null) { - result = new ElementsByTagName(null, name); - ad.putElementsByTagName(this, null, name, result); + result = new ElementsByTagName(name); + ad.putElementsByTagName(this, name, result); } return result; } @@ -274,11 +274,12 @@ return EMPTY_NODE_LIST; } AbstractDocument ad = getCurrentDocument(); - ElementsByTagName result = ad.getElementsByTagName(this, namespaceURI, - localName); + ElementsByTagNameNS result = + ad.getElementsByTagNameNS(this, namespaceURI, + localName); if (result == null) { - result = new ElementsByTagName(namespaceURI, localName); - ad.putElementsByTagName(this, namespaceURI, localName, result); + result = new ElementsByTagNameNS(namespaceURI, localName); + ad.putElementsByTagNameNS(this, namespaceURI, localName, result); } return result; } @@ -461,6 +462,107 @@ protected int size = -1; /** + * The name identifier. + */ + protected String name; + + /** + * Creates a new ElementsByTagName object. + */ + public ElementsByTagName(String n) { + name = n; + } + + /** + * <b>DOM</b>: Implements {@link NodeList#item(int)}. + */ + public Node item(int index) { + if (size == -1) { + initialize(); + } + if (table == null || index < 0 || index > size) { + return null; + } + return table[index]; + } + + /** + * <b>DOM</b>: Implements {@link NodeList#getLength()}. + * @return {@link #size}. + */ + public int getLength() { + if (size == -1) { + initialize(); + } + return size; + } + + /** + * Invalidates the list. + */ + public void invalidate() { + size = -1; + } + + /** + * Appends a node to the list. + */ + protected void append(Node n) { + if (table == null) { + table = new Node[11]; + } else if (size == table.length - 1) { + Node[] t = new Node[table.length * 2 + 1]; + for (int i = 0; i < size; i++) { + t[i] = table[i]; + } + table = t; + } + table[size++] = n; + } + + /** + * Initializes the list. + */ + protected void initialize() { + size = 0; + for (Node n = AbstractParentNode.this.getFirstChild(); + n != null; + n = n.getNextSibling()) { + initialize(n); + } + } + + private void initialize(Node node) { + if (node.getNodeType() == ELEMENT_NODE) { + String nm = node.getNodeName(); + if (name.equals("*") || name.equals(nm)) { + append(node); + } + } + for (Node n = node.getFirstChild(); + n != null; + n = n.getNextSibling()) { + initialize(n); + } + } + } + + /** + * To manage a list of nodes. + */ + protected class ElementsByTagNameNS implements NodeList { + + /** + * The table. + */ + protected Node[] table; + + /** + * The number of nodes. + */ + protected int size = -1; + + /** * The namespace URI identifier. */ protected String namespaceURI; @@ -471,9 +573,9 @@ protected String localName; /** - * Creates a new Nodes object. + * Creates a new ElementsByTagNameNS object. */ - public ElementsByTagName(String ns, String ln) { + public ElementsByTagNameNS(String ns, String ln) { namespaceURI = ns; localName = ln; } 1.8 +11 -4 xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java Index: SAXDocumentFactory.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SAXDocumentFactory.java 18 Mar 2002 10:28:27 -0000 1.7 +++ SAXDocumentFactory.java 19 Mar 2002 09:25:40 -0000 1.8 @@ -36,7 +36,7 @@ * from an URI using SAX2. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: SAXDocumentFactory.java,v 1.7 2002/03/18 10:28:27 hillion Exp $ + * @version $Id: SAXDocumentFactory.java,v 1.8 2002/03/19 09:25:40 hillion Exp $ */ public class SAXDocumentFactory extends DefaultHandler @@ -290,12 +290,19 @@ for (int i = 0; i < len; i++) { String aname = attributes.getQName(i); if (aname.equals("xmlns")) { - namespaces.put("", attributes.getValue(i)); + String ns = attributes.getValue(i); + if (ns.length() == 0) { + ns = null; + } + namespaces.put("", ns); } else { if (aname.startsWith("xmlns:")) { + String ns = attributes.getValue(i); + if (ns.length() == 0) { + ns = null; + } int idx = aname.indexOf(':'); - namespaces.put(aname.substring(idx + 1), - attributes.getValue(i)); + namespaces.put(aname.substring(idx + 1), ns); } } } 1.3 +18 -1 xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- unitTesting.xml 19 Nov 2001 13:39:56 -0000 1.2 +++ unitTesting.xml 19 Mar 2002 09:25:41 -0000 1.3 @@ -9,7 +9,7 @@ <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: unitTesting.xml,v 1.2 2001/11/19 13:39:56 hillion Exp $ --> +<!-- @version $Id: unitTesting.xml,v 1.3 2002/03/19 09:25:41 hillion Exp $ --> <!-- ========================================================================= --> <testSuite id="dom.unitTesting" name="org.apache.batik.dom package - Unit Testing"> @@ -26,6 +26,23 @@ <property name="ParserClassName" class="java.lang.String" value="org.apache.crimson.parser.XMLReaderImpl" /> + </test> + + <!-- ========================================================================== --> + <!-- null namespace test --> + <!-- ========================================================================== --> + <test id="nullNamespace1" class="org.apache.batik.dom.NullNamespaceTest" > + <arg class="java.lang.String" + value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> + <arg class="java.lang.String" value="doc" /> + <arg class="java.lang.String" value="root" /> + </test> + + <test id="nullNamespace2" class="org.apache.batik.dom.NullNamespaceTest" > + <arg class="java.lang.String" + value="test-resources/org/apache/batik/dom/dummyXML3.xml" /> + <arg class="java.lang.String" value="doc" /> + <arg class="java.lang.String" value="elt2" /> </test> <!-- ========================================================================== --> 1.1 xml-batik/test-resources/org/apache/batik/dom/dummyXML3.xml Index: dummyXML3.xml =================================================================== <doc id="root" attr="value1"> <elt1/> <elt2 id="elt2" attr2="value2" xmlns=""> Content </elt2> </doc> 1.1 xml-batik/test-sources/org/apache/batik/dom/NullNamespaceTest.java Index: NullNamespaceTest.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.dom; import org.w3c.dom.*; import java.io.*; import java.net.*; import org.apache.batik.dom.util.*; import org.apache.batik.util.*; import org.apache.batik.test.*; /** * This class tests the empty string value for an xmlns attribute. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id: NullNamespaceTest.java,v 1.1 2002/03/19 09:25:41 hillion Exp $ */ public class NullNamespaceTest extends AbstractTest { public static String ERROR_GET_ELEMENT_BY_ID_FAILED = "error.get.element.by.id.failed"; public static String ENTRY_KEY_ID = "entry.key.id"; protected String testFileName; protected String rootTag; protected String targetId; public NullNamespaceTest(String file, String root, String id) { testFileName = file; rootTag = root; targetId = id; } public TestReport runImpl() throws Exception { String parser = XMLResourceDescriptor.getXMLParserClassName(); DocumentFactory df = new SAXDocumentFactory (GenericDOMImplementation.getDOMImplementation(), parser); File f = (new File(testFileName)); URL url = f.toURL(); Document doc = df.createDocument(null, rootTag, url.toString(), url.openStream()); Element e = doc.getElementById(targetId); if (e == null){ DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode(ERROR_GET_ELEMENT_BY_ID_FAILED); report.addDescriptionEntry(ENTRY_KEY_ID, targetId); report.setPassed(false); return report; } if (e.getNamespaceURI() == null) { return reportSuccess(); } DefaultTestReport report = new DefaultTestReport(this); report.setErrorCode(report.ERROR_TEST_FAILED); report.setPassed(false); return report; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]