Menu

Fail to include external files.

Anonymous
2017-07-13
2017-07-13
  • Anonymous

    Anonymous - 2017-07-13

    Hello, I'm trying to include some external files in my Docbooks files, but have issues with daps or docbook. I've been following some tutorials/guides and everything I try it fails. Following are some try/errors based on some Docbook/Daps guides. Still can't find the way to include external files. Please help me with light to my knowledge darkness.

    Some words are in polish, don't know why. I added in my opensuse leap 42.2 polish input keyboard but I don't expect that outputs are in polish too.

    Example 1: Using Entities from http://tdg.docbook.org/tdg/5.0/ch02.html#ch02-physdiv
    -----------------------------------------------------------------------
    File: Glosario-Gestos.xml
    -----------------------------------------------------------------------
    <glossary>
    
        <title>Gestos</title>
        ...
    </glossary>
    
    -----------------------------------------------------------------------
    File: MAIN-Requirimientos.xml
    -----------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE book [
    <!ENTITY glosario-gestos SYSTEM "Glosario-Gestos.xml" >
    ]>
    <book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="es">
    
        ...
    
        &glosario-gestos;
    
    </book>
    
    -----------------------------------------------------------------------
    Output:
    patricio@patriciodesktop:~/Docbook> daps -d DC-requerimientos -vv pdf
    Using MAIN file /home/patricio/Docbook/xml/MAIN-requerimientos.xml
    warning: failed to load external entity "Glosario-Gestos.xml"
    /home/patricio/Docbook/xml/MAIN-requerimientos.xml:556: parser error : Failure to process entity glosario-gestos
        &glosario-gestos;
                         ^
    /home/patricio/Docbook/xml/MAIN-requerimientos.xml:556: parser error : Entity 'glosario-gestos' not defined
        &glosario-gestos;
                         ^
    unable to parse /home/patricio/Docbook/xml/MAIN-requerimientos.xml
    ERROR: Could not get DocBook version. Maybe /home/patricio/Docbook/xml/MAIN-requerimientos.xml is not well-formed?
    patricio@patriciodesktop:~/Docbook>
    =======================================================================
    
    
    Example 2: Using XInclude from http://tdg.docbook.org/tdg/5.0/ch02.html#ch02-physdiv
    -----------------------------------------------------------------------
    File: Glosario-Gestos.xml
    -----------------------------------------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE glossary>
    <glossary>
    
        <title>Gestos</title>
        ...
    
    </glossary>
    
    -----------------------------------------------------------------------
    File: MAIN-Requerimientos.xml
    -----------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE book>
    <book xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.0" xml:lang="es">
    
        ...
    
        <xi:include href="Glosario-Gestos.xml" />
    
    </book>
    
    -----------------------------------------------------------------------
    Output:
    patricio@patriciodesktop:~/Docbook> daps -d DC-requerimientos -vv pdf
    Using MAIN file /home/patricio/Docbook/xml/MAIN-Requerimientos.xml
    ---------------
    
            DAPS VERSION: 2.3.0
    
                 DOC_DIR: /home/patricio/Docbook
               BUILD_DIR: /home/patricio/Docbook/build
                DAPSROOT: /usr/share/daps
                 DOCCONF: /home/patricio/Docbook/DC-requerimientos
                    BOOK: requerimientos
    
               PROFILING: Off
    
         DOCBOOK_VERSION: 5
            DOCBOOK5_RNG: /usr/share/xml/docbook/schema/rng/5.1/docbookxi.rng
            DBSTYLE_VERS: 1.78.1
    
               STYLEROOT: /home/patricio/Personalizacion
          STYLEROOT_VERS: Not available
      FALLBACK_STYLEROOT: /usr/share/xml/docbook/stylesheet/nwalsh5/1.78.1
       FB_STYLEROOT_VERS: Not available
                EPUB_CSS: 
                HTML_CSS: 
    
           PDF FORMATTER: fop
       FORMATTER WRAPPER: /usr/share/daps/libexec/daps-fop
        FORMATTER CONFIG: 
    
                MAKE_CMD: /usr/bin/make -f /usr/share/daps/make/selector.mk -j2 -s pdf 
           XSLTPROCESSOR: /usr/bin/xsltproc
       XML_CATALOG_FILES: /etc/xml/catalog
    
    ---------------
    
       Profiling /home/patricio/Docbook/xml/Glosario-Gestos.xml   Validating...
    /home/patricio/Docbook/build/.profiled/noprofile/MAIN-Requerimientos.xml:551:45: warning: Include operation failed, reverting to fallback. Resource error reading file as XML (href='Glosario-Gestos.xml'). Reason: no protocol: Glosario-Gestos.xml
    /home/patricio/Docbook/build/.profiled/noprofile/MAIN-Requerimientos.xml:551:45: fatal: An 'include' failed, and no 'fallback' element was found.
    /usr/share/daps/make/validate.mk:35: polecenia dla obiektu '/home/patricio/Docbook/build/.profiled/noprofile/.validate' nie powiodły się
    make: *** [/home/patricio/Docbook/build/.profiled/noprofile/.validate] Błąd 1
    
    =======================================================================
    
    
    Example 3: Using XInclude from https://opensuse.github.io/daps/doc/cha.daps.user.features.html#sec.daps.user.basics.multiple
    -----------------------------------------------------------------------
    File: Glosario-Gestos.xml
    -----------------------------------------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE glossary>
    <glossary>
    
        <title>Gestos</title>
        ...
    
    </glossary>
    
    -----------------------------------------------------------------------
    File: MAIN-Requirimientos.xml
    -----------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE book>
    <book xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="es">
    
        ...
    
        <xi:include href="Glosario-Gestos.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
    
    </book>
    
    -----------------------------------------------------------------------
    Output:
    patricio@patriciodesktop:~/Docbook> daps -d DC-requerimientos -vv pdf
    Using MAIN file /home/patricio/Docbook/xml/MAIN-requerimientos.xml
    ---------------
    
            DAPS VERSION: 2.3.0
    
                 DOC_DIR: /home/patricio/Docbook
               BUILD_DIR: /home/patricio/Docbook/build
                DAPSROOT: /usr/share/daps
                 DOCCONF: /home/patricio/Docbook/DC-requerimientos
                    BOOK: requerimientos
    
               PROFILING: Off
    
         DOCBOOK_VERSION: 5
            DOCBOOK5_RNG: /usr/share/xml/docbook/schema/rng/5.1/docbookxi.rng
            DBSTYLE_VERS: 1.78.1
    
               STYLEROOT: /home/patricio/Personalizacion
          STYLEROOT_VERS: Not available
      FALLBACK_STYLEROOT: /usr/share/xml/docbook/stylesheet/nwalsh5/1.78.1
       FB_STYLEROOT_VERS: Not available
                EPUB_CSS: 
                HTML_CSS: 
    
           PDF FORMATTER: fop
       FORMATTER WRAPPER: /usr/share/daps/libexec/daps-fop
        FORMATTER CONFIG: 
    
                MAKE_CMD: /usr/bin/make -f /usr/share/daps/make/selector.mk -j2 -s pdf 
           XSLTPROCESSOR: /usr/bin/xsltproc
       XML_CATALOG_FILES: /etc/xml/catalog
    
    ---------------
    
       Profiling /home/patricio/Docbook/xml/MAIN-requerimientos.xml   Validating...
    /home/patricio/Docbook/build/.profiled/noprofile/MAIN-requerimientos.xml:551:88: warning: Include operation failed, reverting to fallback. Resource error reading file as XML (href='Glosario-Gestos.xml'). Reason: no protocol: Glosario-Gestos.xml
    /home/patricio/Docbook/build/.profiled/noprofile/MAIN-requerimientos.xml:551:88: fatal: An 'include' failed, and no 'fallback' element was found.
    /usr/share/daps/make/validate.mk:35: polecenia dla obiektu '/home/patricio/Docbook/build/.profiled/noprofile/.validate' nie powiodły się
    make: *** [/home/patricio/Docbook/build/.profiled/noprofile/.validate] Błąd 1
    
    =======================================================================
    

    Just a note aside: In this example https://opensuse.github.io/daps/doc/cha.daps.user.modular.html#ex.daps.ent.decl.separate.multi code have "<ENTITY:.." (1) while in descripción say explicit "(1) <!ENTITY....", what happen to "!" char ?

    Thanks in advance

     
    • Thomas Schraitle

      Hi Patricio,

      thanks for your detailed report! Much appreciated.

      Some comments though:

      • I would try to avoid example 1 (external entities) and always use XIncludes (example 2).
      • In example 2, file Glosario-Gestos.xml is missing the DocBook5 namespace and a version attribute ( for example, version="5.1")

      I have also some questions:

      • Are all XML files stored in the directory xml/?
      • Where does the xi:include element in example 2 appear? I mean, does it appear directly as a child element under book or is it deeper nested?
      • Have you tried it with the latest DAPS version 2.4.0? (according from the log, you use version 2.3.0)
      • Do you have a public repository where we can see all the files?

      I've tried to confirm this and created a small project from scratch, used your names and the structure (as I could see it). Well, it works for me...

      Just a note aside: In this example https://opensuse.github.io/daps/doc/cha.daps.user.modular.html#ex.daps.ent.decl.separate.multi code have "<ENTITY:.." (1) while in descripción say explicit "(1) <!ENTITY....", what happen to "!" char ?

      Good catch, this is a missing "!" char. I've committed the fix to https://github.com/openSUSE/daps/commit/8d7fc3775

      Thanks!

       
  • Anonymous

    Anonymous - 2017-07-13

    Hi, it's me again, Patricio.
    Thanks for your reply, I have to say about it that:

    • Ok, will avoid entitites.
    • I've added in this way:
      <glossary xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.1" xml:lang="es">
      but still error.</glossary>

    To your questions:

    • are inside same xml folder: MyDocs/xml/Glosario-Gestos.xml and MyDocs/xml/Main.....xml
    • Inside book as direct child: <book> <xinclude:......></xinclude:......></book>
    • No, will wait to openSUSE Leap 42.3 to reinstall my system (two weeks), hope it have the new version. Where can I try the latest anyway?
    • Nop, all are private repos :-/

    Seems is a parser problem that needs a protocol like "http://..." or "file://" inside href ?
    Thanks again.

     
    • Thomas Schraitle

      Hi Patricio,

      thanks for your answer.

      are inside same xml folder: MyDocs/xml/Glosario-Gestos.xml and MyDocs/xml/Main.....xml

      Ok, that's good.

      Inside book as direct child: <book> <xinclude:......></xinclude:......></book>

      Hmn, just a guess: it seems to me, you are missing a title element. This is mandatory. If your main file is not valid, the whole xinclude and postvalidation process will fail.

      Try the following structure in your main file:

      <book xml:id="mybook" xml:lang="es" version="5.1"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns="http://docbook.org/ns/docbook">
       <title>Your Title</title>
      <!-- <subtitle>Optional subtitle</subtitle> -->
       <info>
        <!-- Possible optional meta information like
                       author, copyright, date, legalnotice, ... etc.
         -->
       </info>
      
       <xi:include href="Glosario-Gestos.xml" />
      </book>
      

      No, will wait to openSUSE Leap 42.3 to reinstall my system (two weeks), hope it have the new version. Where can I try the latest anyway?

      Have you used https://software.opensuse.org/distributions/tumbleweed ?
      Once installed, you can upgrade to the latest version with zypper dup, see https://en.opensuse.org/SDB:System_upgrade

      Nop, all are private repos :-/

      If you can't share your private text, maybe you can replace all text with "X"? This may still reveal the structure, but the original text is not readable anymore. If you like, you can sent me an archive and I can look at it.

      To do so, I've written an obfuscate stylesheet which you can download from here:
      https://github.com/openSUSE/daps/blob/develop/daps-xslt/contrib/obfuscate.xsl

      To apply the obfuscate.xsl, use the stylesheet with the following shell commands:

      cd YOUR_PROJECT
      wget https://raw.githubusercontent.com/openSUSE/daps/develop/daps-xslt/contrib/obfuscate.xsl
      mv xml xml.orig
      mkdir xml
      for file in xml.orig/*.xml; do
          echo "Processing ${file##*/}..."
          xsltproc --output xml/${file##*/} obfuscate.xsl $file
      done
      daps -d DC-requerimientos package-src
      # Check if the files in xml/*.xml contains only "X" characters
      tar tvf build/requerimientos/package/requerimientos_es_src_set.tar.bz2
      

      After you've successfully created the tar archive, sent it to me (toms AT suse DOT de). This makes it a bit easier to find the problem.

      Seems is a parser problem that needs a protocol like "http://..." or "file://" inside href ?

      No, the href can hold just a filename or a URL.

      Hope that helps.

      Thanks,
      Tom

       

      Last edit: Thomas Schraitle 2017-07-14
  • Anonymous

    Anonymous - 2017-07-14

    Hi, book have corresponding title tag too.

    Data sent. Thanks for your support :)

     
  • Thomas Schraitle

    After I've got the archive I could solve this. It has to do with an Unicode/UTF-8 character inside the filename.

    I haven'd found the tool to blame, but for the time being, it is probably a good idea to stick to ASCII-only filenames.

    Thanks Patricio for this bug report. Filed it as https://github.com/openSUSE/daps/issues/416

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB