If you're using the XQJ interface, it allows you to construct a document from a lexical string of XML using the method createItemFromDocument(), with several overloads. Having created the Item, you can then bind it to the context item or to a variable.
 
You're passing the raw string to the query (as a string value); that's no use, it needs to be parsed first and turned into a tree structure.
 
Michael Kay
http://www.saxonica.com/


From: Erik Rens [mailto:mail2rens@gmail.com]
Sent: 31 March 2009 13:36
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Fwd: Xpath 2.0 sequences and Saxon examples problems.

Ah oke i will use XQuery for now. I think its better solution for this project.
 
Another question ..
 
String str = "<CATALOG><CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>10.90</PRICE><YEAR>1985</YEAR></CD><CD><TITLE>Hide your heart</TITLE><ARTIST>Bonnie Tyler</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS Records</COMPANY><PRICE>9.90</PRICE><YEAR>1988</YEAR></CD></CATALOG>";
 
 
 How can i iterate through this xml string. I know the way when you use a located xml file but not the solution with a string. Do i need to use an bindObject or bindString to do that ?
 

expression.bindString(

new QName("v"), rt, conn.createAtomicType(XQItemType.XQBASETYPE_STRING));

String query2 =

"declare variable $v as xs:string external; for $cd in $v/CATALOG/CD return <title>{$cd/TITLE/text()}</title>)";

XQSequence results = expression.executeQuery(query2);

I appreciate your answers..