xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject RE: Problems with parseXML()
Date Tue, 09 Sep 2008 10:25:43 GMT
Hi Julian,
> I want to parse an XML string with SVG code into a Node object, but I 
> don't have any success. Here's variant one I tried: 

>Node n = 
svgCanvas.getUpdateManager().getScriptingEnvironment().getWindow().parseXML 

>         ("<use xlink:href=\"#QuestionMark\" overflow=\"visible\" 
width=\"10.512\" height=\"6.273\" x=\"5\" y=\"10\" />", 
svgCanvas.getSVGDocument()); 

> wich returns null. 

    Does it return null or are some of the intermediate things NULL?

> HashMap<String,String> map = new HashMap<String,String>(); 
> map.put("xlink", "http://www.w3.org/1999/xlink"); 

    Your code to initialize the prefix map should look like that in
parseXML:
                Map prefixes = new HashMap();
                prefixes.put(XMLConstants.XMLNS_PREFIX,
                        XMLConstants.XMLNS_NAMESPACE_URI);
                prefixes.put(XMLConstants.XMLNS_PREFIX + ':'
                        + XMLConstants.XLINK_PREFIX,
                        XLinkSupport.XLINK_NAMESPACE_URI);
                res = DOMUtilities.parseXML(text, doc, uri, prefixes,
                        SVGConstants.SVG_SVG_TAG, df);

> Node n = DOMUtilities.parseXML("<use xlink:href=\"#QuestionMark\" 
overflow=\"visible\" width=\"10.512\" height=\"6.273\" x=\"5\" y=\"10\" 
/>", doc, svgFile.toURI().toString(), map, "g", documentFactory); 

     You should also wrap things in an 'svg' element.

     I don't see anything obvious wrong and since I think your first 
parseXML 
call should work I think you will need to add some debugging code to
Batik to figure out what is happening.  I would suggest printing any
exception in DOMUtilities.parseXML (right at the end it eats any
exceptions from parsing the fragment and importing it).

Mime
View raw message