Hi Cameron / Venkat,
 
As you say the AbstractNode.importNode method initially creates an Attr without a value but then, I think, because the deep flag is true it performs getFirstChild() on the Attr node ( and gets an AbstractParentNode ) it then recurses with this node, this node is handled as a TEXT_NODE and the result (ie. the attribute value) is added to the Attr node.
 
     if (deep) {
            for (Node n = importedNode.getFirstChild();
                 n != null;
                 n = n.getNextSibling()) {
                result.appendChild(importNode(n, true));
            }
        }
        return result;
 
Patrick
 
-----  Original Message-----
From: pegan@gresham-forms.co.uk [mailto:pegan@gresham-forms.co.uk]
Sent: 15 June 2004 16:42
To: batik-users@xml.apache.org
Subject: RE: problem with JPEGTranscoder

Hi Cameron and Venkat,

I'm using 1.5.1.
I misread the code the first time (saw the setAttributeNodeNS but missed the fact the the Attr a was being passed in the recursive call, apologies), now I do not understand how it can be working.

It does still appear to work for me ! I am trying to work out why ?

Patrick



-----Original Message-----
From: Cameron McCormack [mailto:cam-batik-users@aka.mcc.id.au]
Sent: 15 June 2004 14:13
To: batik-users@xml.apache.org
Subject: Re: problem with JPEGTranscoder


Hi Patrick.

pegan@gresham-forms.co.uk:
> I have not noticed any problem with DeepCloneDocument, but because am using
> this method in my code I felt compelled to check it out.
> I may wrong but on having a look it appears to me that
> AbstractDocument.importNode copies the node values at the point it handles
> the ELEMENT_NODE.
> .....
>  case ELEMENT_NODE:
>             Element e = createElementNS(importedNode.getNamespaceURI(),
>                                         importedNode.getNodeName());
>             result = e;
>             if (importedNode.hasAttributes()) {
>                 NamedNodeMap attr = importedNode.getAttributes();
>                 int len = attr.getLength();
>                 for (int i = 0; i < len; i++) {
>                     Attr a = (Attr)attr.item(i);
>                     if (a.getSpecified()) {
>                         e.setAttributeNodeNS((Attr)importNode(a, true));
>                     }
>                 }
>             }
>             break;

I think the problem is that importNode will create a new attribute in
the SVG DOM with the right name but it won't actually set the
attribute's value.  Notice how in importNode the cases for text nodes,
CDATA sections and comments nodes do something to get the to-be-copied
node's value, while for the attributes it doesn't.

<caveat>
  I haven't tested it though, so if the attribute values actually come
  from somewhere else in the code that I haven't noticed, I could be
  wrong.
</caveat>

But you say that it works for you?  What version of Batik are you using?

Cameron

--
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

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


_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com

_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com