actionshrimp / vim-xpath

XPath search plugin for Vim
47 stars 8 forks source link

Proper XPath throws error #11

Closed welblaud closed 8 years ago

welblaud commented 8 years ago

I am trying to set up vim-xpath—during initial tests with a simple TEI XML file, I have met this error:

Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
Traceback (most recent call last):

The path: /default:TEI/default:text/default:body/default:div/default:head

Up to the default:div it works well, the default:head triggers the error.

Any hints?

actionshrimp commented 8 years ago

Hey - just gave this a go myself (using v3.5 of lxml) and don't get an error with that XPath - are you able to post a minimal XML snippet that replicates? Also was there any more of the error message (below the Traceback (most recent call last):) line you posted? That should be the stack trace from the underlying python library which might be helpful.

welblaud commented 8 years ago

Thanks, ok, the whole error after confirming the vim’s prompt repeatedly looks:

Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
Traceback (most recent call last):
Press ENTER or type command to continue
Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
  File "<string>", line 1, in <module>
Přerušení: Press ENTER or type command to continue
Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
  File "/home/honza/.vim/bundle/vim-xpath/python/vim_adaptor.py", line 43, in evaluate_xpath
Press ENTER or type command to continue
Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
    loc_list.add_error_entry(e.msg)
Přerušení: Press ENTER or type command to continue
Chyba při zpracování function <SNR>40_XPathChanged..XPathEvaluate:
řádek    3:
AttributeError: 'exceptions.UnicodeEncodeError' object has no attribute 'msg'

As for minimal example:

<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" rendition="simple:simple">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title/>
        <author>FFUK</author>
      </titleStmt>
      <editionStmt>
        <edition>
          <date>2015-11-26</date>
        </edition>
      </editionStmt>
      <publicationStmt>
        <p>unknown</p>
      </publicationStmt>
      <sourceDesc>
        <p>Converted from a Word document</p>
      </sourceDesc>
    </fileDesc>
    <encodingDesc>
      <appInfo>
        <application xml:id="docxtotei" ident="TEI_fromDOCX" version="2.15.0">
          <label>DOCX to TEI</label>
        </application>
      </appInfo>
    </encodingDesc>
    <revisionDesc>
      <listChange>
        <change>
          <date>2015-12-10T10:27:16Z</date>
          <name>FFUK</name>
        </change>
      </listChange>
    </revisionDesc>
  </teiHeader>
  <text>
    <body xml:lang="cs">
      <div n="1">
        <head>ÚVOD</head>
        <p>Předkládaná publikace je upravenou a doplněnou verzí dizertační práce „Římsko-germánské vztahy      a kontakty ve světle nálezů předmětů římské provenience v Čechách, zvláště terry sigillaty“ (vedoucí prá     ce doc. PhDr. Lubomír Košnar, Csc.; oponenti: Dr. Lubomira Tyszler a doc. PhDr. Jiří Musil, Ph.D.), která      byla obhájena v roce 2012 v Ústavu pro archeologii Filozofické fakulty Univerzity Karlovy v Praze.</p>
        <p>Práce byla v letech 2011–2012 významně podpořena stipendiem Gerharda Bersu (Stiftung Pro Archa     eologia Saxoniae, Landesamt für Archäologie mit Landesmuseum für Vorgeschichte, Dresden), udělovaného vyb     raným řešitelům dizertačních prací v oboru archeologie, geograficky spadajících do oblasti Saska, Čech neb     o polské Lužice.</p>
      </div>
    </body>
  </text>
</TEI>
actionshrimp commented 8 years ago

Ah yep, that gives me the same error. I'll take a look

actionshrimp commented 8 years ago

Values from the XPath evaluation weren't being encoded properly on the way back into vim so I've sorted that in dedf1a8fa61b7d2715f97892df8b23b412312dc8. Also certain error messages which were thrown up into vim before should now be printed into the evaluation results list which makes it a bit less jarring if there's a problem.

Going to close this now, feel free to reopen if it's still causing you issues though.

welblaud commented 8 years ago

Thanks, it works!

2015-12-12 14:05 GMT+01:00 Dave Aitken notifications@github.com:

Hey - just gave this a go myself (using v3.5 of lxml) and don't get an error with that XPath - are you able to post a minimal XML snippet that replicates? Also was there any more of the error message (below the Traceback (most recent call last):) line you posted? That should be the stack trace from the underlying python library which might be helpful.

— Reply to this email directly or view it on GitHub https://github.com/actionshrimp/vim-xpath/issues/11#issuecomment-164148505 .