Menu ▾ ▴

Using xmlunit library in OSGI bundle

Help
2020-07-21
2020-10-30
  • James Murtaugh

    James Murtaugh - 2020-07-21

    To whom it may concern,

    We are attempting to use the xmlunit-core library methods in an OSGi application. At runtime, we ran into a situation where the TransformerFactory class was not being resolved. I have included below an explaination of a modification to the xml unit code that we used to address this issue. We are wondering if there is an existing mechanim to address OSGI loading? If not, is there any interest in developing a feature so that we do not have to maintain a separate library with the changes we needed?

    Thanks
    Jim

    After googling the error we found the folowing link https://stackoverflow.com/questions/51687871/unable-to-force-eclipse-to-use-saxon-xslt-processor that suggests we use replace:
    TransformerFactory fact = TransformerFactory.newInstance()
    with
    TransformerFactory fact = new net.sf.saxon.TransformerFactoryImpl();"

    We successfully tested that this was our issue by making the following changes to the xmlunit-2.5.1 library code:

    **xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java diffs: ***
    30,31d29
    < import net.sf.saxon.TransformerFactoryImpl;
    <
    457c455
    < final TransformerFactory factory = new TransformerFactoryImpl();


        final TransformerFactory factory = TransformerFactory.newInstance();
    

    ** END xmlunit-core/src/main/java/org/xmlunit/diff/DefaultComparisonFormatter.java diffs ***

    ** xmlunit-core/src/main/java/org/xmlunit/transform/Transformation.java diffs: ***
    168c168
    < fac = new net.sf.saxon.TransformerFactoryImp();


                fac = TransformerFactory.newInstance();
    

    ** END xmlunit-core/src/main/java/org/xmlunit/transform/Transformation.java diffs ***

    ** xmlunit-core/src/main/java/org/xmlunit/util/Convert.java diffs: ***
    34d33
    < import net.sf.saxon.TransformerFactoryImpl;
    76c75
    < fac = new TransformerFactoryImpl();


                    fac = TransformerFactory.newInstance();
    

    ** END xmlunit-core/src/main/java/org/xmlunit/util/Convert.java ***

     
  • Stefan Bodewig

    Stefan Bodewig - 2020-07-29

    I've opened https://github.com/xmlunit/xmlunit/issues/195 and will get to it sometime in the coming weeks. If there is anything else you'd need please open new issues.

    Thanks

    Stefan

     
  • Stefan Bodewig

    Stefan Bodewig - 2020-10-30

    XMLUnit 2.8.0 has just been released and allows the TransformerFactory to be set explicitly in DefaultComparisonFormatter.

     

Log in to post a comment.