You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/08/04 23:09:18 UTC
[Bug 56814] New: Investigate switching from Dom4J to Javax.XML
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Bug ID: 56814
Summary: Investigate switching from Dom4J to Javax.XML
Product: POI
Version: 3.11-dev
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: OPC
Assignee: dev@poi.apache.org
Reporter: apache@gagravarr.org
When the OPC code was first added, it only required Java 1.4, so needed
external XML jars in the form of stax-api and dom4j. Now that we're on Java
1.6, we've already been able to drop the stax-api jar. It may also be possible
to drop the dom4j one too, with some minor package name changes. If so, that'd
save us one dependency, and let us solve some generics warnings (dom4j 1.6.x is
Java 1.4 compatible so no generics)
Depending on exactly how major a change this turns out to be, it might be
possible to do in 3.11, or might be better left for a 3.12 change
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Replace use of Dom4J with JAXP
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Yaniv Kunda <ya...@kundas.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Investigate switching from |Replace use of Dom4J with
|Dom4J to Javax.XML |JAXP
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #3 from Yaniv Kunda <ya...@kundas.net> ---
It's a precaution as neither DocumentBuilderFactory nor DocumentBuilder are
guaranteed to be thread-safe, plus it duals as a cache.
But I agree that this needs to be more carefully examined, and perhaps starting
with a static DocumentBuilderFactory spawning new DocumentBuilder objects on
each call is the way to go.
Performance wise, I do believe we have more pressing issues than creation of
DocumentBuilders and their factories...
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
RE: [Bug 56814] New: Investigate switching from Dom4J to Javax.XML
Posted by Nick Burch <ap...@gagravarr.org>.
On Sun, 10 Aug 2014, Yaniv Kunda wrote:
> p.s. Noticed that legal/NOTICE still contains a reference to Piccolo XML
> parser...
That's required, we get Piccolo via xmlbeans
We probably don't want to make a change like this for a month or so, until
we get 3.11 final out. Feel free to make any more tweaks as you feel are
needed, we'll apply it as soon as 3.11 is done!
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
RE: [Bug 56814] New: Investigate switching from Dom4J to Javax.XML
Posted by Yaniv Kunda <ya...@answers.com>.
Submitted a patch for getting rid of dom4j.
One note thought - moving to JAXP might get rid of both dom4j and some
generic warnings, but that's only because it uses its own special
(non-)collection types such as NodeList; the fact it follows the
cross-language w3c recommendation gives it "vintage" bouquet - I would
still prefer to use a good XML processing library (or a wrapper) over both
dom4j and JAXP.
The only question remains - is there such a library, and can we use it?
p.s. Noticed that legal/NOTICE still contains a reference to Piccolo XML
parser...
-----Original Message-----
From: bugzilla@apache.org [mailto:bugzilla@apache.org]
Sent: Tuesday, August 5, 2014 00:09
To: dev@poi.apache.org
Subject: [Bug 56814] New: Investigate switching from Dom4J to Javax.XML
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Bug ID: 56814
Summary: Investigate switching from Dom4J to Javax.XML
Product: POI
Version: 3.11-dev
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: OPC
Assignee: dev@poi.apache.org
Reporter: apache@gagravarr.org
When the OPC code was first added, it only required Java 1.4, so needed
external XML jars in the form of stax-api and dom4j. Now that we're on Java
1.6, we've already been able to drop the stax-api jar. It may also be
possible to drop the dom4j one too, with some minor package name changes. If
so, that'd save us one dependency, and let us solve some generics warnings
(dom4j 1.6.x is Java 1.4 compatible so no generics)
Depending on exactly how major a change this turns out to be, it might be
possible to do in 3.11, or might be better left for a 3.12 change
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org For additional
commands, e-mail: dev-help@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #2 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
+1 !
Why do we need the ThreadLocal for the DocumentBuilder? Can we not configure
the DocumentBuilderFactory and return a *new* DocumentBuilder each time? Thread
locals have some side effects and should be avoided if not really needed.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #14 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Is there anything against committing this for now? Nick already mentioned, that
we should get this in BETA2, too.
To me the patch looks fine, we can improve later. Locally, I just changed some
*-imports to be explicit, otherwise its the same as attached patch and ready to
commit.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Yaniv Kunda <ya...@kundas.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31890|0 |1
is obsolete| |
--- Comment #4 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31893
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31893&action=edit
Required changes to replace dom4j with JAXP - without ThreadLocal
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Uwe Schindler (ASF) <uw...@thetaphi.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31895|New patch |56814.patch
description| |
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #12 from Yaniv Kunda <ya...@kundas.net> ---
I intentionally left the coreProperties prefix in PackagePropertiesMarshaller
empty because I've noticed it is used as the default namespace when writing -
I'm not sure if that matters.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Uwe Schindler (ASF) <uw...@thetaphi.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #16 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
I committed the current state.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #6 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Thanks!
Looks fine. The problem with DocumentBuilderFactory is more that it is not
thread safe if you change properties. But if you have a correctly conbfigured
factory and just call newDocumentBuilder() it should be thread safe.
BTW: The warnings about missing thread safety were removed from Javadocs after
Java 1.5. So I assume that newDocumentBuilder are thread safe. If you canr,
wrap the newDocumentBuilder with a static synchronized block, that would be
most safe: "static synchronized getDocumentBuilder()" (in both SAXHelper and
the other factory class). Since Java 1.6 the synchronized does not matter at
all if there is no real concurrency involved (optimized away by Hotspot).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Uwe Schindler (ASF) <uw...@thetaphi.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31894|0 |1
is obsolete| |
--- Comment #10 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Created attachment 31895
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31895&action=edit
New patch
Hi,
I reviewed the patch and made some changes:
- In StreamHelper, I set OutputKeys in the identity transformer, to prettyprint
(as done by dom4j) and also ste standalone attribute (as required by openxml).
- In StreamHelper I prevented the transformer from closing the outputstream
(using a CloseShieldOutputStream like in TIKA, unfortunately it was not
available to POI). The problem: some transformers close the outputstream (from
StreamResult), which would break ZIPOutputStream.
- I removed stax.Namespace from the properties parser, useless there, as
namespace prefixes are not used while parsing
- I moved the methods to add xmlns attributes from POI to openxml, because this
would have added a wrong relationship. It is now in DocumentHelper
- I fixed a incorrect namespaceprefix in the coreProperties. openxml document
should use "cp" prefix.
- I removed the thread safety test again, because I made the methods that use
the factories synchronized. This has no overhead in Java 6, if not used from
many threads.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Yaniv Kunda <ya...@kundas.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31893|0 |1
is obsolete| |
--- Comment #7 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31894
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31894&action=edit
Required changes to replace dom4j with JAXP - without ThreadLocal, including a
test
Added a test to check for concurrency issues - at least for SAXHelper, if I
change the implementation to return a static DocumentBuilder, it fails with
org.xml.sax.SAXException: FWK005 parse may not be called while parsing.
I could not manage to fail DocumentHelper.createDocument() :-)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #1 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31890
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31890&action=edit
Contains the required changes to replace dom4j with JAXP
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #9 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Hi,
I think we should put this into 3.11, too. I will apply the patch locally and
do my tests with it. If all goes fine, I would be very happy to get rid of
dom4j. This makes using of POI complicated, because it may conflict with other
uses of dom4j. Also, dom4j is more or less inactive, because it has no features
that are not available in the official W3C DOM APIs. The only nice thing with
dom4j is the more "Java-like" API, but this is no longer true, because it lacks
generics support.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #13 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Hi,
I checked this. This was an error. In official openxml documents as created
e.g. by Word 2010, the coreproperties prefix is marked as "cp:". There is no
default namespace.
Uwe
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Uwe Schindler (ASF) <uw...@thetaphi.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31895|0 |1
is obsolete| |
--- Comment #11 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
Created attachment 31898
--> https://issues.apache.org/bugzilla/attachment.cgi?id=31898&action=edit
Patch.
New patch, because the previous one had Line-feed issues (unfortunately POI
does not have svn:eol-style:native on all text files.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #5 from Yaniv Kunda <ya...@kundas.net> ---
Eventually I did some testing and as long as it is not changed from different
threads, a DocumentBuilderFactory can produce new DocumentBuilder objects from
different threads without a problem.
Regarding DocumentBuilder, for the purpose of parsing I created a new one for
each invocation of SAXHelper.readSAXDocument, but for
DocumentHelper.newDocument I used a static DocumentBuilder, as it does change
its state, and only used for that purpose.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Yaniv Kunda <ya...@kundas.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31890|Contains the required |Required changes to replace
description|changes to replace dom4j |dom4j with JAXP
|with JAXP |
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
Uwe Schindler (ASF) <uw...@thetaphi.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #31898|Patch. |56814.patch
description| |
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #15 from Yaniv Kunda <ya...@kundas.net> ---
+1 on the synchronization - my test was good for verifying the JRE running it
was safe, not for every user's JRE.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 56814] Investigate switching from Dom4J to Javax.XML
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56814
--- Comment #8 from Uwe Schindler (ASF) <uw...@thetaphi.de> ---
I would still make it synchronized, then we are safe!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org