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 André Rüdiger <an...@web.de> on 2007/08/30 18:08:50 UTC

BridgeContext problem with internal links

Hello Batik list!

I am currently dealing with a BridgeContext problem in Batik. Maybe
someone could look into that.

To generate the SVG I am doing the following:

final DOMImplementation svgDomImpl = SVGDOMImplementation
        .getDOMImplementation();
final Document ret = svgDomImpl.createDocument(
        SVGDOMImplementation.SVG_NAMESPACE_URI, SVG_ROOT, null);
final SVGGeneratorContext ctx = SVGGeneratorContext
        .createDefault(ret);

SVGGraphics2D g = new SVGGraphics2D(ctx, false);
g.setSVGCanvasSize(new Dimension((int) bounds.getWidth(),
        (int) bounds.getHeight()));

// paint something

g.getRoot(ret.getDocumentElement());
g.dispose(); erzeugt in " + delay + "[s].");
}

 // has no impact:
ret.getDocumentElement().setAttributeNS(
        SVGDOMImplementation.SVG_NAMESPACE_URI, "xmlns:xlink",
        XLinkSupport.XLINK_NAMESPACE_URI);
return ret;


When I then try to render the output I am hitting an Exception:

Cannot find the referenced element:
"file:/[Path/to/Java/Class/File/Directory]#clipPath1"
specified on the element <path> - may be a problem of id -
org.apache.fop.render.java2d.Java2DSVGHandler.renderSVGDocument(Java2DSVGHandler.java:135)
org.apache.batik.bridge.BridgeException:
file:/[Path/to/Java/Class/File/Directory]:-1
Cannot find the referenced element:
"file:/[Path/to/Java/Class/File/Directory]#clipPath1"
specified on the element <path> - may be a problem of id
	at org.apache.batik.bridge.BridgeContext.getReferencedElement(Unknown Source)
	at org.apache.batik.bridge.CSSUtilities.convertClipPath(Unknown Source)
	at org.apache.batik.bridge.AbstractGraphicsNodeBridge.buildGraphicsNode(Unknown
Source)
	at org.apache.batik.bridge.SVGShapeElementBridge.buildGraphicsNode(Unknown
Source)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source)
	at org.apache.batik.bridge.GVTBuilder.build(Unknown Source)


While the output contains something like this (shortened):

<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" color-interpolation="auto"
color-rendering="auto" fill="black" fill-opacity="1"
font-family="'sansserif'" font-size="12" font-style="normal"
font-weight="normal" height="714" image-rendering="auto"
shape-rendering="auto" stroke="black" stroke-dasharray="none"
stroke-dashoffset="0" stroke-linecap="square" stroke-linejoin="miter"
stroke-miterlimit="10" stroke-opacity="1" stroke-width="1"
text-rendering="auto" width="535">
  <defs id="genericDefs"/>
  <g>
    <defs id="defs1">
      <clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
        <path d="M-274.9927673339844 2540.350341796875
L434.2093811035156 2540.350341796875 L434.2093811035156
3486.8369140625 L-274.9927673339844 3486.8369140625
L-274.9927673339844 2540.350341796875 Z"/>
      </clipPath>
      <!-- more clipPaths -->
    </defs>
    <g fill="rgb(216,216,216)" stroke="rgb(216,216,216)"
stroke-width="0.6628057360649"
transform="matrix(0.7543688371203,0,0,-0.7543688371203,207.445974110225,2630.3612127404385)">
      <path clip-path="url(#clipPath1)" d="M-164.5249938964844 0
L434.2093811035156 0 M-164.5249938964844 20 L434.2093811035156 20
M-164.5249938964844 40 L434.2093811035156 40 M-164.5249938964844 60
L434.2093811035156 60 M-164.5249938964844 80 L434.2093811035156 80
M-164.5249938964844 100 L434.2093811035156 100 M-164.5249938964844 120
L434.2093811035156 120 M-164.5249938964844 140 L434.2093811035156 140
M-164.5249938964844 160 L434.2093811035156 160 M-164.5249938964844 180
L434.2093811035156 180 M-164.5249938964844 200 L434.2093811035156 200
M-164.5249938964844 220 L434.2093811035156 220 M-164.5249938964844 240
L434.2093811035156 240 M-164.5249938964844 260 L434.2093811035156 260
M-164.5249938964844 280 L434.2093811035156 280 M-164.5249938964844 300
L434.2093811035156 300 M-164.5249938964844 320 L434.2093811035156 320
M-164.5249938964844 340 L434.2093811035156 340 M-164.5249938964844 360
L434.2093811035156 360 M-164.5249938964844 380 L434.2093811035156 380
M-164.5249938964844 400 L434.2093811035156 400 M-164.5249938964844 420
L434.2093811035156 420 M-164.5249938964844 440 L434.2093811035156 440
M-164.5249938964844 460 L434.2093811035156 460 M-164.5249938964844 480
L434.2093811035156 480 M-164.5249938964844 500 L434.2093811035156 500
M-164.5249938964844 520 L434.2093811035156 520 M-164.5249938964844 540
L434.2093811035156 540 M-164.5249938964844 560 L434.2093811035156 560
M-164.5249938964844 580 L434.2093811035156 580 M-164.5249938964844 600
L434.2093811035156 600 M-164.5249938964844 620 L434.2093811035156 620
M-164.5249938964844 640 L434.2093811035156 640 M-164.5249938964844 660
L434.2093811035156 660 M-164.5249938964844 680 L434.2093811035156 680
M-164.5249938964844 700 L434.2093811035156 700 M-164.5249938964844 720
L434.2093811035156 720 M-164.5249938964844 740 L434.2093811035156 740
M-164.5249938964844 760 L434.2093811035156 760 M-164.5249938964844 780
L434.2093811035156 780 M-164.5249938964844 800 L434.2093811035156 800
M-164.5249938964844 820 L434.2093811035156 820 M-164.5249938964844 840
L434.2093811035156 840 M-164.5249938964844 860 L434.2093811035156 860
M-164.5249938964844 880 L434.2093811035156 880 M-164.5249938964844 900
L434.2093811035156 900 M-164.5249938964844 920 L434.2093811035156 920
M-164.5249938964844 940 L434.2093811035156 940 M-164.5249938964844 960
L434.2093811035156 960 M-164.5249938964844 980 L434.2093811035156 980
M-164.5249938964844 1000 L434.2093811035156 1000 M-164.5249938964844
1020 L434.2093811035156 1020 M-164.5249938964844 1040
L434.2093811035156 1040 M-164.5249938964844 1060 L434.2093811035156
1060 M-164.5249938964844 1080 L434.2093811035156 1080
M-164.5249938964844 1100 L434.2093811035156 1100 M-164.5249938964844
1120 L434.2093811035156 1120 M-164.5249938964844 1140
L434.2093811035156 1140 M-164.5249938964844 1160 L434.2093811035156
1160 M-164.5249938964844 1180 L434.2093811035156 1180
M-164.5249938964844 1200 L434.2093811035156 1200 M-164.5249938964844
1220 L434.2093811035156 1220 M-164.5249938964844 1240
L434.2093811035156 1240 M-164.5249938964844 1260 L434.2093811035156
1260 M-164.5249938964844 1280 L434.2093811035156 1280
M-164.5249938964844 1300 L434.2093811035156 1300 M-164.5249938964844
1320 L434.2093811035156 1320 M-164.5249938964844 1340
L434.2093811035156 1340 M-164.5249938964844 1360 L434.2093811035156
1360 M-164.5249938964844 1380 L434.2093811035156 1380
M-164.5249938964844 1400 L434.2093811035156 1400 M-164.5249938964844
1420 L434.2093811035156 1420 M-164.5249938964844 1440
L434.2093811035156 1440 M-164.5249938964844 1460 L434.2093811035156
1460 M-164.5249938964844 1480 L434.2093811035156 1480
M-164.5249938964844 1500 L434.2093811035156 1500 M-164.5249938964844
1520 L434.2093811035156 1520 M-164.5249938964844 1540
L434.2093811035156 1540 M-164.5249938964844 1560 L434.2093811035156
1560 M-164.5249938964844 1580 L434.2093811035156 1580
M-164.5249938964844 1600 L434.2093811035156 1600 M-164.5249938964844
1620 L434.2093811035156 1620 M-164.5249938964844 1640
L434.2093811035156 1640 M-164.5249938964844 1660 L434.2093811035156
1660 M-164.5249938964844 1680 L434.2093811035156 1680
M-164.5249938964844 1700 L434.2093811035156 1700 M-164.5249938964844
1720 L434.2093811035156 1720 M-164.5249938964844 1740
L434.2093811035156 1740 M-164.5249938964844 1760 L434.2093811035156
1760 M-164.5249938964844 1780 L434.2093811035156 1780
M-164.5249938964844 1800 L434.2093811035156 1800 M-164.5249938964844
1820 L434.2093811035156 1820 M-164.5249938964844 1840
L434.2093811035156 1840 M-164.5249938964844 1860 L434.2093811035156
1860 M-164.5249938964844 1880 L434.2093811035156 1880
M-164.5249938964844 1900 L434.2093811035156 1900 M-164.5249938964844
1920 L434.2093811035156 1920 M-164.5249938964844 1940
L434.2093811035156 1940 M-164.5249938964844 1960 L434.2093811035156
1960 M-164.5249938964844 1980 L434.2093811035156 1980
M-164.5249938964844 2000 L434.2093811035156 2000 M-164.5249938964844
2020 L434.2093811035156 2020 M-164.5249938964844 2040
L434.2093811035156 2040 M-164.5249938964844 2060 L434.2093811035156
2060 M-164.5249938964844 2080 L434.2093811035156 2080
M-164.5249938964844 2100 L434.2093811035156 2100 M-164.5249938964844
2120 L434.2093811035156 2120 M-164.5249938964844 2140
L434.2093811035156 2140 M-164.5249938964844 2160 L434.2093811035156
2160 M-164.5249938964844 2180 L434.2093811035156 2180
M-164.5249938964844 2200 L434.2093811035156 2200 M-164.5249938964844
2220 L434.2093811035156 2220 M-164.5249938964844 2240
L434.2093811035156 2240 M-164.5249938964844 2260 L434.2093811035156
2260 M-164.5249938964844 2280 L434.2093811035156 2280
M-164.5249938964844 2300 L434.2093811035156 2300 M-164.5249938964844
2320 L434.2093811035156 2320 M-164.5249938964844 2340
L434.2093811035156 2340 M-164.5249938964844 2360 L434.2093811035156
2360 M-164.5249938964844 2380 L434.2093811035156 2380
M-164.5249938964844 2400 L434.2093811035156 2400 M-164.5249938964844
2420 L434.2093811035156 2420 M-164.5249938964844 2440
L434.2093811035156 2440 M-164.5249938964844 2460 L434.2093811035156
2460 M-164.5249938964844 2480 L434.2093811035156 2480
M-164.5249938964844 2500 L434.2093811035156 2500 M-164.5249938964844
2520 L434.2093811035156 2520 M-164.5249938964844 2540
L434.2093811035156 2540 M-164.5249938964844 2560 L434.2093811035156
2560 M-164.5249938964844 2580 L434.2093811035156 2580
M-164.5249938964844 2600 L434.2093811035156 2600 M-164.5249938964844
2620 L434.2093811035156 2620 M-164.5249938964844 2640
L434.2093811035156 2640 M-164.5249938964844 2660 L434.2093811035156
2660 M-164.5249938964844 2680 L434.2093811035156 2680
M-164.5249938964844 2700 L434.2093811035156 2700 M-164.5249938964844
2720 L434.2093811035156 2720 M-164.5249938964844 2740
L434.2093811035156 2740 M-164.5249938964844 2760 L434.2093811035156
2760 M-164.5249938964844 2780 L434.2093811035156 2780
M-164.5249938964844 2800 L434.2093811035156 2800 M-164.5249938964844
2820 L434.2093811035156 2820 M-164.5249938964844 2840
L434.2093811035156 2840 M-164.5249938964844 2860 L434.2093811035156
2860 M-164.5249938964844 2880 L434.2093811035156 2880
M-164.5249938964844 2900 L434.2093811035156 2900 M-164.5249938964844
2920 L434.2093811035156 2920 M-164.5249938964844 2940
L434.2093811035156 2940 M-164.5249938964844 2960 L434.2093811035156
2960 M-164.5249938964844 2980 L434.2093811035156 2980
M-164.5249938964844 3000 L434.2093811035156 3000 M-164.5249938964844
3020 L434.2093811035156 3020 M-164.5249938964844 3040
L434.2093811035156 3040 M-164.5249938964844 3060 L434.2093811035156
3060 M-164.5249938964844 3080 L434.2093811035156 3080
M-164.5249938964844 3100 L434.2093811035156 3100 M-164.5249938964844
3120 L434.2093811035156 3120 M-164.5249938964844 3140
L434.2093811035156 3140 M-164.5249938964844 3160 L434.2093811035156
3160 M-164.5249938964844 3180 L434.2093811035156 3180
M-164.5249938964844 3200 L434.2093811035156 3200 M-164.5249938964844
3220 L434.2093811035156 3220 M-164.5249938964844 3240
L434.2093811035156 3240 M-164.5249938964844 3260 L434.2093811035156
3260 M-164.5249938964844 3280 L434.2093811035156 3280
M-164.5249938964844 3300 L434.2093811035156 3300 M-164.5249938964844
3320 L434.2093811035156 3320 M-164.5249938964844 3340
L434.2093811035156 3340 M-164.5249938964844 3360 L434.2093811035156
3360 M-164.5249938964844 3380 L434.2093811035156 3380
M-164.5249938964844 3400 L434.2093811035156 3400 M-164.5249938964844
3420 L434.2093811035156 3420 M-164.5249938964844 3440
L434.2093811035156 3440 M-164.5249938964844 3460 L434.2093811035156
3460 M-164.5249938964844 3480 L434.2093811035156 3480" fill="none"/>
      <!-- more Paths -->
    </g>
  </g>
</svg>

The Problem seems to be that "url(#clipPath1)" doesn't link to the
corresponding xml element inside the document but tries to resolve to
"file:/[Path/to/Java/Class/File/Directory]#clipPath1".

Is this behaviour adjustable or am I simply missing something?

Thanks in advance for your kind help which is highly appreciated.

Cheers,
André

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: BridgeContext problem with internal links

Posted by th...@kodak.com.
Hi Andre,

andre.ruediger@googlemail.com wrote on 08/30/2007 12:08:50 PM:

>  // has no impact:
> ret.getDocumentElement().setAttributeNS(
>         SVGDOMImplementation.SVG_NAMESPACE_URI, "xmlns:xlink",
>         XLinkSupport.XLINK_NAMESPACE_URI);

   This is incorrect, it should be 
batik.util.XMLConstants.XMLNS_NAMESPACE_URI for the namespace.

> When I then try to render the output I am hitting an Exception:
> 
> Cannot find the referenced element:
> "file:/[Path/to/Java/Class/File/Directory]#clipPath1"
> specified on the element <path> - may be a problem of id -

> The Problem seems to be that "url(#clipPath1)" doesn't link to the
> corresponding xml element inside the document but tries to resolve to
> "file:/[Path/to/Java/Class/File/Directory]#clipPath1".
> 
> Is this behaviour adjustable or am I simply missing something?

   It looks like someone is setting the base URL of the document
to "File:/[Path/to/Java/Class/File/Directory]".  Our code should
work if the base URL of the document is null, or point to a
semi-real location.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org