openSUSE / daps

DocBook Authoring and Publishing Suite (DAPS)
https://openSUSE.github.io/daps
Other
62 stars 19 forks source link

Tags inside entities cause namespace warning #389

Closed LoSong closed 7 years ago

LoSong commented 7 years ago

When using tags inside entities there is a namespace warning when validating or transforming into pdf:

entity.ent

<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY test1 "test1">
<!ENTITY test2 "This is the test for a <guibutton>gui button</guibutton>.">

MAIN-test.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>

<!DOCTYPE chapter [
<!ENTITY % entities SYSTEM "include.ent"> %entities;
]>

<chapter xml:id="test" xml:lang="de_de" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">

  <title>Test Chapter</title>
  <para>This is the test entity "&test1;"</para>
  <para>&test2;</para>
</chapter>

Executing the following command:

user@linux-q86n:~/Documents/DocBook/daps> daps -d DC-test --debug validate

results in the following warning message:

`user@linux-q86n:~/Documents/DocBook/daps> daps -d DC-test --debug validate
Using MAIN file /path/to/Documents/DocBook/daps/xml/MAIN-test.xml
namespace warning : Namespace default prefix was not found
This is the test for a <guibutton>gui button</guib
                                 ^
namespace warning : Namespace default prefix was not found
This is the test for a <guibutton>gui button</guib
                                 ^
---------------

        DAPS VERSION: 2.3.0

             DOC_DIR: /path/to/Documents/DocBook/daps
           BUILD_DIR: /path/to/Documents/DocBook/daps/build
            DAPSROOT: /usr/share/daps
             DOCCONF: /path/to/Documents/DocBook/daps/DC-test
                BOOK: test

           PROFILING: Off

     DOCBOOK_VERSION: 5
        DOCBOOK5_RNG: /usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng
        DBSTYLE_VERS: 1.78.1

           STYLEROOT: /usr/share/xml/docbook/stylesheet/nwalsh5/1.78.1
      STYLEROOT_VERS: Not available
   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 --debug=b -j1 validate 
       XSLTPROCESSOR: /usr/bin/xsltproc
   XML_CATALOG_FILES: /etc/xml/catalog

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

GNU Make 4.0
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
»make«-Steuerdateien werden gelesen...
namespace warning : Namespace default prefix was not found
This is the test for a <guibutton>gui button</guib
                                 ^
namespace warning : Namespace default prefix was not found
This is the test for a <guibutton>gui button</guib
                                 ^
Aktualisieren der Ziele...
 File 'validate' does not exist.
Must remake target 'validate'.
   Validating...
/usr/share/daps/libexec/daps-jing  /usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng /path/to/Documents/DocBook/daps/build/.profiled/noprofile/MAIN-test.xml
java virtual machine used: /usr/lib64/jvm/jre/bin/java
classpath used: /usr/share/java/jing.jar:/usr/share/java/xerces-j2.jar:/usr/share/java/xml-commons-apis.jar:/usr/share/java/saxon6.jar:/usr/share/java/xml-commons-resolver.jar:
main class used: com.thaiopensource.relaxng.util.Driver
flags used:  -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration 
options used:   -Xss3072K 
arguments used: /usr/share/xml/docbook/schema/rng/5.0/docbookxi.rng /path/to/Documents/DocBook/daps/build/.profiled/noprofile/MAIN-test.xml
touch /path/to/Documents/DocBook/daps/build/.profiled/noprofile/.validate
All files are valid.
Successfully remade target file 'validate'.
user@linux-q86n:~/Dokumente/DocBook/daps> 

Nevertheless, the transformation generates a correct pdf.

So it is not that important, but maybe there is a way to eleminate this warning?

DAPS 2.3.0 OpenSuse Leap 42.2 (Virtualbox VM)

ghost commented 7 years ago

Yes, that is a known limitation: you need to add the document namespace to the topmost element(s) in your entities.

fsundermeyer commented 7 years ago

Stefan is right - I consider this a libxml2 bug.

So this works:

  <!ENTITY exampleuser  "
   <systemitem xmlns='http://docbook.org/ns/docbook' class='username'>
    tux
  </systemitem>">

and

  <!ENTITY foo  "
   <para  xmlns='http://docbook.org/ns/docbook'>
    Lorem <emphasis>ipsum</emphasis>
  </para>">

If there are two parent tags, you need to add the namespace declaration for both:

 <!ENTITY baz  "
  <para  xmlns='http://docbook.org/ns/docbook'>
    Lorem <emphasis>ipsum</emphasis>
  </para>
  <para  xmlns='http://docbook.org/ns/docbook'>
    Dolor <emphasis>ipsum</emphasis>
  </para>">

Closing.