dbTalk Databases Forums  

Using doc("") function

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Using doc("") function in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ale
 
Posts: n/a

Default 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..)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.