xpathgluongluon-mobilegluon-desktop

Does gluon support Xpath in IOS


I tried running a gluon project that uses XML to initialize the project. Seeing the following error when running the application on an IOS device:

Caused by: java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFactory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:76

Note: Application runs successfully on Desktop Windows/Mac and on Android platform.

Is the Xpath not supported on IOS devices with Gluon


Solution

  • As you can read in the exception:

    No XPathFactory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom at javax.xml.xpath.XPathFactory.newInstance...
    

    So all you need to do is provide a valid implementation.

    For instance, adding this to your build.gradle:

    dependencies {
        compile 'com.gluonhq:charm:4.4.0'
        compile 'xalan:xalan:2.7.2'
    }
    

    Probably there are others like 'com.sun.org.apache:jaxp-ri:1.4'.

    I've tried it for this code only:

    public BasicView(String name) {
        super(name);
    
        XPath newXPath = XPathFactory.newInstance().newXPath();
    }
    

    and I don't get the exception anymore.