You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Reinhard Brandstädter <r....@gmx.at> on 2003/08/19 11:13:26 UTC
invalid URI '' on
Hi,
i was trying to generate a <use> element in a Document displayed in a
JSVGCanvas via the UpdateManager, but got a Batik exception
org.apache.batik.bridge.BridgeException: null:0
The URI '' specified on the element <use> is invalid
jSVGCanvas1.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC);
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
doc = (SVGDocument)impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(svgNS, "overflow", "visible");
svgRoot.setAttributeNS(svgNS, "width", "800");
svgRoot.setAttributeNS(svgNS, "height", "600");
// static symbols
Element defs = doc.createElementNS(svgNS, "defs");
Element symbol = doc.createElementNS(svgNS,"symbol");
symbol.setAttributeNS(svgNS,"id","processor");
symbol.setAttributeNS(svgNS,"viewbox","0 0 40 40");
Element rect = doc.createElementNS(svgNS,"rect");
rect.setAttributeNS(svgNS,"x","0");
rect.setAttributeNS(svgNS,"y","0");
rect.setAttributeNS(svgNS,"width","40");
rect.setAttributeNS(svgNS,"height","40");
rect.setAttributeNS(svgNS,"fill","rgb(102,102,102)");
Element text = doc.createElementNS(svgNS,"text");
text.setAttributeNS(svgNS,"x","2");
text.setAttributeNS(svgNS,"y","18");
text.setAttributeNS(svgNS,"font-family","Arial Black");
text.setAttributeNS(svgNS,"font-size","12");
text.setAttributeNS(svgNS,"fill","rgb(0,174,0)");
text.appendChild(doc.createTextNode("AMD"));
symbol.appendChild(rect);
symbol.appendChild(text);
defs.appendChild(symbol);
doc.getRootElement().appendChild(defs);
jSVGCanvas1.setSVGDocument(doc);
jScrollPane1.getViewport().add(jSVGCanvas1, null);
a button pressed event invokes this:
jSVGCanvas1.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
Runnable() {
public void run() {
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Element processor = doc.createElementNS(svgNS, "use");
processor.setAttributeNS(svgNS, "x", "50");
processor.setAttributeNS(svgNS, "y", "50");
processor.setAttributeNS(svgNS, "xlink:href", "#processor");
doc.getRootElement().appendChild(processor);
}
});
Which results in the above exception (URI '')
Dumping the Document to file results in a valid and correct graphic
which i could verify with Squiggle.
I know the document is transformed again when writing out, but I still
can't explain how to make use of the <use> element in this way.
I also tried loading a SVG Document which contains the <defs> section
and then adding the <use> element dynamically, but the same exception is
thrown.
kr,
Reinhard
--
Reinhard Brandstaedter r.brandstaedter@gmx.at GPG: 0x033B81DB
- Student of Computer Science - J.K. University of Linz -
- <ICQ: 73059068> <Mobile: +43 699 12419541> -
- http://adelaide.dnsalias.net -
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: invalid URI '' on
Posted by Thomas DeWeese <Th...@Kodak.com>.
> Sorry for posting this, I just found a hint in the FAQ which I missed
> before. Of course it's the xlink Namespace I have to use for the
> attribute "xlink:href" of the <use> element.
Did you notice that the other SVG attributes are in the 'null'
namespace not the 'SVG' namespace:
>> processor.setAttributeNS(null, "x", "50");
>> processor.setAttributeNS(null, "y", "50");
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: invalid URI '' on
Posted by Reinhard Brandstädter <r....@gmx.at>.
> jSVGCanvas1.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> public void run() {
> String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
> Element processor = doc.createElementNS(svgNS, "use");
> processor.setAttributeNS(svgNS, "x", "50");
> processor.setAttributeNS(svgNS, "y", "50");
> processor.setAttributeNS(xlinkNS, "xlink:href", "#processor");
> doc.getRootElement().appendChild(processor);
> }
> });
>
>
> Which results in the above exception (URI '')
> Dumping the Document to file results in a valid and correct graphic
> which i could verify with Squiggle.
Sorry for posting this, I just found a hint in the FAQ which I missed
before. Of course it's the xlink Namespace I have to use for the
attribute "xlink:href" of the <use> element.
--
Reinhard Brandstaedter r.brandstaedter@gmx.at GPG: 0x033B81DB
- Student of Computer Science - J.K. University of Linz -
- <ICQ: 73059068> <Mobile: +43 699 12419541> -
- http://adelaide.dnsalias.net -
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org