xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steiner, Dominik" <Dominik.Stei...@gigatronik.com>
Subject BridgeException - Cannot find the referenced element + <use> problem
Date Wed, 31 Aug 2005 15:01:14 GMT
Hy there,

 

I'm having a weird error when loading a svg file in my application,
which I designed using the squiggle implementation. In Squiggle there is
no problem, but in my application it gives me this exception:

 

org.apache.batik.bridge.BridgeException: file:/C:/workspace/vergelein
tnc/aaa.svg:33

Cannot find the referenced element:

"#loop"

specified on the element <use> - may be a problem of id

            at
org.apache.batik.bridge.BridgeContext.getReferencedElement(BridgeContext
.java:582)

            at
org.apache.batik.bridge.SVGUseElementBridge.buildCompositeGraphicsNode(S
VGUseElementBridge.java:113)

            at
org.apache.batik.bridge.SVGUseElementBridge.createGraphicsNode(SVGUseEle
mentBridge.java:88)

            at
org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:199
)

            at
org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:161)

            at
org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:77)

            at
org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:95)

 

Here is the svg file

 

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"

   "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd">

 

<svg id="body"

    width="21cm" height="13.5cm"

    viewBox="0 0 210 135">

<title>Example 4</title>

<desc>

    Add polyline; show scaling transformation.

</desc>

<defs>

    <polyline id="loop" points="

         1.00,  0.00     0.93,  0.16

         0.72,  0.26     0.43,  0.25

         0.13,  0.11    -0.11, -0.13

        -0.25, -0.43    -0.26, -0.72

        -0.16, -0.93     0.00, -1.00

         0.16, -0.93     0.26, -0.72

         0.25, -0.43     0.11, -0.13

        -0.13,  0.11    -0.43,  0.25

        -0.72,  0.26    -0.93,  0.16

        -1.00,  0.00"

        transform="scale(5, 5)"

        stroke="green" stroke-width="0.1" fill="none" />

</defs>

    <rect x="10" y="20" width="150" height="70"

        transform="translate(3, 3)"

        fill="#999999" stroke="#999999" stroke-width="1" />

 

    <rect x="10" y="20" width="150" height="70"

        fill="#eeeeff" stroke="red" stroke-width="1" />

 

    <use xlink:href="#loop" transform="translate(20,100)"/>

 

</svg>

 

Beside that problem I'm having a hard time using the <use>-tag...  right
now I create the referenced element in <defs> and the use-tag as
following:

 

    Element refEl = doc.createElementNS(svgNS, SVGConstants.
SVGConstants.SVG_CIRCLE_TAG);

    refEl.setAttributeNS(null, "cx", 0);

    refEl.setAttributeNS(null, "id", "gps");

    // and so on, than later creating the use-tag

    Element useEl = doc.createElementNS(svgNS,
SVGConstants.SVG_USE_TAG);

    useEl.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "xlink:href",
"#gps");

    useEl.setAttributeNS(null, "cx", "30");

 

But this just displays the referenced Element at its original position,
not with the coordinates I gave it in the use tag... any idea?

 

Thanks for all your kind help... :-)

 

Dominik Steiner

    


Mime
View raw message