docbook-apps

  • 1.  Inheritance of customized generated text

    Posted 10-10-2008 17:31
    For two my projects I would like to share customized gentext and after
    importing this customization layer into next customization layer to perform
    additional changes to gentext, relative to appropriate project. I found
    difficult to set it out properly.
    If in db-common.xsl following changes are specified:
    <i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0">
    <l10n language="en">
    <context name="title">
    <template name="example" text="Example %t"/>
    <template name="informalexample" text="Example"/>
    </context>
    </l10n>
    </i18n>

    and this layer is later imported using <xsl:import href="db-common.xsl"/>
    into next layer with following code:
    <xsl:param name="local.l10n.xml" select="document('')"/>
    <i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0">
    <l10n language="en">
    <context name="title">
    <template name="example" text="%t"/>
    </context>
    </l10n>
    </i18n>

    It seems all db-common changes are ignored and only these from second layer
    are used (i.e. informalexample is unknown). My list of changes is much
    larger so it is quite important. Is there any mistake in my code or
    different approach should be used instead?




  • 2.  Re: [docbook-apps] Inheritance of customized generated text

    Posted 10-10-2008 18:28
    Hi,

    On Freitag, 10. Oktober 2008, honyk wrote:
    > [...]
    > If in db-common.xsl following changes are specified:
    >
    > <i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0">
    > [...]
    > </i18n>
    >
    > and this layer is later imported using <xsl:import
    > href="db-common.xsl"/> into next layer with following code:

    Maybe it sounds picky, but isn't it an XML file? So why use ".xsl" as
    extension when nothing XSL specific is inside?


    > <xsl:param name="local.l10n.xml" select="document('')"/>
    ^^^^^^^^^^^^
    This selects the current stylesheet so the DocBook stylesheets can search
    for any l18n or l10n elements.
    This is useful, if you have your language changes inside the current
    stylesheet. However, you can't use this method in combination with what
    you did. This doesn't work.


    > It seems all db-common changes are ignored and only these from second
    > layer are used (i.e. informalexample is unknown). My list of changes is
    > much larger so it is quite important. Is there any mistake in my code
    > or different approach should be used instead?

    Yes, that's the expected behaviour.

    I would suggest the following:

    1. Do not import your XML file with xsl:import as that is used for
    XSLT files only. In my opinion it's highly confusing.
    2. Rename db-common.xsl to db-common.xml as it is confusing too.
    You fool everybody (including yourself) when the content does
    not fit to the extension
    3. Let "local.l10n.xml" point to your XML file, for example:
    <xsl:param name="local.l10n.xml" select="document('db-common.xml')"/>

    I know, this does not solve your problem. You tried to "overwrite" your
    language changes but as far as I know this is not how this method works.

    Normally you create an XML file and insert only those entries that have to
    appear differently. If you have two different projects, maybe some could
    be shared. If not, you need two separate files.

    More about this topic can you read in
    http://www.sagehill.net/docbookxsl/CustomGentext.html


    Tom

    --
    Thomas Schraitle