2016-07-07 64 views
0

我正在使用Krextor将XML转换为RDF。它从命令行运行良好。 我尝试使用此代码从Java(Eclipse)运行它。由于撒克逊运行XSLT到RDF框架失败

private static void XMLToRDF() throws KrextorException, ValidityException, ParsingException, IOException, XSLException{ 

     Element root = new Element("person"); 
     Attribute friend = new Attribute("friends", "http://van-houten.name/milhouse"); 
     root.addAttribute(friend); 
     Element name = new Element("name"); 
     name.appendChild("Bart Simpson"); 
     root.appendChild(name); 
     nu.xom.Document inputDocument = new nu.xom.Document(root); 
     System.out.println(inputDocument.toXML()); 
     Element root1 = inputDocument.getRootElement(); 
     System.out.println(root1); 
     Krextor k = new Krextor(); 
     nu.xom.Document outputDocument = k.extract("socialnetwork","turtle",inputDocument); 
     System.out.println(outputDocument.toString()); 
    } 

我有以下问题的问题

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/saxon/CollectionURIResolver 
Caused by: java.lang.ClassNotFoundException: net.sf.saxon.CollectionURIResolver 

我在classpath中包括Saxon9he,我也手动添加作为项目库,但错误是一样的。

+0

我的猜测是Krextor对Saxon的特定版本有依赖性。但我无法在他们的文档中轻松找到这些信息。类CollectionURIResolver在Saxon 9.1的包net.sf.saxon中,但是通过9.3它已经转移到了net.sf.saxon.lib。 –

+0

我按照你的建议,我手动包括Saxon9.jar,现在我得到这个错误:异常在线程“主”javax.xml.transform.TransformerFactoryConfigurationError:提供者net.sf.saxon.TransformerFactoryImpl无法实例化:java.lang .SecurityException:类“net.sf.saxon.TransformerFactoryImpl”的签名者信息与相同包中的其他类的签名者信息不匹配 – Caleb

+1

我想你应该向Krextor的开发人员询问这一点。也许他们已经包含了一个Saxon版本,在这种情况下,将另一个版本的Saxon放在类路径中很可能会导致问题。 –

回答

0

我是Krextor的主要开发人员。而且,@迈克尔凯,其实是格兰杰的同事,所以我会在当地解决他的具体问题。因此,我确实进行了严格测试的最后一个撒克逊版本是9.1;之后,我还没有将Krextor集成到Java中,但主要是从命令行使用Krextor。

@Grangel,你可以请Krextor提出问题,然后我们可以一起修复它。

事实上,@Michael Kay,一段时间以来,我一直在使用Krextor包含更新的Saxon版本,并更新了命令行包装器以使用它们(比如将不同的JAR添加到类路径中),但我没有更新Java包装代码。