2017-09-05 2 views
0

J'utilise Xpath 1.0 Expression pour interroger un document XML. Mon but est de sortir tous les nœuds sélectionnés dans un rapport Jaspersoft qui affiche une nouvelle page avec les données correspondantes pour chaque Uid.XPath Multiple Nodes

Voici un extrait de mon document XML que j'ai simplifié:

<?xml version="1.0" encoding="UTF-8"?> 
<root> 
    <modules> 
     <Operation> 
      <Operation> 
       <wellUid lookupLabel="Well992454">cf1</wellUid> 
      </Operation> 
     </Operation> 
     <RigInformation> 
      <RigInformation> 
       <rigName>RigName12345</rigName> 
       <rigInformationUid>rig005</rigInformationUid> 
       <rigManager lookupLabel="Manager554">554</rigManager> 
      </RigInformation> 
      <RigInformation> 
       <rigName>RigName4578945</rigName> 
       <rigInformationUid>rig001</rigInformationUid> 
       <rigManager lookupLabel="Manager2254879">2254</rigManager> 
      </RigInformation> 
     </RigInformation>  
     <Well> 
      <Well> 
       <wellUid>cf1</wellUid> 
       <wellName>Name 1</wellName> 
      </Well> 
      <Well> 
       <wellUid>cf2</wellUid> 
       <wellName>Name 2</wellName> 
      </Well> 
     </Well> 
     <ReportDaily> 
      <ReportDaily> 
       <wellUid>cf1</wellUid> 
       <rigInformationUid>rig001</rigInformationUid> 
      </ReportDaily> 
     </ReportDaily> 
    </modules> 
</root> 

Je suis en train de trier une expression XPath qui affiche toutes les informations sous la wellUid. Donc, s'il y a un puits "001" et un puits "002", alors il devrait y avoir seulement deux lignes retournées avec toutes les informations de Well, RigInformation, Operation et ReportDaily. RigInformation ne dispose pas de wellUid mais possède un outil rigInformationUID auquel ReportDaily est également associé.

Voici mes questions que j'ai essayé jusqu'à présent ...

//ReportDaily/ReportDaily[wellUid = //Well/Well/wellUid] | //RigInformation/RigInformation[wellUid = //Well/Well/wellUid] | //Operation/Operation[wellUid = //Well/Well/wellUid] | //Well/Well[wellUid] 

et

//Well/Well[wellUid and //ReportDaily/ReportDaily[wellUid = //Well/Well/wellUid and //Operation/Operation[wellUid = //Well/Well/wellUid and //RigInformation/RigInformation[rigInformationUid = //ReportDaily/ReportDaily/rigInformationUid]]]] 

Toute aide serait grandement appréciée.

Répondre

0

Cela devrait vous commencé, étant donné que vous obtenez itérer à travers de wellUid donné:

root/modules/*/*[descendant::wellUid/text() = //Well/Well[1]/wellUid/text()] | 
root/modules/*/*[descendant::rigInformationUid/text() = //descendant::rigInformationUid[preceding-sibling::wellUid/text() = //Well/Well[1]/wellUid/text()]/text()]