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 Jorg Heymans <jh...@domek.be> on 2005/03/16 13:39:29 UTC

Re: namespace woes - simplification

Say i create an element "A" using getSVGDocument.createElementNS() and 
then append a bunch of other nodes "B" (from a different document) to 
this element. Now i want to append some parts of "B" to the main 
document, is it necessary to import the parts into the main document 
first or are they considered imported already because they hang off an 
element that was created from the main document.

I am trying to avoid having to import (and thus clone) the nodes for 
performance reasons, hence this setup.


sorry for continuously replying to my own posts, i am just trying to a 
deeper understanding of something obviously not so trivial.

Any pointers?
Jorg


Jorg Heymans wrote:
> i just switched to xerces 2.6.2, it didn't help so my suspicion about 
> namespaces seem to be correct.
> 
> Batik is rightfully ignoring any element that is not created with the 
> SVG namespace. But i do create a text document with correct prefixes 
> everywhere, and i made sure the client parser sees them (debugging the 
> contenthandler i can see that every startelement() has the correct URI 
> with it).
> 
> Could the transformerfactory maybe drop them ? I create it as following:
> 
> SAXTransformerFactory factory = TransformerFactory.newInstance();
> TransformerHandler handler = factory.newTransformerHandler();
> handler.setResult(new DOMResult(parentnode)) -> parent node is the 
> element i created from the SVGDoc
> 
> I hope these snippets make sense.
> 
> Regards
> Jorg
> 
> 
> Jorg Heymans wrote:
> 
>> Hi,
>>
>> I am having a problem getting my canvas updates to appear. I know the 
>> common pitfalls and i think i avoided them, hence my post.
>>
>> Here is what i am doing
>> - a servlet creates a stream of xml data, parts of this xml data is 
>> used to build the SVG document, other parts not. I made sure that the 
>> servlet declares the namespace prefixes at the begining of the doc, 
>> and that all elements (not the attributes) used for the SVG doc have 
>> the svg namespace prefix.
>> - a client canvas retrieves this stream and does the following
>>  1)create a reader using crimson's o.a.crimson.parser.XMLReaderImpl, 
>> making sure it has namespace and namespaceprefix support
>>  2)setup a content handler that uses a SAX to DOM transformer
>>  3)parse the stream using the content handler, resulting in a DOM tree 
>> of the SAX stream.
>>
>>  The content handler appends the parsed nodes to an element that is 
>> created from the current active SVGDocument (thus avoiding having to 
>> import and clone them afterwards).
>>
>> I then move the newly created elements from this element to the 
>> relevant nodes in the SVGDocument (in the canvasmgr update thread). 
>> The updates aren't showing for some reason. But if i dump the updated 
>> svg doc to a file and load it into squiggle it shows up fine :(
>>
>>
>> I believe there are namespace issues involved here, either i don't set 
>> it correctly or batik does not see it. What can i do to debug this?
>>
>> Regards
>> Jorg


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


Re: namespace woes - simplification

Posted by Thomas DeWeese <Th...@Kodak.com>.
Jorg Heymans wrote:

> Say i create an element "A" using getSVGDocument.createElementNS() and 
> then append a bunch of other nodes "B" (from a different document) to 
> this element. 

    You shouldn't be allowed to do this.  If "A" and "B" have
different ownerDocuments then an exception should be raised
when you append nodes from "B".  I don't think this is the
real issue in your other post as I suspect that when you
give the element from "A" to the DOMResult it uses the
ownerDocument of A as a factor to create the new nodes.

> Now i want to append some parts of "B" to the main 
> document, is it necessary to import the parts into the main document 
> first or are they considered imported already because they hang off an 
> element that was created from the main document.

    Any time nodes move from one document to another (in DOM 2)
they must be imported and cloned.

> I am trying to avoid having to import (and thus clone) the nodes for 
> performance reasons, hence this setup.

    I suspect that you are going through a lot of work for nothing.
In my experience the clone time is a very small % of the total time
so eliminating it saves you almost nothing.

> sorry for continuously replying to my own posts, i am just trying to a 
> deeper understanding of something obviously not so trivial.



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