Hello Thomas,
Here is the whole code from the walk method:
public void walk(Node rootNode, NodeVisitor visitor) {
if (rootNode == null || rootNode.getChildNodes().getLength() == 0) {
return;
}
NodeList nodes = rootNode.getChildNodes();
for (int i = 0;i < nodes.getLength(); i++) {
Node node = nodes.item(i);
boolean isVisitable = true;
if (isValidTextNode(node)) {
NodeList childNodes = node.getChildNodes();
for (int j = 0;j < childNodes.getLength();j++) {
Node child = childNodes.item(j);
if (isTSpanNode(child)) { // print value.........
}
}
visitor.visitTextNode(node);
} else if (isGNode(node)) {
Element n = (Element) node;
String gAttrIdName = n.getAttribute(SVGOMDocument.ATTR_ID);
visitor.visitGNode(node);
// empty groups shold be translated too
if (translateEmptyGroups == true) {
visitor.visitGNode(node);
} else if (null != gAttrIdName || !"".equals(gAttrIdName))
{ // group is not empty
visitor.visitGNode(node);
} else {
isVisitable = false;
}
}
if (isVisitable) {
walk(node, visitor);
}
}
Note that there are no any additional inserts or movements of the
nodes. Just walking through the tree. About the ordering probably this is a
typing mistake. I made another test with similar xml. This is the result
from the application:
<text stroke="blue" font-size="20" transform="matrix(1 0 0 1 20
40)">QUICK
<tspan dy="20">BROWN</tspan>
<tspan y="20">FOX</tspan>
<tspan dy="20">JUMPS</tspan>
<tspan y="60">OVER</tspan>
<tspan dy="0">THE LAZY</tspan>
</text>
My Program prints:
BROWN
JUMPS
THE LAZY
FOX
OVER
It seems that there is some attribute sorting - first are all elements with
dy attribute and then are these with y. Any idea where is the problem ?
Thanks in advance
thomas.deweese wrote:
>
>
>
> 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'.
>
--
View this message in context:
http://www.nabble.com/SVGOMDocument-and-getChildNodes-ordering-tp21254983p21266183.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]