Hi Mgenov,
mgenov <[email protected]> wrote on 01/03/2009 03:50:09 AM:
> For walking through all nodes I made a NodeWallker of the svg document
I
> made this class. This class has a walk method which traverses the whole
tree
> and asks the visitor class to do something over some of the nodes. ( In
my
> case these nodes should be tspan and text nodes. ).
> And here is the code which I'm using for the retrieving of all tspan
> nodes:
> NodeList childNodes = node.getChildNodes();
> for (int j = 0;j < childNodes.getLength();j++) {
> Node childNode = childNodes.item(j);
> if (isTSpanNode(childNode)) {
Is your walker method moving the children around the child list
for the parent? The DOM specifies that getChildNodes
returns a 'live' list of node children so that modifications to
the children list is immediately visible:
http://www.w3.org/TR/DOM-Level-2-Core/core.html#td-live
This would mostly explain the odd ordering of children
you see: 2 4 6 3 5
Two is the first tspan, When it is removed/moved the
second child is '4' (since '3' became the first), then
'6' is the third child ('3', '5', '6'). I'm not so sure
how you wind up with the '3' and '5'.
> Hope that this information will help. If you thing that the
information
> shown above is not enough, please let me know and I'll try to explain
the
> situation in better way.
>
>
> Archie Cobbs-3 wrote:
> >
> > I've never heard of this happening... they should always be returned
in
> > proper order.
> >
> > There's may be something wrong with how you're accessing the child
nodes.
> > What does your loop look like?
> >
> > -Archie
> >
> > On Fri, Jan 2, 2009 at 12:09 PM, mgenov <[email protected]> wrote:
> >
> >>
> >> Hello guys,
> >> I'm encountering problem with the ordering of the tspan nodes in an
svg
> >> document. I have a document with text node and several child nodes of
> >> type
> >> tspan. My svg file looks similar to this one:
> >>
> >> <text stroke="blue" font-size="20" transform="matrix(1 0 0 1 20
40)">1
> >>
> >> <tspan dy="20">2</tspan>
> >>
> >> <tspan y="20">3</tspan>
> >>
> >> <tspan dy="20">4</tspan>
> >>
> >> <tspan y="60">5</tspan>
> >>
> >> <tspan dy="0">6</tspan>
> >>
> >> </text>
> >>
> >> The problem is that when I get all child nodes of the text node, the
> >> resulted order is: 2 4 6 3 5. Does anyone know how can I get the same
> >> order
> >> as it is in the svg file?
> >>
> >> Thanks in advance.
> >> --
> >> View this message in context:
> >> http://www.nabble.com/SVGOMDocument-and-getChildNodes-ordering-
> tp21254983p21254983.html
> >> Sent from the Batik - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
[email protected]
> >> For additional commands, e-mail:
[email protected]
> >>
> >>
> >
> >
> > --
> > Archie L. Cobbs
> >
> >
>
> --
> View this message in context: http://www.nabble.com/SVGOMDocument-
> and-getChildNodes-ordering-tp21254983p21263112.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>