osdir.com
mailing list archive F.A.Q. -since 2001!



Subject: Re: parseXML and new document. - msg#00050

List: text.xml.batik.devel

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index

Thomas DeWeese wrote:

Jim Ley wrote:

Hi,

With my SVG application, I currently only have 1 issue with Batik 1.5beta 5 serious enough that I need to fork the script to seperate ASV from Batik:

a=parseXML("<xml/>",null)

This works in ASV for creating a new document, however in Batik it produces an error, and you can only produce documentFragments by having the second parameter be the SVG document (which doesn't work properly in ASV, and isn't really neat when you have a standalone document.

Is this simply not yet implemented in Batik, or is it a bug?

So the problem here is that in Java (strongly typed language) parseXML is defined to
return a DocumentFragment. In fact we currently parse the string into it's own document
then import it as a document fragment into the provided Document.

Please remember that this is an 'Adobe extension' (admittedly useful one) so there really is no solid definition of the function, and as usual things are never as easy as they seem.

The issue I ran into was cases like:
a = parseXML("<rect x="10" y="10" width="100" height="50"/>", null);

This can not return an SVG document (root element of an SVG Document must be an
'svg' element), but it could return an SVG fragment. This has implications on the namespace
of the 'rect' element, it will be different if given a base document or not. I think this is 'the
right thing to do' but I wanted to make sure people agree.

If the base document is provided and it is an SVG document then the resulting 'rect'
element will be an svg rect (in the svg namespace) in a Document Fragment. Othewise it
will become the root element of a generic XML document (if doc is null) or a generic
XML Document Fragment (if doc is not an SVG document) and not have any associated
namespace.


Thread at a glance:

Previous Message by Date:

cvs commit: xml-batik/sources/org/apache/batik/dom/svg AbstractSVGPathSegList.java

vhardy 2003/06/30 08:04:44 Modified: test-resources/org/apache/batik/dom unitTesting.xml sources/org/apache/batik/dom/svg AbstractSVGPathSegList.java Added: test-resources/org/apache/batik/dom bug20331.svg Log: Fixed bug 20331. Added new test to the test suite Revision Changes Path 1.12 +2 -1 xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml Index: unitTesting.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/dom/unitTesting.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- unitTesting.xml 30 Jun 2003 12:36:44 -0000 1.11 +++ unitTesting.xml 30 Jun 2003 15:04:44 -0000 1.12 @@ -19,6 +19,7 @@ <testGroup id="ecmaDOM" name="Basic DOM Tests from ECMA Scripts" class="org.apache.batik.dom.EcmaScriptDOMTest"> <test id="bug18143" /> + <test id="bug20331" /> </testGroup> <!-- ========================================================================== --> 1.1 xml-batik/test-resources/org/apache/batik/dom/bug20331.svg Index: bug20331.svg =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ========================================================================= --> <!-- Copyright (C) The Apache Software Foundation. All rights reserved. --> <!-- --> <!-- This software is published under the terms of the Apache Software License --> <!-- version 1.1, a copy of which has been included with this distribution in --> <!-- the LICENSE file. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- --> <!-- @author vincent.hardy@xxxxxxx --> <!-- @version $Id: bug20331.svg,v 1.1 2003/06/30 15:04:44 vhardy Exp $ --> <!-- ========================================================================= --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:test="http://xml.apache.org/batik/test" width="350" height="350" onload="runTest(evt)" > <test:testResult id="testResult" result="failed" code="invalid.path.seg.value"/> <script type="text/ecmascript"><![CDATA[ var testNS = "http://xml.apache.org/batik/test"; var svgNS = "http://www.w3.org/2000/svg"; function runTest() { var result = document.getElementById("testResult"); var path = document.createElementNS(svgNS, "path"); var svgPathSegArcRel = path.createSVGPathSegArcRel(1, 2, 3, 4, 5, false, false); if (svgPathSegArcRel.getR1() != 3 || svgPathSegArcRel.getR2() != 4) { return; } var svgPathSegArcAbs = path.createSVGPathSegArcAbs(1,2,3,4,5,false,false); if (svgPathSegArcAbs.getR1() != 3 || svgPathSegArcAbs.getR2() != 4) { return; } var p = document.getElementById("path"); if (p == null) { return; } var psl = p.pathSegList; if (psl == null) { return; } if (psl.numberOfItems != 3) { result.setAttributeNS(null, "code", "wrong.number.of.path.seg"); return; } var ps = psl.getItem(0); if (ps == null || ps.pathSegType != 2) { result.setAttributeNS(null, "code", "wrong.first.seg.type.0.M.vs." + ps.pathSegType); return; } ps = psl.getItem(1); if (ps == null || ps.pathSegType != 10) { result.setAttributeNS(null, "code", "wrong.first.seg.type.1.A.vs." + ps.pathSegType); return; } if (ps.r1 != 2 || ps.r2 != 3) { result.setAttributeNS(null, "code", "wrong.r1.2.vs." + ps.r1 + " or r2.3.vs." + ps.r2); return; } ps = psl.getItem(2); if (ps == null || ps.pathSegType != 1) { result.setAttributeNS(null, "code", "wrong.first.seg.type.2.Z.vs." + ps.pathSegType); return; } var t = document.getElementById("text"); t.setAttributeNS(null, "fill", "#0F0"); result.setAttributeNS(null, "result", "passed"); } ]]></script> <text id="text" x="50%" y="50%" text-anchor="middle" fill="red">This string is red if test failed, green otherwise</text> <path d="M 0 0 A 2 3 0 0 0 4 5 Z" id="path"/> </svg> 1.4 +2 -2 xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGPathSegList.java Index: AbstractSVGPathSegList.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/svg/AbstractSVGPathSegList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractSVGPathSegList.java 11 Apr 2003 13:56:08 -0000 1.3 +++ AbstractSVGPathSegList.java 30 Jun 2003 15:04:44 -0000 1.4 @@ -533,7 +533,7 @@ SVGPathSegArcRel { public SVGPathSegArcItem(short type,String letter, - float rx,float ry,float angle, + float r1,float r2,float angle, boolean largeArcFlag, boolean sweepFlag, float x, float y ){ super(type,letter);

Next Message by Date:

Re: parseXML and new document.

"Thomas DeWeese" <Thomas.DeWeese@xxxxxxxxx> wrote in message news:3F00585E.2070702@xxxxxxxxxxxx > The issue I ran into was cases like: > a = parseXML("<rect x="10" y="10" width="100" height="50"/>", null); > > If the base document is provided and it is an SVG document then the > resulting 'rect' > element will be an svg rect (in the svg namespace) in a Document > Fragment. Othewise it > will become the root element of a generic XML document (if doc is null) > or a generic > XML Document Fragment (if doc is not an SVG document) and not have any > associated > namespace. I agree with this, although as you note it's an Adobe extension, and I would not be too unhappy if you left of deployment until after SVG 1.2 had defined what it should do (or decided not to, in which case then I'd like to see it :-) Jim.

Previous Message by Thread:

Re: parseXML and new document.

Jim Ley wrote: Hi, With my SVG application, I currently only have 1 issue with Batik 1.5beta 5 serious enough that I need to fork the script to seperate ASV from Batik: a=parseXML("<xml/>",null) This works in ASV for creating a new document, however in Batik it produces an error, and you can only produce documentFragments by having the second parameter be the SVG document (which doesn't work properly in ASV, and isn't really neat when you have a standalone document. Is this simply not yet implemented in Batik, or is it a bug? So the problem here is that in Java (strongly typed language) parseXML is defined to return a DocumentFragment. In fact we currently parse the string into it's own document then import it as a document fragment into the provided Document. So Vincent, Christophe what do you think? Is it ok to change the return type of parseXML so it returns a Node instead of a DocumentFragment? I say yes.

Next Message by Thread:

Re: parseXML and new document.

"Thomas DeWeese" <Thomas.DeWeese@xxxxxxxxx> wrote in message news:3F00585E.2070702@xxxxxxxxxxxx > The issue I ran into was cases like: > a = parseXML("<rect x="10" y="10" width="100" height="50"/>", null); > > If the base document is provided and it is an SVG document then the > resulting 'rect' > element will be an svg rect (in the svg namespace) in a Document > Fragment. Othewise it > will become the root element of a generic XML document (if doc is null) > or a generic > XML Document Fragment (if doc is not an SVG document) and not have any > associated > namespace. I agree with this, although as you note it's an Adobe extension, and I would not be too unhappy if you left of deployment until after SVG 1.2 had defined what it should do (or decided not to, in which case then I'd like to see it :-) Jim.
blog comments powered by Disqus

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too!