Hi Loicrollus,

[EMAIL PROTECTED] wrote on 04/16/2007 05:50:55 AM:

> First, sorry for my english ;)

    Your English is fine.
> 
> But I need to change that. The document "a" (basic) must be the 
> document object of my batik software:
> -----------------------------CODE-----------------------------
> Document a = svgCanvas.getSVGDocument();
> --------------------------------------------------------------
> 
> But it doesent work if I use it when 
> -----------------------------CODE-----------------------------
> Element a1 = (Element)a.getDocumentElement().getFirstChild();
> // java.lang.ClassCastException: org.apache.batik.dom.GenericText

   This is because typically the first child of the document is
not the root element of the document it's text XML processing
instructions etc...

> This line works:
> -----------------------------CODE-----------------------------
> Element root = (Element)a.getDocumentElement(); //root has tag name: 
"svg"
> --------------------------------------------------------------
> 
> But
> -----------------------------CODE-----------------------------
> Node a1 = root.getFirstChild();
> System.out.println(a1.getChildNodes().getLength()); //=>0
> --------------------------------------------------------------
> I don't understand why he gaves me 0...Element <g id="1" ...> has a 
> more than 0 node! 

   Because the first child of the Root element is most likely 
the whitespace from the end of the opening 'g' tag to
the start of the tag for the first element.  You need to 
filter the children based on the Node Type, to avoid the
Text nodes you don't care about (the TextNodes are important
for things like, well 'text').

> When I save de document "a" in a file I have:
[...]
> <g id="1" transform="matrix(1 0 0 -1 0 0)">
> <g id="101">

   The Whitespace consists of a single 'newline' in this case.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to