• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Xquery and XMLcursor again (XMLbeans)

 
Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In my program, I do not want to proceed the sets of EPJ for which at
least one of their children <LIEN_EPJ>
have the elements LE_CO_TYPE and LE_DA_SUPPRESSION that match this
condition:
[LE_CO_TYPE = R and LE_DA_SUPPRESSION is empty ]

So, I wrote this:

MPGPVCDocument mpgpvcdoc = MPGPVCDocument.Factory.parse(inputXMLFile);
// Get object reference of root element MPGPVC.
MPGPVCDocument.MPGPVC MPGPVCElement = mpgpvcdoc.getMPGPVC();
EPJ[] lesepjs = MPGPVCElement.getEPJArray();
while ( i < lesepjs.length)
{
XmlCursor itemCursor = lesepjs[i].newCursor();
itemCursor.toChild("LIENS_EPJ"); // ==> LIENS_EPJ
itemCursor.push();
// this displays all elements from <!-- POSITION 1 --> to
<!-- POSITION 2 -->
System.out.println(itemCursor.xmlText());

// Now how do i get to loop on itemcursor and check for
every subset <LIEN_EPJ>
// to see if their elements LE_CO_TYPE and
LE_DA_SUPPRESSION match the condition ?


}


Thanks for your suggestions.

Here is the XML file:

<?xml version="1.0" encoding="UTF-8"?>
<MPG-PVC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="mpgpvc.xsd">
<DATE_ENVOI>07/08/2005 09:07:01</DATE_ENVOI>
<NB_EPJ>92</NB_EPJ>
<EPJ>
<DT>
<DT_CO_EMETTEUR_MVT>PVC3</DT_CO_EMETTEUR_MVT>
</DT>
<LIENS_EPJ> <!-- POSITION 1 -->
<LIEN_EPJ>
<LE_ID_EPJA_FONC>8</LE_ID_EPJA_FONC>
<LE_CO_TYPE>R</LE_CO_TYPE>
<LE_DA_SUPPRESSION></LE_DA_SUPPRESSION>
</LIEN_EPJ>
<LIEN_EPJ>
<LE_ID_EPJA_FONC>7</LE_ID_EPJA_FONC>
<LE_CO_TYPE>R</LE_CO_TYPE>

<LE_DA_SUPPRESSION>10/02/2004</LE_DA_SUPPRESSION>
</LIEN_EPJ>
</LIENS_EPJ> <!-- POSITION 2 -->
</EPJ>
<EPJ>
etc ...
</EPJ>
 
reply
    Bookmark Topic Watch Topic
  • New Topic