Hi,

As suggested by you, I am using bindDocument. But I am using it in SaxonXQPreparedExpression.Here is my sample code:

SaxonXQPreparedExpression expr = (SaxonXQPreparedExpression) con.prepareExpression(rule2);
expr.bindDocument(new QName("testString"), new StringReader(contents.toString()), null, null);

and in my rule2.xq (Xquery File), I am declaring external variable as:
declare variable $testString as node() external;
 
I am getting exception as:
Error on line 1 column 1
  SXXP0003: Error reported by XML parser: Content is not allowed in prolog.
javax.xml.xquery.XQException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at net.sf.saxon.xqj.SaxonXQDataFactory.newXQException(SaxonXQDataFactory.java:974)
    at net.sf.saxon.xqj.SaxonXQDataFactory.createItemFromDocument(SaxonXQDataFactory.java:437)
    at net.sf.saxon.xqj.SaxonXQDynamicContext.bindDocument(SaxonXQDynamicContext.java:75)

What can I do for this?

Regards
Sweta




From: Michael Kay <mike@saxonica.com>
Date: Mon, Feb 22, 2010 at 12:22 AM
Subject: Re: [saxon] Querying a XMLFile stored in memory as String Object
To: Mailing list for the SAXON XSLT and XQuery processor <saxon-help@lists.sourceforge.net>


One of the overloads of XQDynamicContext.bindDocument() accepts a Reader; call it with
 
bindDocument(xx, new StringReader(inputString), null, null)
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

Hi,

I am  using XQJ implementation  for processing XML  files in java. I have some xml files (not URI of files but the whole files itself)  which are converted into string objects . I want to query these string objects. How can I do this?

Thanks
Sweta