[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    Saxon 8.1.1 dependency & saxon namespaces
From:       "Marius Gleeson" <mg () subscribe ! audumla ! net>
Date:       2005-12-29 3:02:43
Message-ID: 1135825363.12039.250699214 () webmail ! messagingengine ! com
[Download RAW message or body]

I am using a later version of saxon by making a simple change to the
following classes and rebuilding the xbean_xpath.jar

File:org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.java
Change 
 import net.sf.saxon.xpath.XPathException
to
 import net.sf.saxon.trans.XPathException

File:org.apache.xmlbeans.impl.xpath.saxon.XBeansXQuery.java
Change 
 import net.sf.saxon.xpath.XPathException
 import net.sf.saxon.xpath.StaticError
to
 import net.sf.saxon.trans.XPathException
 import net.sf.saxon.trans.StaticError

This will allow you to use the new versions of Saxon as the only problem
is a package name change.
It would be good to maybe replace the explicit catching of these
exceptions with more generic ones so that any version of Saxon can be
used without the need to have a different xbean_xpath.jar.

While on the topic, I have needed to pass namespaces to the Saxon engine
for xpath processing. 
However this is not possible through the xmlbeans interfaces because it
creates a new (empty) Map and hands this to saxon as its namespace list.
I have however made a simple change to
org.apache.xmlbeans.impl.store.Path to allow it to use the namespace map
in the XmlOptions instance that is passed on the call to selectPath.
The following snipit from my org.apache.xmlbeans.impl.store.Path.java
shows the changes,

From Line 78
public static Path getCompiledPath(String pathExpr, XmlOptions options)
    {
        options = XmlOptions.maskNull(options);

        int force =
                options.hasOption(_useXqrlForXpath)
                ? USE_XQRL
                : options.hasOption(_useXbeanForXpath)
                ? USE_XBEAN
                : USE_XBEAN|USE_XQRL|USE_SAXON; //set all bits
//******* passing options parameter 
        return getCompiledPath(pathExpr, force,
        getCurrentNodeVar(options),options);    
    }

//******* added options parameter to this method
    static synchronized Path getCompiledPath(String pathExpr, int force,
        String currentVar,XmlOptions options)
    {
        Path path = null;
        Map namespaces = null;
//******* If there are suggested namespaces then use them instead of
just creating an empty map.
        if ((options != null) &&
        (options.hasOption(XmlOptions.SAVE_SUGGESTED_PREFIXES)) ) {
            namespaces = (Map)
            options.get(XmlOptions.SAVE_SUGGESTED_PREFIXES);
        }
        else {
            namespaces = (force & USE_SAXON) != 0 ? new HashMap() :
            null;            
        }
  .
  .
  .

It would be really great to have this functionality back in the main
branch.

Thanks,
Marius.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic