0

I'm trying to send a SQL string to URI resolver via XSLT document() function. The transformer fails when I use single quotes in it. Does anybody what to use in this sitation?

Here is the code from XSL file

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

This is the error that I get when I run transformation.

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)
4
  • Due to no good 'David' Try \'David\' - not sure. Or &apos;David&apos; should do. Commented Dec 18, 2013 at 21:16
  • @JoopEggen Nope. I tried that already. It didn't help. Commented Dec 18, 2013 at 21:19
  • You have to replace the single quotes with &apos; (so &apos;David&apos;) Commented Dec 18, 2013 at 21:22
  • @DanielHaley I get the same error. 16:28:13,091 ERROR [STDERR] javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Expected ,, but found: David Commented Dec 18, 2013 at 21:29

1 Answer 1

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

Explanation:

The select expression will become

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

which fits. The document call needs a double quoted string as 'David' has to be in single quotes (SQL).

Thanks to @DanielHaley

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.