db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-2739) Automatically detect and use the Xalan which is included in Sun's Java 1.5.0 and higher
Date Mon, 03 Jan 2011 17:14:51 GMT

     [ https://issues.apache.org/jira/browse/DERBY-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Knut Anders Hatlen updated DERBY-2739:

    Attachment: xml-interfaces.diff

I've experimented with making changes to the SqlXmlUtil class so that
it uses the JAXP/DOM interfaces instead of the Xalan implementation
classes to make it independent of the actual underlying implementation.

The attached patch (xml-interfaces.diff) is just for testing. It needs
more polishing before it can be committed, but in its current state it
successfully runs all the XML tests on Oracle's Java 6, without
separate Xalan jars on the classpath.

In short, the patch changes from the following implementation classes
to these interfaces:

org.apache.xalan.serialize.Serializer -> javax.xml.transform.Transformer
org.apache.xpath.XPath -> org.w3c.dom.xpath.XPathEvaluator

The javax.xml.transform.Transformer interface is part of JDK 1.4.2,
but org.w3c.dom.xpath.XPathEvaluator isn't, so this change means we'll
have to reintroduce the xml-apis.jar file (part of Xalan) that we
removed in DERBY-3702. But only as a build dependency. On the bright
side, we shouldn't need xalan.jar, xercesImpl.jar or serializer.jar in
the build anymore.

There are interfaces that provide support for XPath in JDK 1.4.2 too,
but those interfaces require us to know up front what the return type
of an XPath query is, and we don't have that information when we
compile the query. org.w3c.dom.xpath.XPathEvaluator doesn't have this

To test the patch, get xml-apis.jar from the Subversion history with
this command:

svn copy https://svn.apache.org/repos/asf/db/derby/code/trunk/tools/java/xml-apis.jar@588374

Some missing parts that need to be worked out before the patch is
ready are:

1) Formatting of floating point numbers is done differently. The
current code uses org.apache.xpath.objects.XNumber.str() to format the
numbers, and the patch uses Double.toString(). Double.toString() uses
exponents/scientific notation to make the result string more compact,
whereas XNumber.str() doesn't use exponents. There are currently no
tests that expose this difference.

2) The original code uses an instance of
org.apache.xml.utils.PrefixResolverDefault to resolve prefixes when
evaluating XPath queries. According to the comments, this is needed in
order to prevent NPEs in some queries. However, none of the XML tests
failed when tried to replace the resolver with null in the original
code. So some more investigation is needed in order to find out what
problem this code is supposed to fix, and if something special is
needed to handle that in the new code.

Here are some more details about what the patch does:

M       java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java

Remove code that's not used anymore

M       tools/ant/properties/extrapath.properties
M       java/engine/org/apache/derby/iapi/types/build.xml

Compile SqlXmlUtil.java against xml-apis.jar instead of xercesImpl.jar.

M       java/engine/org/apache/derby/iapi/types/XML.java

Stop looking for Xalan implementation classes, and instead see if we
have the JAXP interfaces and check that the DOM implementation
supports the required XPath functionality.

M       java/engine/org/apache/derby/iapi/types/SqlXmlUtil.java

Use the interfaces as described above.

M       java/testing/org/apache/derbyTesting/junit/XML.java

Check for JAXP interfaces and DOM level instead of a specific Xalan
version, and rename methods accordingly.

M       java/testing/org/apache/derbyTesting/functionTests/tests/lang/XMLMissingClassesTest.java
M       java/testing/org/apache/derbyTesting/junit/EnvTest.java

Use the new helper methods that check if the XML operators are

> Automatically detect and use the Xalan which is included in Sun's Java 1.5.0 and higher
> ---------------------------------------------------------------------------------------
>                 Key: DERBY-2739
>                 URL: https://issues.apache.org/jira/browse/DERBY-2739
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions:
>            Reporter: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: xml-interfaces.diff
> Sun's Java 1.5.0 and higher includes Xalan, but Derby doesn't find it because it has
been moved to a non-standard package. Derby should be able to detect and use these classes
if it cannot find Xalan in the standard package on the classpath. This would make it easier
for many users to start using Derby's XML features.
> See also the discussion in this thread: <URL:http://mail-archives.apache.org/mod_mbox/db-derby-dev/200705.mbox/%3c465F015C.9070404@gmail.com%3e>

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message