2
我錯過了什麼?我無法弄清楚爲什麼我的轉換不支持模式。 編號:用scala對saxonica 9 EE進行架構感知XSLT轉換
- http://www.saxonica.com/documentation/schema-processing/satransformapi.html
- http://www.saxonica.com/documentation9.4-demo/html/changes/intro92/install92.html
我知道的文件都很好,XSD/XSLT/XML文件是由其他系統處理並能正常工作。我試圖爲自己創建一個桌面命令行工具。
源代碼
def main(args: Array[String])
{
System.setProperty( "javax.xml.transform.TransformerFactory", "com.saxonica.config.EnterpriseTransformerFactory")
val factory = new EnterpriseTransformerFactory()
factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION, new Integer(Validation.STRICT))
val schemaXXX = new StreamSource(new File("PATH/to/xxx.xsd"))
val schemaYYY = new StreamSource(new File("PATH/to/yyy.xsd"))
factory.addSchema(schemaXXX)
factory.addSchema(schemaYYY)
val XSLT = new StreamSource(new File("PATH/to/zzz.xslt"))
val transformer = factory.newTransformer(XSLT)
val input = new StreamSource(new File("PATH/to/file.xml"))
val result = new StringWriter();
transformer.transform(input, new StreamResult(result))
println(result.toString())
}
結果:
The transformation is not schema-aware, so the source document must be untyped
不熟悉Java環境。但是'SchemaAwareTransformerFactory'和'EnterpriseTransformerFactory'是一樣的嗎? – 2014-08-27 15:29:08
@MathiasMüller給出的是:http://www.saxonica.com/documentation9.4-demo/html/changes/intro92/install92.html 無論如何,SchemaAwareTransformerFactory在我的jar文件中不可用,而EnterpriseTransformerFactory是。 – user2346536 2014-08-27 15:33:12
SchemaAwareTransformerFactory存在於舊版本中,它已被EnterpriseTransformerFactory – 2014-08-31 12:06:29