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 Paul Wellner Bou <pa...@purecodes.org> on 2009/06/18 17:56:27 UTC

Duplicated IDs on version=1.2 documents

Hello,

Batik seems to write duplicated IDs if version="1.2" is used in the svg 
root element. I have this svg root:

	<svg xmlns="http://www.w3.org/2000/svg"
		xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2"

And I use batik to read and write out the document without modifications:

     String parser= XMLResourceDescriptor.getXMLParserClassName();
     SAXSVGDocumentFactory f= new SAXSVGDocumentFactory(parser);
     Document doc = f.createDocument(uri);

     SVGGraphics2D svgGenerator= new SVGGraphics2D(doc);
     Writer out= new OutputStreamWriter(new FileOutputStream(outfile)));
     svgGenerator.stream(doc.getDocumentElement(), out);
     out.close();

Regards
Paul.

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


Re: Duplicated IDs on version=1.2 documents

Posted by Helder Magalhães <he...@gmail.com>.
Hi Paul,


> Is there any way to get around this? My problem is mainly the output of the
> SVG. As all operations and so on are working fine after reading the document
> with batik.

Thomas seems to have fixed this in revision 793536 [1]. If you want to
use it you'll need to download and compile the trunk source code [2]
yourself.

If you try with the trunk source code and the problem is still there,
please report back.


> Regards
> Paul.

Hope this helps,
 Helder


[1] http://svn.apache.org/viewvc?view=rev&revision=793536
[2] http://xmlgraphics.apache.org/batik/download.html#Subversion+repository

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


Re: Duplicated IDs on version=1.2 documents

Posted by Paul Wellner Bou <pa...@purecodes.org>.
Hi,

Is there any way to get around this? My problem is mainly the output of 
the SVG. As all operations and so on are working fine after reading the 
document with batik.

> With the current implementation of Batik, it is impossible to parse a 
> serialized SVG 1.2 document containing id attributes, because the parser 
> will complain about the duplicate id attribute.

I am able to parse a 1.2 document containing IDs, at least without 
validating. But I am not able to save the document again without getting 
duplicated IDs.

Regards
Paul.


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


Re: Duplicated IDs on version=1.2 documents

Posted by Daniel Westheide <d....@iplabs.de>.
Hi,

I have stumbled across this before. SVG 1.2 requires that if there is  
an SVG id attribute, there must also be a corresponding id attribute  
in the XML namespace. However, what Batik does is this: If an SVG id  
attribute is set, it automatically sets an id attribute in the XML  
namespace - however, when calling the setAttributeNS method, it uses  
the local name for the id attribute instead of the qualified name (see  
AbstractElement and SVGOMElement).

The correct output of Paul's example would be:

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd' 
 >
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink 
" version="1.2">
	<g id="test" xml:id="test"><text>ANY CONTENT</text></g>
</svg>

This can be achieved by passing the qualified name for the XML id  
attribute ("xml:id") to the setAttributeNS method instead of the local  
name.

With the current implementation of Batik, it is impossible to parse a  
serialized SVG 1.2 document containing id attributes, because the  
parser will complain about the duplicate id attribute.

Best regards,

Daniel 

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


Re: Duplicated IDs on version=1.2 documents

Posted by Paul Wellner Bou <pa...@purecodes.org>.
Hi Thomas,

of course I can. The code shown in the mail before outputs for example 
this (reformatted):

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2">
	<g id="test" id="test"><text>ANY CONTENT</text></g>
</svg>

The input is the same, just with only one id attribute.

Removing version="1.2" solves the problem.

Regards
Paul


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


Re: Duplicated IDs on version=1.2 documents

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

Paul Wellner Bou <pa...@purecodes.org> wrote on 06/18/2009 11:56:27 AM:

> Batik seems to write duplicated IDs if version="1.2" is used in the svg 
> root element. I have this svg root:

   I don't understand the problem.  Can you provide an example
of the problem output?