xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gold Martin <Martin.G...@blva.bayern.de>
Subject error with attribute 'xlink:href' when loading a raster image
Date Tue, 14 Oct 2003 16:58:50 GMT
hello,

I have written an Interactor to load raster images into the canvas.
When I click into the SVG-Canvas to load the raster image I get the
following error message:
The attribute 'xlink:href' of the element <image> is required


The header of my SVG-file looks like this:
<?xml version='1.0' standalone='no'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd'>
<svg contentScriptType="text/ecmascript" width="700"
     xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify"
     contentStyleType="text/css" viewBox="4280000 -5620000 350000 400000"
     height="700" preserveAspectRatio="xMidYMid meet"
     xmlns="http://www.w3.org/2000/svg" version="1.0">
     ...


The code in the update queue of my interactor to show the raster image looks
like that:
    public void mousePressed(MouseEvent e) {
        final JSVGCanvas svgCanvas = (JSVGCanvas) e.getSource();          
        
        beendet = true;
        if ((e.getModifiers() & java.awt.event.InputEvent.BUTTON1_MASK) !=
0)
        {
            try {
 
svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(
            new Runnable() {
               public void run() {
 
svgCanvas.setRenderingTransform(svgCanvas.getRenderingTransform());  
                  
                  final Document document = svgCanvas.getSVGDocument();
                  final Element svgRoot = document.getDocumentElement();
                  final String svgNS =
SVGDOMImplementation.SVG_NAMESPACE_URI;  
                  
                  Element gruppe = document.createElementNS(svgNS, "g"); 
                  gruppe.setAttributeNS(null, "id", svgCanvas.RASTER_ID);
                  gruppe.setAttributeNS(null, "transform", new String
("translate(4350366.25,-5365852.82)"));
                  gruppe.setAttributeNS(null, "visibility", "visible");
                  svgRoot.appendChild(gruppe);
                  Element image = document.createElementNS(svgNS, "image"); 
                  image.setAttributeNS(null, "xlink:href",
"resources/l7726col.gif");   
                  image.setAttributeNS(null, "x", new String ("0"));
                  image.setAttributeNS(null, "y", new String ("0"));
                  image.setAttributeNS(null, "width", "28117.8");
                  image.setAttributeNS(null, "height","26035.0");    
                  gruppe.appendChild(image);        
              }
            }); 
            } catch (Exception ex) {
                   ex.printStackTrace();
            }
        }
    }


You can see the xlink namespace in my document is declared.
So why do I get this error message ?
What I'm doing wrong ?

Best regards and thanks for your help,
Martin


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


Mime
View raw message