在xslt document()函数的字符串中使用单引号

时间:2013-12-18 21:04:27

标签: java xslt

我正在尝试通过XSLT document()函数将URI字符串发送到URI解析器。当我在其中使用单引号时,变压器会失败。有没有人在这个作品中使用什么?

以下是来自XSL文件的代码

<xsl:variable name="findFEV" select="document('sql:select md from MenuData md where md.id=194003 and string01='David' and md.account = :account')"/>

这是我在进行转换时遇到的错误。

15:59:12,165 ERROR [STDERR] javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Expected ,, but found: David
15:59:12,165 ERROR [STDERR] javax.xml.transform.TransformerException: Expected ,, but found: David
15:59:12,166 ERROR [STDERR]     at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:938)
15:59:12,167 ERROR [STDERR]     at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:776)
15:59:12,167 ERROR [STDERR]     at org.tolven.api.rs.resource.DataExtractResources.transform(DataExtractResources.java:109)
15:59:12,167 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
15:59:12,167 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
15:59:12,168 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
15:59:12,168 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:606)
15:59:12,168 ERROR [STDERR]     at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:186)

1 个答案:

答案 0 :(得分:1)

<xsl:variable name="findFEV"
select='document("sql:select md ... and string01=&apos;David&apos; and ...")'/>

说明:

选择表达式将变为

document("sql:select md ... string01='David' and ...")

适合。文档调用需要双引号字符串,因为'David'必须是单引号(SQL)。

感谢@DanielHaley