I'm having trouble inserting a "use" element into a Document. This is a basic 
drawing application that has a "stamp" tool, and for this stamp I'm using a 
group. When I try to append the use element to the document I get the error 
"The attribute "xlink:href" of the element <use> is required". The xlink:href 
attribute is most certainly present, here is the code that creates the element:

final Element element = getElement();
element.setAttributeNS(SketchPadConstants.SVG_XLINK_NS, X_ATTRIBUTE_NAME, "" + 
origin.getX());
element.setAttributeNS(SketchPadConstants.SVG_XLINK_NS, Y_ATTRIBUTE_NAME, "" + 
origin.getY());
element.setAttributeNS(SketchPadConstants.SVG_XLINK_NS, "xlink:href", 
GROUP_NAME);
.
.
.
document.getDocumentElement().appendChild(element);


If I save the document to the file system after inserting a few of these 
stamps, and then open it, the stamps render without any problems. Could there 
be something that is happening under the covers in the save/open process? What 
am I missing here? Here is how the Document object is saved to the file system 
(how we convert it to a string):

DOMSource domSource = new DOMSource(node);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
try {
     Transformer transformer = tf.newTransformer();
     transformer.transform(domSource, result);
     return writer.toString();
}


and here is how a file is opened (converted from a string to a Document object):

SAXSVGDocumentFactory factory = new 
SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
return factory.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, new 
StringReader(svgXmlDocumentAsString));


Any help would be greatly appreciated!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to