You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Celinio Fernandes <cf...@pagesjaunes.fr> on 2005/08/11 18:19:37 UTC

Xquery and XMLcursor again

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>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org