本文介绍了撒克逊变换导致未知扩展指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 sql;query 从 XSLT 查询 oracle 数据库,我正在使用 sql9-sql.jar 和 saxon EE 9.6.0.7 版本,其中我已将 ojdc6.jar 也放在 eclipse 的构建路径中.我收到以下错误

I am trying to query oracle database from XSLT using sql;query, i am using sql9-sql.jar along with saxon EE 9.6.0.7 version where in i have placed ojdc6.jar also in buildpath of eclipse. I am getting below error

队列名称是错误 in xsl:value-of/@select on line 37 column 65 of pro.xsl: XTDE1450: Unknown extension instructions in built-in template rule ;SystemID: file:/C:/home/oracle/workspace/XSLTsaxonEE/src/com/thbs/viniReq/pro.xsl;Line#: 37 net.sf.saxon.trans.XPathException: 在 net.sf.saxon.expr.ErrorExpression.evaluateItem(ErrorExpression.java:127) 的未知扩展指令在 net.sf.saxon.expr.Expression.process(Expression).java:880) at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:325) at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:50) at net.sf.saxon.expr.Atomizer.evaluateItem(Atomizer.java:317) 在 net.sf.saxon.expr.Atomizer.evaluateItem(Atomizer.java:37) 在 net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:311) 在 net.sf.saxon.expr.AtomicSequenceConverter.evaluateItem(AtomicSequenceConverter.java:34) 在 net.sf.saxon.expr.instruct.ValueOf.evaluateItem(ValueOf.java:313) 在 net.sf.saxon.expr.instruct.ValueOf.evaluateItem(ValueOf.java:45) 在 net.sf.saxon.expr.instruct.SimpleNodeConstructor.iterate(SimpleNodeConstructor.java:281) 在 net.sf.saxon.expr.instruct.BlockIterator.next(BlockIterator.java:49) 在 net.sf.saxon.expr.instruct.Message.processLeavingTail(Message.java:214) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:657) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule).java:393) 在 net.sf.saxon.trans.Mode.applyTemplates(Mode.java:456) 在 net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:65) 在 net.sf.saxon.trans.Mode.applyTemplates(Mode.java:433) at net.sf.saxon.Controller.transformDocument(Controller.java:2291) at net.sf.saxon.Controller.transform(Controller.java:1889) at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:553) 在 net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:183) 在 com.thbs.viniReq.TransformXsl.main(TransformXsl.java:553))

这是我的java代码:


Here is my java code:

 public static void main(String[] args) throws XPathException { 

   System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");  

    EnterpriseConfiguration config=new EnterpriseConfiguration();
    config.setExtensionElementNamespace("http://ns.saxonica.com/sql", "net.sf.saxon.option.sql.SQLElementFactory");

    EnterpriseTransformerFactory factory = new EnterpriseTransformerFactory();
    factory.setConfiguration(config);
    try {  
        Transformer transformer =  factory.newTransformer(new StreamSource(new File(xslt)));

         transformer.transform(new StreamSource(new File(xml)),  
                              new StreamResult(new File(resultDir))); 

       transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    } catch (Exception e) {  
        e.printStackTrace();  
    }  

这是我的 XSLT:


Here is my XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:sql="http://ns.saxonica.com/sql"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:java="http://saxon.sf.net/java-type"
 xmlns:saxon="http://saxon.sf.net/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 exclude-result-prefixes="java saxon xsd xsi xsl"
 extension-element-prefixes="saxon sql"
 >
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"
/>

<!-- Database Querying -->
<xsl:param name="jdbc.driver"   as="xsd:string" select="'oracle.jdbc.OracleDriver'" />
<xsl:param name="jdbc.database" as="xsd:string" select="'jdbc:oracle:thin:@localhost:1521:orclaq'" />
<xsl:param name="jdbc.user" as="xsd:string" select="'artl'" />
<xsl:param name="jdbc.pass" as="xsd:string" select="'artl'" />

<xsl:template match="OrderSubline">

<xsl:variable name="sql.conn" as="java:java.sql.Connection">
              <sql:connect driver="{$jdbc.driver}" database="{$jdbc.database}" user="{$jdbc.user}" password="{$jdbc.pass}">
                <xsl:fallback>
                  <xsl:message terminate="yes">SQL extenstions are not installed</xsl:message>
                </xsl:fallback>
              </sql:connect>
</xsl:variable>
<xsl:variable name="queue-table">
    <sql:query connection="$sql.conn" table="QUEUE_CONFIG" column="QUEUE_NAME" row-tag="book" column-tag="col" where="QUEUE_NAME='TVXX_INPT'"/>

</xsl:variable>
<xsl:variable name="queue-id">
    <sql:query connection="$sql.conn" table="QUEUE_CONFIG" column="QUEUE_ID" row-tag="book" column-tag="col" where="QUEUE_NAME='TVXX_INPT'"/>
</xsl:variable>
<xsl:message>queue name is <xsl:value-of select="$queue-table"/></xsl:message>

<RequestHeader>
<NeType><xsl:value-of select="$queue-table"/></NeType>
<OrderNo>100001</OrderNo>
<ReqUser>ff</ReqUser>
</RequestHeader>
</xsl:template>

</xsl:stylesheet>

如果我遗漏了什么,请告诉我.因为我从过去 3 天就陷入了困境.提前致谢.

Kindly let me know if i am missing on something. As i am stuck in it from past 3 days. Thanks in advance.

推荐答案

我无法立即看出这里出了什么问题,但我想到的第一种可能,应该作为可能的原因进行调查和消除,是未找到许可证文件.(这将导致 Saxon 基本上在 Saxon-HE 模式下运行.)因为您手头有 Configuration 对象,所以最简单的检查方法是

I can't immediately see what's wrong here, but the first possibility that comes to mind, which should be investigated and eliminated as a possible cause, is that the license file isn't being found. (This would cause Saxon to run essentially in Saxon-HE mode.) Since you've got the Configuration object to hand, the simplest way to check this is

config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XSLT)

config.isLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XSLT)

如果确实是许可证问题,那么我们需要查看类路径.我注意到您在 Eclipse 中运行,并且在 Eclipse 中动态加载可能相当古怪.

If it does turn out to be a license issue then we need to look at the classpath. I note you are running in Eclipse, and dynamic loading in Eclipse can be fairly quirky.

这篇关于撒克逊变换导致未知扩展指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 15:17