Export to bibTeX format

Help
2005-06-12
2013-05-28
  • Hello,

    I discovered refbase and found it very interesting and useful.

    I am novice with php, regexp and so one.

    When I try to export in Bibtex format I receive a blank page. With xml format, it works very well.

    I read in the file Export_xml2bib.php :

    "Requires the following packages (available under the GPL):
            //    - bibutils
            //    - ActiveLink PHP XML Package
    "
    Ok for the first point.

    About the second I stay perplex : I do not know where to put the required package (or file) in the refbase
    repertory.

    May I receive some help ?

     
    • > When I try to export in Bibtex format I receive a blank page. With
      > xml format, it works very well.

      If you've installed bibutils and provided a correct path on install, you should be fine. The 'ActiveLink PHP XML Package' is provided with the refbase-0.8.0 package (in 'includes/classes'), i.e. you don't need to download this package separately.

      When attempting to export to Bibtex/RIS/Endnote (via bibutils), the resulting page will be blank if:

      - the path to bibutils isn't correct
      - the path to bibutils doesn't end with a slash
      - bibutils can't be accessed by the server (due to incorrect permissions)

      What platform are you running on?

      Another user (being on a Windows system) could solve problems with blank pages by putting bibutils under c:\bibutils and specifying the following path on install:

      C:/bibutils/

      Note that the final forward slash is mandatory.

      If you did install refbase without specifying a path to bibutils you can also supply the path manually by issuing the following command from your MySQL command line interpreter:

      UPDATE literature.depends SET depends_path = '/usr/local/bin/', depends_enabled
      = 'true' WHERE depends_external = "bibutils";

      The above command assumes that your literature database is named 'literature' and your path to bibutils is '/usr/local/bin/', so you'll need to adopt these values to your needs. As noted above, the path spec must end with a slash.

      In addition, there was a user entry in the refbase forums pointing out that the export functions in refbase-0.8.0 may not work correctly on particular systems. A solution is given as well:

        <https://sourceforge.net/forum/message.php?msg_id=3159375>

      Please let us know, if this doesn't help.

      Good luck, Matthias

       
    • Thanks for your answer,

      my platform is FreeBSD-4.10, Apache-2.0.54, PHP4-4.3.11, mysql-4.0.24.

      I will check my configuration according to your answer and give you the results.

      Thanks

      Micercle

       
    • hello,

      bibutils have installed in /usr/local/bin

      the declared path in refbase is /usr/local/bin/

      the rights of bibutils fiile's are 766 and owned to root:wheel.

      They can be executed by all users.

      Only the export xml format works very well. The other expot format get a blank page (or an empty file).

      Bibutils have been compiled by make and make install from the sources (according to the install file of bibutils).

      Is something wrong ? The solution proposed in mail https://sourceforge.net/forum/message.php?msg_id=3159375
      do not solve the probleme.

      Micercle

       
    • the rights of bibutils' files are 755 and not 766.

      Micercle

       
      • :-)

        As they should be.  I have used bibutils export capabilities in freebsd 4 + apache 2.0 + php 4 (though have since upgraded all of these), so it is possible.

        If you have local access to the server, please test xml2bib (preferrably as whoever would execute it in your php/apache chain).

        Can you please also post the contents of your depends mysql table?

         
    • micercle
      micercle
      2005-06-13

      Hello,

      I have tried xml2bib with an export in xml format with the command line xml2bib essai.xml > essai.bib.

      It works very well at the command line as normal user. I read a bibtex file.

      Here is the dump of the table "depends" of my database :

      -- phpMyAdmin SQL Dump
      -- version 2.6.1
      -- http://www.phpmyadmin.net
      --
      -- Serveur: localhost
      -- Gnr le : Lundi 13 Juin 2005  22:00
      -- Version du serveur: 4.0.24
      -- Version de PHP: 4.3.11
      --
      -- Base de donnes: `LICN`
      --

      -- --------------------------------------------------------

      --
      -- Structure de la table `depends`
      --

      CREATE TABLE `depends` (
        `depends_id` mediumint(8) unsigned NOT NULL auto_increment,
        `depends_external` varchar(100) default NULL,
        `depends_enabled` enum('true','false') NOT NULL default 'true',
        `depends_path` varchar(255) default NULL,
        PRIMARY KEY  (`depends_id`)
      ) TYPE=MyISAM AUTO_INCREMENT=3 ;

      --
      -- Contenu de la table `depends`
      --

      INSERT INTO `depends` VALUES (1, 'refbase', 'true', '/usr/local/www/data/');
      INSERT INTO `depends` VALUES (2, 'bibutils', 'true', '/usr/local/bin/');

       
    • Looks all fine to me.

      It's ok for entry 'refbase' in table 'depends' to have 'depends_path' = NULL and it shouldn't matter if you enter anything else. At least it shouldn't matter for the bibutils export.

      What temporary directory is used by PHP on your platform? The file 'export_xml2bib.php' does always assume '/tmp' as temp directory (since I don't know of a smart way to dynamically retrieve the temp directory ?:-/). If this is not what your system uses please edit it accordingly and let us know if this helps.

      What happens if you hard code a fixed path to an existing file in 'export_xml2bib.php' (line 33) an uncomment the following three lines (line 34-36)? Like:

      ...
      $tempFile = "/full/path/to/file/essai.xml";
      // $tempFileHandle...
      // fwrite...
      // fclose...
      ...

      If that doesn't help, try to give a fixed path to '$bibutilsPath' (line 27):

      $bibutilsPath = "/full/path/to/bibutils/directory/";

      Otherwise I have no idea right now what could cause your problem but I'll think about it again...

      Matthias

       
      • By default, it should be /tmp like everything else.  Check the TMPDIR system variable to be sure.

        However, a good change would be to use the tempnam function.  This will make a file with a unique name in the system's temporary directory & return the name of that file.

         
    • micercle
      micercle
      2005-06-14

      hello

      "What happens if you hard code a fixed path to an existing file in 'export_xml2bib.php' (line 33) an uncomment the following three lines (line 34-36)? Like:

      ...
      $tempFile = "/full/path/to/file/essai.xml";
      // $tempFileHandle...
      // fwrite...
      // fclose...
      ...
      "
      do not make anything

      "
      to give a fixed path to '$bibutilsPath' (line 27):

      $bibutilsPath = "/full/path/to/bibutils/directory/";
      "
      do not make anything too. :-( !

      The TMPDIR system variable is /tmp. The soft is able to write refbase-xxxxx in the /tmp directory but their are all empty.

      It seems that it is not allowed to write the results of selected item between <pre> and </pre> in the script search.php.

      $exportText = "\n\t<pre>\n" . encodeHTML($exportText) . "\n\t</pre>\n</body>\n</html>\n"; (line 1328, export_xml2bib.php)

      Is the variable $recordCollection empty in the statement fwrite($tempFileHandle, $recordCollection); (line 36, export_xml2bib.php) ?

      PS is encodeHTML a selfmade function ? I did not found it in the php documentation (www.php.net).

      Well, well .....

       
      • encodeHTML is a custom function in include.inc.php, but all it does is to return:
        htmlentities($sourceString, ENT_COMPAT, "$contentTypeCharset");

        Where $contentTypeCharset is defined in ini.inc.php (do you have it set to ISO-8859-1 or UTF-8?)

         
      • refbase-xxxx should contain the MODS records.

         
      • > > What happens if you hard code a fixed path to an existing file in
        > > 'export_xml2bib.php' (line 33) an uncomment the following three
        > > lines (line 34-36)? Like:

        > > $tempFile = "/full/path/to/file/essai.xml";
        >
        > do not make anything

        That's strange. If you're able to execute 'xml2bib' manually then the command (in file 'export_xml2bib.php'):

        exec($bibutilsPath . "xml2bib " . $tempFile, $resultArray);

        should work as well, especially when you simply provide full paths to
        - an existing (and resolvable) XML source file
        - the 'xml2bib' program

        Try copying the code below into a new (executable) file in your web directory and call it via the browser:

        <?php
          $bibutilsPath = "/usr/local/bin/"; // path to bibutils directory
          $xmlSourceFile = "/path/to/file"; // path to XML source file
          exec($bibutilsPath . "xml2bib " . $xmlSourceFile, $resultArray);
          echo implode("\n", $resultArray);
        ?>

        (note that you must adopt the path specs in the code above to your setup!)

        This should convert your XML source file to Bibtex and write the output to the browser window.

        > The TMPDIR system variable is /tmp. The soft is able to write
        > refbase-xxxxx in the /tmp directory but their are all empty.

        Hmm, maybe that's the problem. What are the permissions for the /tmp folder and/or the "refbase-" tmp files?

        > It seems that it is not allowed to write the results of selected
        > item between <pre> and </pre> in the script search.php.

        XML output is only enclosed in HTML when you choose 'html' from the "return as" drop down. It's not what is passed to bibutils (which sees only the MODS XML) and shouldn't matter in your case.

        > Is the variable $recordCollection empty in the statement
        > fwrite($tempFileHandle, $recordCollection);

        '$recordCollection' should contain your MODS XML data. You can verify that it actually contains your XML data by inserting the following two lines after line 30 in file 'export_xml2bib.php':

        echo $recordCollection;
        exit;

        > PS is encodeHTML a selfmade function ?

        Yes, but currently it simply calls:

        htmlentities($sourceString, ENT_COMPAT, "$contentTypeCharset");

        with '$contentTypeCharset' being defined in file 'ini.inc.php'. This shouldn't matter in case of your problems, though.

        Sorry that this is causing you so man trouble,

        Matthias

         
    • micercle
      micercle
      2005-06-14

      Hello,

      The modification :
      "
      $recordCollection' should contain your MODS XML data. You can verify that it actually contains your XML data by inserting the following two lines after line 30 in file 'export_xml2bib.php':

      echo $recordCollection;
      exit;
      "
      works well : the XML data appear correctly.

      rights of /tmp and refbase-xxx are :
      drwxrwxrwt  13 root  wheel    16384 Jun 14 16:50 tmp/
      -rw-------   1 www       wheel        0 Jun 14 16:44 refbase-2eYEEG

      the refbase directory is in /usr/local/www/data

      and the rights are
      drwxr-xr-x  15 micercle  www

      I suspect some rights are not correct

      Micercle

       
    • Your permissions seem to be fine. They are the same as on my machine.

      If '$recordCollection' contains your records as XML data and the temp file gets written but is empty, then something must go wrong when writing data to the file:

      $tempFileHandle = fopen($tempFile, "w");
      fwrite($tempFileHandle, $recordCollection);
      fclose($tempFileHandle);

      I have actually no clue what could cause problems here.

      Does the little script (which I gave you in my last post) work correctly? This would also prove that the problem must be somehow connected with the temp file since it's the only variable left out (if I'm not missing something here).

      Matthias

       
    • micercle
      micercle
      2005-06-15

      I did not answer a question : I use  ISO-8859-1 Charset.
      (I do not use mysql-4.1.x but 4.0.23 or 24)

      Matthias, the script you gave me works correctly. I see the contents of the variable $recordCollection.

      question : the requirements in php.ini are magic_quotes_gpc, session.use_cookies to on or 1 and the uploads_file_size. Is there others requirements in php.ini, or in httpd.conf ? (safe_mode or somethings else ?)

      Micercle

       
      • MySQL 4.1 is only required for Unicode support, your MySQL version is fine for use with ISO-8859-1.

        > the script you gave me works correctly. I see the contents of the
        > variable $recordCollection.

        I mean the following code copied into a new file inside your web directory:

        <?php
        $bibutilsPath = "/usr/local/bin/"; // path to bibutils directory
        $xmlSourceFile = "/path/to/file"; // path to XML source file
        exec($bibutilsPath . "xml2bib " . $xmlSourceFile, $resultArray);
        echo implode("\n", $resultArray);
        ?>

        Please adopt the "/path/to/file" so that it points to an existing and well-formed MODS XML file (if you don't have one I could send you an example file). Then execute this script via your browser. Do you get Bibtex entries returned from it?

        AFAIK, there are no other requirements in 'php.ini' as those that you've already mentioned. We don't require anything special in 'httpd.conf'

        Matthias

         
    • Is safe_mode enabled on your system? Have you tried to export some records to Bibtex with safe_mode = Off?

      Matthias

       
    • From the PHP site:

      "When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir."

      If you need or want to keep safe_mode = ON in 'php.ini' then have you tried putting the bibutils programs within the safe_mode_exec_dir? Of course, you'll have to adopt the value for  'depends_path' in table 'depends' then.

      Matthias

       
    • micercle
      micercle
      2005-06-15

      Ok, I found the mistake : safe_mode was enabled and not safe_mode_exec_dir and do on.

      I disabled safe_mode and I may obtain the bibtex format export.

      some time php is not very "friendly" :-)

      Thanks for your attention and your help

       
    • micercle
      micercle
      2005-06-15

      Well, the fault may be shared, I could think too of safe_mode. I am not an php expert but I tried to read some litterature about it and about php.ini.

      I contributed to add a note in the documentation :-) It is the positif point of view of these discussion.