docbook-apps

  • 1.  Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 14:05
    Hi,
    i am using docbook xsl 1.78.1 that comes bundled with the oxygem xml editor
    version 16.0. I think there is a problem (a bug?) in handling relative
    filenames defined as entities in the stylesheets for xhtml output.

    I have an article with an image. The image is defined as an unparsed entity,
    its value is an relative filename. Something like


    Used as
    <imagedata entityref="img"/>
    In my article.

    When I try to generate xhtml output, the image is not visible. Problem is,
    that its URL in the generated HTML file is "../../file:/C:/temp/image.png".
    Obviously, it should be "file:/C:/temp/image.png"

    Trying to find the reason, i found that the stylesheets make use of the
    unparsed-entity-uri() function. In this case, this function will return the
    value "file:/C:/temp/image.png".

    Further investigation shows that the rather long template named
    "process.image", defined in file "xhtml/graphics.xsl", generates an element
    which name is given as the value of variable $tag. In my case it's the img
    Element in the HTML file. This starts at line 554.
    Within this Element the value of the @src Attribute is defined (Line 579).
    Basically, it's the value of $output_filename, but in some cases prepended
    by the value of $img.src.path. The important condition is
    "not(contains($output_filename, '://'))". This should check wheter it is an
    absolute filename. However, unparsed-entity returns "
    file:/C:/temp/image.png" with only one slash after the colon. That's why I
    get the concatenation of $img.src.path and $output_filename.

    Conclusion: I think that the condition within the @src-Attribute value
    should read " not(contains($output_filename, ':/'))", that is, only one
    slash after the colon, to catch absolute filenames generated by the
    unparsed-entity-uri() function.

    Transformation is done within oxygen. As far as I can see, it is done with
    the xhtml/profile-docbook.xsl stylesheet using saxon 6.5 engine. Environment
    is windows 7.

    Sincerely,
    Frank Steimke




  • 2.  Re: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 14:34
    On 22.5.2014 16:05, Frank Steimke wrote:
    > I have an article with an image. The image is defined as an unparsed entity,
    > its value is an relative filename. Something like
    >
    >
    > Used as
    > <imagedata entityref="img"/>
    > In my article.

    Is there any reason why you are not using fileref attribute with
    relative path to image? That's more manageable setup.


    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------




  • 3.  RE: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 14:42
    Hi all,

    I am (I think) trying to accomplish the same thing as Frank. I have multiple docs which use the same copy, but require different figures. I was hoping to define those figures in entity files so they would be easier to maintain. The references do not appear to be making it into the docs. This all sounds like what I am trying to do, but not being very familiar, I was hoping someone might offer a high-level explanation of how this is all working? Then perhaps I can understand the presented solutions.




  • 4.  Re: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 15:01
    On 22.5.2014 16:42, Fletcher, Brett wrote:
    > I am (I think) trying to accomplish the same thing as Frank. I have
    > multiple docs which use the same copy, but require different figures.
    > I was hoping to define those figures in entity files so they would be
    > easier to maintain. The references do not appear to be making it into
    > the docs. This all sounds like what I am trying to do, but not being
    > very familiar, I was hoping someone might offer a high-level
    > explanation of how this is all working? Then perhaps I can understand
    > the presented solutions.

    First advice -- try to eliminate usage of entities in your documents. In
    XML entities will give you more troubles then advantages (situation was
    different in SGML where entities were more flexible).

    In your case, you can put each set of images into different directory,
    but using same filenames. Then use following parameter to switch
    directory from which images will be loaded:

    http://docbook.sourceforge.net/release/xsl/current/doc/html/img.src.path.html

    Jirka


    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------




  • 5.  AW: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 15:22
    -- try to eliminate usage of entities in your documents. In XML entities will give you more troubles then advantages

    OK, but as far as I understand, the same problem would come up if I would use a @fileref with an absolute filename like " file:/C:/temp/image.png".

    Question is, whether this is a correct URL for an absolute filename.
    If it is not, then there is a problem with the unparsed-entity-uri() function, since it should never return an invalid URL. This would result in a bug report for saxon 6.5 on windows 7.
    If it is, then there is a problem with the process.image template, since it should be able to process URLs with absolute filenames.

    Thanks,
    Frank




  • 6.  Re: AW: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 15:31
    On 22.5.2014 17:22, Frank Steimke wrote:
    > OK, but as far as I understand, the same problem would come up if I would use a @fileref with an absolute filename like " file:/C:/temp/image.png".

    You shouldn't use absolute filenames because that way your documents are
    not portable.

    > Question is, whether this is a correct URL for an absolute filename.

    It depends on your definition of correctness. At least for Windows paths
    there are several common ways how to construct URL, e.g. file:///c/...,
    file:/c:/..., file:///c|/...

    > If it is not, then there is a problem with the unparsed-entity-uri() function, since it should never return an invalid URL. This would result in a bug report for saxon 6.5 on windows 7.
    > If it is, then there is a problem with the process.image template, since it should be able to process URLs with absolute filenames.

    Absolute file URLs are mess, very different on each operating system.
    But if there is a bug, please feel free to submit bugreport.

    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------




  • 7.  AW: AW: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    Posted 05-22-2014 16:38
    Thank you Jirka,

    actually i am not shure wheter there is a bug, and, if so, i fit is in the stylesheets or in the xslt engine. But the answer should definitively not depend on my own definition of correctness, since this may vary from time to time ...

    I will try to get some help from the oxygen guys.

    Thanks,
    Frank

    -----Ursprüngliche Nachricht-----
    Von: Jirka Kosek [mailto:jirka@kosek.cz]
    Gesendet: Donnerstag, 22. Mai 2014 17:31
    An: Frank Steimke
    Cc: docbook-apps@lists.oasis-open.org
    Betreff: Re: AW: [docbook-apps] Problem with images given as entity in xhtml output (template process.image)

    On 22.5.2014 17:22, Frank Steimke wrote:
    > OK, but as far as I understand, the same problem would come up if I would use a @fileref with an absolute filename like " file:/C:/temp/image.png".

    You shouldn't use absolute filenames because that way your documents are not portable.

    > Question is, whether this is a correct URL for an absolute filename.

    It depends on your definition of correctness. At least for Windows paths there are several common ways how to construct URL, e.g. file:///c/..., file:/c:/..., file:///c|/...

    > If it is not, then there is a problem with the unparsed-entity-uri() function, since it should never return an invalid URL. This would result in a bug report for saxon 6.5 on windows 7.
    > If it is, then there is a problem with the process.image template, since it should be able to process URLs with absolute filenames.

    Absolute file URLs are mess, very different on each operating system.
    But if there is a bug, please feel free to submit bugreport.

    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------