Using doc("") function -
09-07-2006
, 09:01 AM
Hi all
I'm trying this XQuery (using Java API)
I'm using this code:
public class EngineSleepycatBDBXML
{
private static File path2DbEnv = new File("bdbxml_data");
private static String theContainer = "data.dbxml";
private String collection=null;
private myDbEnv myEnv = null;
private XmlTransaction myTransaction = null;
private XmlContainer myContainer = null;
private XmlManager myManager = null;
private XmlManagerConfig myManagerConfig = null;
private XmlContainerConfig myContainerConfig = null;
private XmlDocumentConfig docConfig = null;
private XmlUpdateContext updateContext = null;
protected boolean run(String fullQuery) throws Exception
{
try
{
try
{
if(!path2DbEnv.isDirectory())
path2DbEnv.mkdir();
myEnv = new myDbEnv(path2DbEnv);
}
catch (Throwable ex)
{
ex.printStackTrace();
}
myManagerConfig = new XmlManagerConfig();
myManagerConfig.setAllowAutoOpen(true);
myManagerConfig.setAllowExternalAccess(true);
myManager = new XmlManager(myEnv.getEnvironment(),
myManagerConfig);
// open a transactional container
myContainerConfig = new XmlContainerConfig();
myContainerConfig.setTransactional(true);
File f = new File(path2DbEnv+"\\"+theContainer);
f.delete();
f = null;
myContainer = myManager.createContainer(theContainer,
myContainerConfig);
// Start a transaction
myTransaction = myManager.createTransaction();
//Get an update context.
updateContext = myManager.createUpdateContext();
return true;
XmlQueryContext xqueryContext =
myManager.createQueryContext();
XmlResults results = myManager.query(fullQuery, xqueryContext,
null);
//Iterate over the results of the query using an XmlValue
object
XmlValue value;
String strResults = null;
while((value = results.next()) != null)
{
System.out.println(value.asString());
}
}
catch (Exception e)
{
....
ex.printStackTrace();
return false;
}
}
protected void load(File fc)
{...}
}
I want to be able to use both container and external xml resources...
And I'm using SleepyCat under Windows Xp. Is the java code right? And
the XQuery?
(I've also a function that loads XML resorces into container, and
XQuery against that docs run, but XQuery against external docs
failes... )
If I load C:\test\test_sleepycatDbXml\test_sleepycatDbXml.xm l and run
collection('data.dbxml')/bib/book/title
It works fine
But if I try to execute this XQuery (loading or without loading the
document)
doc("C:/test/test_sleepycatDbXml/test_sleepycatDbXml.xml")/bib/book/title
the error is:
com.sleepycat.dbxml.XmlException: Error: Operation not permitted,
errcode = DATABASE_ERROR
The error is
com.sleepycat.dbxml.XmlException: Error: The resource does not exist:
malformed or non-existent stream source, errcode = INVALID_VALUE
I've also runned:
doc("/test/test_sleepycatDbXml/test_sleepycatDbXml.xml")/bib/book/title
doc("file:/test/test_sleepycatDbXml/test_sleepycatDbXml.xml")/bib/book/title
doc("file://test/test_sleepycatDbXml/test_sleepycatDbXml.xml")/bib/book/title
(C:\test_sleepycatDbXml\test_sleepycatDbXml.xml is an existent file and
it is book.xml from W3C XQuery Usecases renamed..) |