Hi
I change the query to
String query = "for $item in doc('src/xmlFile/input.xml')//package return insert node <e123/> into $item";
with doc and is still not working.
Thanks
Eitan Elmalam
2014-03-13 15:00 GMT+02:00 BaseX Support support@basex.org:
Maybe it's due to...
https://github.com/BaseXdb/basex/issues/848 http://docs.basex.org/wiki/Options#WRITEBACK
Please use the basex-talk mailing list for future requests. ____________________________________
On Thu, Mar 13, 2014 at 1:50 PM, eitan elmalam eitan.elmalam@gmail.com wrote:
Hello BaseX Support
I am trying to do simple thing. I want to confige the data base to WRITEBACK true , that changes on XML
file
will execute on the file on the disc. And after that to execute query insert and to see the file on the disck changed. I send you the test case code, please check why is not work.
Thanks Eitan Elmalam.
/**
@param args
@throws BaseXException
*/
public static void main(String[] args) throws BaseXException {
try {
String LOCAL_DB_NAME1 = "LocalDB";
String LOCAL_DB_PATH1 = "src/xmlFile/input.xml";
Context context1 = new Context();
// Start server on default port 1984
BaseXServer server = new BaseXServer();
ClientSession session = new ClientSession("localhost", 1984,
"admin", "admin");
session.execute(new CreateDB(LOCAL_DB_NAME1, LOCAL_DB_PATH1));
String query = "for $item in //package return insert node <e123/> into $item";
//String query = "//package";
session.query(query).execute();
BaseXXQDataSource xqjd = null;
XQConnection conn;
XQExpression xqe;
xqjd = new BaseXXQDataSource();
conn = xqjd.getConnection("admin", "admin");
xqe = conn.createExpression();
xqe.executeCommand("SET WRITEBACK true");
} catch (Exception e) {
e.printStackTrace();
}
}
<App name="BasexTest_1">
<package name="main/resources/xml">
<file name="input.xml"/>
<e/>
<e/>
<e1/>
<e12/>
</package>
<package name="org/basex/examples/local">
<file name="RunCommands.java"/>
<folder>lib</folder>
<e/>
<e/>
<e1/>
<e12/>
</package>
</App>
2014-03-11 23:17 GMT+02:00 BaseX Support support@basex.org:
Eitan,
if you want help, please spend more time in creating examples that work out of the box (see [1] for more details), and write to the basex-talk mailing list. What do you expect your qeery to do? What is the error?
Christian
[1] http://www.sscce.org/ ____________________________________
I am create DB instance , and create client server for create
expression
to execute the command (("SET WRITEBACK true"); But the command not working , please help . See the code below.
Thanks Eitan Elmalam
public void createDB(String dbName, String dbPath) throws IOException
{
CreateDB db = new CreateDB(dbName, dbPath); db.execute(context); BaseXServer server = new BaseXServer(context);
session = new ClientSession("localhost", 1984, "alex", "admin");
XQDataSource ds = null; BaseXXQDataSource xqjd = null;
try { xqjd = new BaseXXQDataSource();
conn = xqjd.getConnection("alex", "admin");
} catch (Exception e) {
}
try { this.xqe = this.conn.createExpression(); } catch (XQException e) { e.printStackTrace(); }
int j = 0; try { xqe.executeCommand("SET WRITEBACK true"); } catch (XQException e) { e.printStackTrace(); }
}
Hello Eitan,
I see multiple issues with your code:
- First of all, you are using the Client/Server architecture, which does not seem to be very useful (at least to me, maybe you have a particular use case) if you want to use WRITEBACK. I am not even sure if WRITEBACK is actually used on server side. You might want to take a look at the local examples provided here https://docs.basex.org/wiki/Java_Examples to see how you can use BaseX locally. - You are executing the command to set WRITEBACK to true _after_ you run the query, i.e. during runtime of the query WRITEBACK is still the default (which is false) - Issue #848 could still apply, as it is unclear for me if you are using a database document or one read from the file system. If you add the file using CreateDB it is added to the database and as stated in the issue it is currently not possible to write back these files. You have to explicitly read the file from disk.
Cheers, Dirk
On 13/03/14 14:19, eitan elmalam wrote:
Hi
I change the query to
String query = "for $item in doc('src/xmlFile/input.xml')//package return insert node <e123/> into $item";
with doc and is still not working.
Thanks
Eitan Elmalam
2014-03-13 15:00 GMT+02:00 BaseX Support support@basex.org:
Maybe it's due to...
https://github.com/BaseXdb/basex/issues/848 http://docs.basex.org/wiki/Options#WRITEBACK
Please use the basex-talk mailing list for future requests. ____________________________________
On Thu, Mar 13, 2014 at 1:50 PM, eitan elmalam eitan.elmalam@gmail.com wrote:
Hello BaseX Support
I am trying to do simple thing. I want to confige the data base to WRITEBACK true , that changes on XML
file
will execute on the file on the disc. And after that to execute query insert and to see the file on the disck changed. I send you the test case code, please check why is not work.
Thanks Eitan Elmalam.
/**
@param args
@throws BaseXException
*/
public static void main(String[] args) throws BaseXException {
try {
String LOCAL_DB_NAME1 = "LocalDB";
String LOCAL_DB_PATH1 = "src/xmlFile/input.xml";
Context context1 = new Context();
// Start server on default port 1984
BaseXServer server = new BaseXServer();
ClientSession session = new ClientSession("localhost", 1984,
"admin", "admin");
session.execute(new CreateDB(LOCAL_DB_NAME1, LOCAL_DB_PATH1));
String query = "for $item in //package return insert node <e123/> into $item";
//String query = "//package";
session.query(query).execute();
BaseXXQDataSource xqjd = null;
XQConnection conn;
XQExpression xqe;
xqjd = new BaseXXQDataSource();
conn = xqjd.getConnection("admin", "admin");
xqe = conn.createExpression();
xqe.executeCommand("SET WRITEBACK true");
} catch (Exception e) {
e.printStackTrace();
}
}
<App name="BasexTest_1">
<package name="main/resources/xml">
<file name="input.xml"/>
<e/>
<e/>
<e1/>
<e12/>
</package>
<package name="org/basex/examples/local">
<file name="RunCommands.java"/>
<folder>lib</folder>
<e/>
<e/>
<e1/>
<e12/>
</package>
</App>
2014-03-11 23:17 GMT+02:00 BaseX Support support@basex.org:
Eitan,
if you want help, please spend more time in creating examples that work out of the box (see [1] for more details), and write to the basex-talk mailing list. What do you expect your qeery to do? What is the error?
Christian
[1] http://www.sscce.org/ ____________________________________
I am create DB instance , and create client server for create
expression
to execute the command (("SET WRITEBACK true"); But the command not working , please help . See the code below.
Thanks Eitan Elmalam
public void createDB(String dbName, String dbPath) throws IOException
{
CreateDB db = new CreateDB(dbName, dbPath); db.execute(context); BaseXServer server = new BaseXServer(context);
session = new ClientSession("localhost", 1984, "alex", "admin");
XQDataSource ds = null; BaseXXQDataSource xqjd = null;
try { xqjd = new BaseXXQDataSource();
conn = xqjd.getConnection("alex", "admin");
} catch (Exception e) {
}
try { this.xqe = this.conn.createExpression(); } catch (XQException e) { e.printStackTrace(); }
int j = 0; try { xqe.executeCommand("SET WRITEBACK true"); } catch (XQException e) { e.printStackTrace(); }
}
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de