osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: SV: Need help with XmlCursor - msg#00063

List: text.xml.xmlbeans.user

Date: Prev Next Index Thread: Prev Next Index
Hi,

I think the problem you're having is that your cursor get "reseted" at your
second executeQuery statement.
I had a similar problem, and I solved it by creating new cursors at the point
where I wanted to continue the search.
Instead of:
XmlCursor newCursor = cursor.execQuery("//PhysicalLocation");

I think you should try:
XmlCursor newCursor = cursor.newCursor();
newCursor.execQuery("//PhysicalLocation");

Here is my example, hope it helps:

cursor = body.newCursor();

cursor.toFirstChild();
cursor.push();


cursor.selectPath( queryExpression + "$this//xq:t");
XmlCursor cursor_toc_start = cursor.newCursor();
XmlCursor cursor_toc_end = cursor.newCursor();

cursor_toc_start.selectPath( queryExpression + "$this//xq:t[contains(.,
'Contents')]");
cursor_toc_end.selectPath( queryExpression + "$this//xq:t[contains(.,
'Income statement CIB PRUs total')]");
cursor_toc_start.toNextSelection();
cursor_toc_end.toNextSelection();

bookmarks = new HashMap();

bookmarks.put( "toc_start" , cursor_toc_start.getObject() );
bookmarks.put( "toc_end", cursor_toc_end.getObject() );




Connecta

Box 3216, Mäster Samuelsgatan 60, SE-103 64 Stockholm
Tel +46 (0) 8 635 80 00
Dir/Mob +46 (0) 8 635 81 08
Fax +46 (0) 8 635 80 02
www.connecta.se

________________________________

Från: Christopher.Mathrusse@xxxxxxxxxx [mailto:Christopher.Mathrusse@xxxxxxxxxx]
Skickat: fr 2006-06-30 00:52
Till: user@xxxxxxxxxxxxxxxxxxx
Ämne: Need help with XmlCursor




I'm having a bit of trouble getting my queries to work correctly. I have a
rather complex XML schema that is deep. I want to perform a query to get
all of the CustomerInformation elements throughout the document. This I
accomplish very easily:



custInfoCursor = cursor.execQuery("//CustomerInformation");



The custInfoCursor now contains a document fragment that contains all of
the CustomerInformation structures that were within the original document.
These structures are defined as complex datatypes because they have some
depth to them as well. My problem here is how do I iterate through the
CustomerInformation elements so I can perform additional queries against
each CustomerInformation element? I've been running into a great deal of
difficulty with this one as there are no concise examples.



I've tried:



for (cursor.toFirstContentToken() ; cursor.hasNextToken() ;
cursor.toNextToken()) {

// Here I want to run a query against the cursor but only in regards to
the current nodes context.

XmlCursor newCursor = cursor.execQuery("//PhysicalLocation"); // But
this doesn't work. It retrieves all nodes within the original document

}



Any help is greatly appreciated at this point. Even a link to an example so
I can see what I am doing wrong.



Thanks...



Chris Mathrusse

christopher.mathrusse@xxxxxxxxxx

(925) 236-5553



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: user-help@xxxxxxxxxxxxxxxxxxx



<<winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: user-help@xxxxxxxxxxxxxxxxxxx
Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Need help with XmlCursor

I'm having a bit of trouble getting my queries to work correctly. I have a rather complex XML schema that is deep. I want to perform a query to get all of the CustomerInformation elements throughout the document. This I accomplish very easily: custInfoCursor = cursor.execQuery("//CustomerInformation"); The custInfoCursor now contains a document fragment that contains all of the CustomerInformation structures that were within the original document. These structures are defined as complex datatypes because they have some depth to them as well. My problem here is how do I iterate through the CustomerInformation elements so I can perform additional queries against each CustomerInformation element? I've been running into a great deal of difficulty with this one as there are no concise examples. I've tried: for (cursor.toFirstContentToken() ; cursor.hasNextToken() ; cursor.toNextToken()) { // Here I want to run a query against the cursor but only in regards to the current nodes context. XmlCursor newCursor = cursor.execQuery("//PhysicalLocation"); // But this doesn't work. It retrieves all nodes within the original document } Any help is greatly appreciated at this point. Even a link to an example so I can see what I am doing wrong. Thanks... Chris Mathrusse christopher.mathrusse@xxxxxxxxxx (925) 236-5553

Next Message by Date: click to view message preview

Dynamically generating java classes from XSD file using XmlBeans

Hi, I am fairly new to XMLBEans. I know one can generate java classes from xsd (XML SChema) file using scomp. But I was wondering if there is any way it would be done on the fly. For Example, the user would be able to specify the file path for the XSD file to the program, and the program would then load the file, compile it, generate the java classes and manipulate the classes as required. Could this be done? Any help would be greatly appreciated. Best Regards Arif

Previous Message by Thread: click to view message preview

Need help with XmlCursor

I'm having a bit of trouble getting my queries to work correctly. I have a rather complex XML schema that is deep. I want to perform a query to get all of the CustomerInformation elements throughout the document. This I accomplish very easily: custInfoCursor = cursor.execQuery("//CustomerInformation"); The custInfoCursor now contains a document fragment that contains all of the CustomerInformation structures that were within the original document. These structures are defined as complex datatypes because they have some depth to them as well. My problem here is how do I iterate through the CustomerInformation elements so I can perform additional queries against each CustomerInformation element? I've been running into a great deal of difficulty with this one as there are no concise examples. I've tried: for (cursor.toFirstContentToken() ; cursor.hasNextToken() ; cursor.toNextToken()) { // Here I want to run a query against the cursor but only in regards to the current nodes context. XmlCursor newCursor = cursor.execQuery("//PhysicalLocation"); // But this doesn't work. It retrieves all nodes within the original document } Any help is greatly appreciated at this point. Even a link to an example so I can see what I am doing wrong. Thanks... Chris Mathrusse christopher.mathrusse@xxxxxxxxxx (925) 236-5553

Next Message by Thread: click to view message preview

Dynamically generating java classes from XSD file using XmlBeans

Hi, I am fairly new to XMLBEans. I know one can generate java classes from xsd (XML SChema) file using scomp. But I was wondering if there is any way it would be done on the fly. For Example, the user would be able to specify the file path for the XSD file to the program, and the program would then load the file, compile it, generate the java classes and manipulate the classes as required. Could this be done? Any help would be greatly appreciated. Best Regards Arif
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by