[bdbxml] namespace problem

"sarigiannis xaralampos" <hsarigiannis-taE2apzES20Cep0kKqy/[email protected]>
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
Thanks George for the answer indeed I instantiate a single XmlManager
object, and keep it around for

the lifetime of my application  but I don t do the same with the
XmlQueryExpression .

You mean to create once an XmlQueryExpression lalas= new
XmlQueryExpression();  and use this variable whenever i need to make a query
instead of initializing new XmlQueryExpression variables all the times you
need to make a query?? (indeed XMLDB objects are very heavy it s good as I
realised everytime I create sth like XmlQueryExpression to delete them  )

 

Anyway 

I have one problem when using the below type of namespace :

<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p0"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation=" http://www.imsglobal.org/xsd/imsqti_v2p0
<http://www.imsglobal.org/xsd/imsqti_v2p0%20imsqti_v2p0.xsd>
imsqti_v2p0.xsd "title="Unattended Luggage" >

 

in order I make xqueries I instantiate an Xmlquerycontext

 

 context.setNamespace(" ", "http://www.imsglobal.org/xsd/imsqti_v2p0");

 

when my query has the form for instance   / assessmentItem  it does work

when my query has the form for instance   / assessmentItem/[@title='
Unattended Luggage']  it does  not work :((

 

I cannot understand why when the same query without namespace definitions
works fine 

 Thanks 

charris

  _____  

From: George Feinberg [mailto:[email protected]] 
Sent: Monday, June 27, 2005 7:57 PM
To: sarigiannis xaralampos
Cc: [email protected]
Subject: Re: [bdbxml] using DBXML API to query an Xml Doc 

 

I implemented a system that in order to render some xml files i used Xquery
to get docs from the database and after follow on queries to get the
specific values from the docs so as to render as needed.

 

I wanted  to make my system distributed by having the part of getting the
doc from the database in the one side and the part of doing the follow on
queries in the other side .I separated the system having the Xml Server in
the one side and the application that uses the Xml files of the server. I
did it using  a web service architecture .

 

I was asking via a soap msg the appropriate xml doc .After I used Berkeley
DBXML API to convert this (String)Xml Doc to an      XmlDocument , after I
was making a new XmlValue and finally I was making my Query.

 

        XmlManager theMgr = new XmlManager();

        XmlDocument Doc=theMgr.createDocument();

 
Doc.setContent(""<aDoc><title>doc1</title><color>green</color></aDoc> ");

        XmlValue  value=new XmlValue(Doc);

        XmlQueryContext Context = theMgr.createQueryContext();

        XmlQueryExpression Expression = theMgr.prepare(" //color ",
Context);

        XmlResults Results = Expression.execute(value, Context);

 

My question is if using DBXML API  to query over an Xml doc without it being
in the database is efficient ????

 

Using the XQuery functions built into BDB XML without using the database
portion 

works well, and is fully  supported.

 

I'd make two suggestions for this, based on the above code.

1.  You should instantiate a single XmlManager object, and keep it around
for

the lifetime of your application.  It can be safely shared among threads.

2.  Also, it is well worth creating XmlQueryExpression objects using

the XmlManager::prepare() method, and keeping them around as well

(perhaps in an STL map, or something similar).

They can also be safely shared among threads (do NOT share

XmlQueryContext objects, however).

 



Instead of it I could use Xalan engine ..

 

I can't compare to Xalan.  I can make a couple of comments based

on the implementation in BDB XML.

1.  Parsing/DOM.  In BDB XML, in queries such as yours, against transient

documents, the "DOM" tree created is done lazily (it doesn't use the

Xerces DOM parser).  That is, it creates nodes for elements, but avoids

constructing/destroying attribute and text nodes until required by the
query.

This means better memory management and less memory used and more

efficient code than if BDB XML used the Xerces DOM implementation.

 

2.  Querying.  Because it controls the DOM being queried, BDB XML adds

(and will be adding more) some methods that traverse the tree more
efficiently

in XQuery than can be done if simply working on top of a Xerces DOM layer.

 

In other words, it is the intent of BDB XML to be as efficient as possible
even

for querying of documents that do not appear in the database.

This is important because the same code is used when querying

documents stored in a wholedocument container.



I decided to use DBXML API   instead of Xalan engine as two queries over my
Doc are enough to render my XmlDoc.

Any comparisons between Xalan and DBXML API for rendering Xml docs are
accepted ..

 

Yes, please share.

 

Regards,

 

George
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.