The subject says it all already ... as time went on, we not only need to read any attribute as specified in the XML (again, many thanks for making that possible at all!), but also do some magic tricks with the Element. It's already stored there, so I figured the easiest would be to extend InkscapeNonGeometricData. Proposed patch appended (against latest svn, InkscapeNonGeometricData.java). Incidentally, this also includes an NPE fix.
Code:
Index: InkscapeNonGeometricData.java
===================================================================
--- InkscapeNonGeometricData.java (revision 1106)
+++ InkscapeNonGeometricData.java (working copy)
@@ -4,23 +4,25 @@
import org.w3c.dom.Element;
/**
- * A custom non-geometric data type that can pass back any attribute
- * on the field.
+ * A custom non-geometric data type that can pass back any attribute on the field.
*
* @author kevin
*/
public class InkscapeNonGeometricData extends NonGeometricData {
/** The element read from the SVG */
private Element element;
-
+
/**
* Create a new non-geometric data holder
*
- * @param metaData The metadata provided
- * @param element The XML element from the SVG document
+ * @param metaData
+ * The metadata provided
+ * @param element
+ * The XML element from the SVG document
*/
public InkscapeNonGeometricData(String metaData, Element element) {
super(metaData);
+ this.element = element;
}
/**
@@ -31,8 +33,16 @@
if (result == null) {
result = element.getAttribute(attribute);
}
-
+
return result;
}
+ /**
+ * Returns the XML element that is wrapped by this instance.
+ *
+ * @return The XML element for this instance
+ */
+ public Element getElement() {
+ return element;
+ }
}