Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:36:35+00:00 2026-06-11T21:36:35+00:00

I’m using libxml2 in a C program to do some stuff within XML documents.

  • 0

I’m using libxml2 in a C program to do some stuff within XML documents.
Now… if I look to the following XPath I have an empty result.

/scheda_conservatore[1]/patrimonio_archivistico[1]/lower_list[@type='risorsa_informativa']/risorsa_informativa_nested[@id='037006-001-2012-ri002']

but… If I look for the following XPAth I have a non empty result containing elements that should have been matched even from the first one.

/scheda_conservatore[1]/patrimonio_archivistico[1]/lower_list/risorsa_informativa_nested[@id='037006-001-2012-ri002']

Now… if I check, step by step, my XPath I have…

/scheda_conservatore[1] -> Non empty node set
/scheda_conservatore[1]/patrimonio_archivistico[1] -> Non empty node set
/scheda_conservatore[1]/patrimonio_archivistico[1]/lower_list[@type='risorsa_informativa'] -> Empty Node set.

As I told before, the XML document DO contain a valid path but this is not matched by this request.
More: If I ask jEdit or other editors having XPath support to solve XPath expression for me, the result is a non empty node set.

I’m going mad. I watched the XPath expression thousands of times and there must be somethig very wrong at least as very hidden to my eyes even if it will surelly be brilliant to somebody else.


More…
The following, just asking for the ‘type’ attribute without looking at it’s value, give a valid result. But the value is also correct.
/scheda_conservatore[1]/patrimonio_archivistico[1]/lower_list[@type]/risorsa_informativa_nested[@id=’037006-001-2012-ri002′]


Here’s a “director’s cut” of the larger XML document

  <?xml version="1.0" encoding="iso-8859-1"?>
  <scheda_conservatore    anno_rilevazione="2012" stato="non-storicizzata">  
     <!-- scheda 2012 per Bologna -->  
     <patrimonio_archivistico> 
        <lower_list type="complesso_archivistico"> 
           <complesso_archivistico_nested id="037006-001-2012-ca001" inventariazione="n"> 
              <lower_list type="altro_luogo_collocazione"> 
                 <altro_luogo_collocazione_nested id="037006-001-2012-alc001"> 
                    <!-- altro luogo 1 per bologna 2012 -->  
                    <upper_list type="complesso_archivistico"> 
                       <upper ref="ca002"/>  
                       <upper ref="ca003"/> 
                    </upper_list>  
                    <ubicazione>sotterraneo da botola segreta</ubicazione>  
                    <bridge_list type="sede"> 
                       <bridge ref="s001"/> 
                    </bridge_list>  
                 </altro_luogo_collocazione_nested>  
              </lower_list>  
              <!-- complesso 1 per bologna 2012 -->  
              <identificazione> 
                 <denominazione>Archivi dei Comprensori della provincia di Bologna</denominazione>  
                 <lista_altre_denominazioni> 
                    <!-- Modificato -->  
                    <altra_denominazione>Archivi dei Comprensori bolognesi</altra_denominazione>  
                    <altra_denominazione>Archivi dei Comprensori felsinei</altra_denominazione> 
                 </lista_altre_denominazioni>  
                 <livello>Complesso di fondi, Superfondo</livello> 
              </identificazione>  
              <dati_giuridici> 
                 <tipologia>Pubblico</tipologia>  
                 <notificato_dichiarato presente="y"> 
                    <data>20100304T000000</data> 
                 </notificato_dichiarato> 
              </dati_giuridici>  
              <lower_list type="titolare"> 
                 <titolare_nested id="037006-001-2012-t001"> 
                    <!-- titolare 1 per bologna 2012 -->  
                    <upper_list type="complesso_archivistico"> 
                       <upper ref="ca001"/>  
                       <upper ref="ca002"/> 
                    </upper_list>  
                 </titolare_nested> 
              </lower_list> 
           </complesso_archivistico_nested>  
        </lower_list>  
        <lower_list type="risorsa_informativa"> 
           <risorsa_informativa_nested id="037006-001-2012-ri001"> 
              <bridge_list type="complesso_archivistico"> 
                 <bridge ref="ca001"/>  
                 <bridge ref="ca002"/> 
              </bridge_list>  
              <!-- risorsa 1 per bologna 2012 -->  
              <descrizione> 
                 <autore>CSR - Centro studi e ricerche</autore>  
                 <titolo>Atti degli uffici: inventario-mappa topografica del...</titolo>  
                 <anno indicativo="y">1986</anno>  
                 <qualifica> 
                    <opz pubbl="y">Strumenti di ricerca archivistici</opz> 
                 </qualifica>  
                 <scelta_multipla nome="standard"> 
                    <opz valore="AACR2"/>  
                    <opz valore="Altro">EAD</opz> 
                 </scelta_multipla>  
                 <descr_estrinseca>Dattiloscritto (relativo a: documentazione post 1945 conservata in Viale Martiri della Libert&amp;#x2026;)</descr_estrinseca> 
              </descrizione>  
              <lista_pubblicazioni> 
                 <pubblicazione> 
                    <edita presente="y">stampa</edita>  
                    <edita_stampa> 
                       <curatore/>  
                       <edito_in/>  
                       <luogo/>  
                       <data/>  
                       <pagine/>  
                       <sbn/>  
                       <note/> 
                    </edita_stampa>  
                    <url/>  
                    <ultima_consultazione>20120611T165400</ultima_consultazione>  
                    <nota>Nessuna nota</nota> 
                 </pubblicazione>  
                 <pubblicazione> 
                    <edita presente="y">web</edita>  
                    <edita_stampa/>  
                    <url>www.risorsainformativa.gov</url>  
                    <ultima_consultazione/>  
                    <nota>Nessuna nota web</nota> 
                 </pubblicazione> 
              </lista_pubblicazioni>  
              <informatizzazione presente="y"> 
                 <scelta_multipla nome="applicativi_utilizzati"> 
                    <!-- MODIFICATO!! -->  
                    <opz valore="Access (database)"/>  
                    <opz valore="Altro">eXtraWay</opz> 
                 </scelta_multipla>  
                 <partecipazione_sistemi_informativi presente="y"> 
                    <descrizione>x.dams</descrizione> 
                 </partecipazione_sistemi_informativi> 
              </informatizzazione> 
           </risorsa_informativa_nested>  
        </lower_list>  
        <lower_list type="intervento"> 
           <intervento_nested autor_sovraintendenza="y" id="037006-001-2012-i001" in_corso="y"> 
              <!-- intervento 1 per bologna 2012 -->  
              <descrizione>Restauro archivi dei comprensori della provincia di Bologna</descrizione>  
              <scelta_multipla nome="tipologia"> 
                 <opz valore="Riordino"/>  
                 <opz valore="Altro">Pulizia</opz> 
              </scelta_multipla>  
              <avvio>20111101T000000</avvio>  
              <conclusione_prevista>20120701T000000</conclusione_prevista>  
              <conclusione_effettiva/>  
              <autore/>  
              <promotore/>  
              <scelta_multipla nome="standard_descrittivi"> 
                 <opz valore="ISAD"/>  
                 <opz valore="Altro">Descrizione altro standard descrittivo</opz> 
              </scelta_multipla>  
              <informatizzazione presente="y"> 
                 <scelta_multipla nome="applicativo_utilizzato"> 
                    <opz valore="Access (database)"/>  
                    <opz valore="Altro">eXtraWay</opz> 
                 </scelta_multipla>  
                 <partecipazione_sistemi_informativi presente="y"> 
                    <descrizione>x.dams</descrizione> 
                 </partecipazione_sistemi_informativi> 
              </informatizzazione>  
              <bridge_list type="complesso_archivistico"> 
                 <bridge ref="ca001"/> 
              </bridge_list> 
           </intervento_nested>  
        </lower_list>  
        <note/> 
     </patrimonio_archivistico>  
     <note/>
     <?xw-meta Dbms="ExtraWay" DbmsVer="24.3.1" OrgNam="3D Informatica" OrgVer="1.0" Classif="1.0" ManGest="3.1" ManTec="0.0.4" DocType="" InsUser="admin" InsTime="20120910175739" ModUser="rtirabassi" ModTime="20120925145347"?>
     <?xw-crc key32=e324f581-406521b5?>

  </scheda_conservatore>

Ok, now the problem is assuming another aspect. Probably I have to “close” this and pass to another quiestion.

XPath, on the originale (wider) XML document, is correct and now I see where the problem is but have no idea about how to solve it.

  • If I execute just once the XPath expression onto the XML document, I HAVE THE EXPECTED RESULT;
  • If I execute a pretty large sequence of XPath onto the same XML document, complex XPaths (containing condition concerning attribute values) fails (those ones and only those);

So I took a look on how we implemented the XPath evaluation and find that the XPathContext saw never freed. So I changed the code in order to free the context after each XPath evaluation and create a new one everytime but… nothing changes.

Any Idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:36:36+00:00Added an answer on June 11, 2026 at 9:36 pm

    XPath works correctly. You are looking for @id='037006-001-2012-ri002 and the attribute value is 037006-001-2012-ri001. After changing xml to ri002 it matches, libxml returns the correct nodesetval.

    In case it does not really resolve the problem: maybe id attribute is treated in a special way? Try changing it to idx. See Java XML DOM: how are id Attributes special?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.