This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] mulitple


It's possible to do what you want, but it gets a little complicated.  As you
discovered, a global parameter like local.l10n.xml can't be declared more
than once at the same import level.  What you have to do is put each into
its own uniquely named parameter or variable, and then merge them into a
single node set stored in the parameter named 'local.l10n.xml'.

Here are two samples that would appear in different files, one for chapter
and one for appendix, each with a different parameter name:

<xsl:param name="first.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
  <l:l10n language="en">
   <l:context name="title-numbered">
      <l:template name="chapter" text="EnglishChapter&#160;%n.&#160;%t"/>
   </l:context>
  </l:l10n>
  <l:l10n language="nl">
   <l:context name="title-numbered">
      <l:template name="chapter" text="DutchChapter&#160;%n.&#160;%t"/>
   </l:context>
  </l:l10n>
</l:i18n>

<xsl:param name="second.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
  <l:l10n language="en">
   <l:context name="title-numbered">
      <l:template name="appendix" text="EnglishAppendix&#160;%n.&#160;%t"/>
   </l:context>
  </l:l10n>
  <l:l10n language="nl">
   <l:context name="title-numbered">
      <l:template name="appendix" text="DutchAppendix&#160;%n.&#160;%t"/>
   </l:context>
  </l:l10n>
</l:i18n>

These can be merged as follows:

<xsl:param name="local.l10n.merged">
  <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
    <l:l10n language="en">
      <xsl:copy-of
select="$first.l10n.xml//l:i18n/l:l10n[@language='en']/*"/>
      <xsl:copy-of
select="$second.l10n.xml//l:i18n/l:l10n[@language='en']/*"/>
    </l:l10n>
    <l:l10n language="nl">
      <xsl:copy-of
select="$first.l10n.xml//l:i18n/l:l10n[@language='nl']/*"/>
      <xsl:copy-of
select="$second.l10n.xml//l:i18n/l:l10n[@language='nl']/*"/>
    </l:l10n>
  </l:i18n>
</xsl:param>

<xsl:param name="local.l10n.xml"
select="exsl:node-set($local.l10n.merged)"/>

The merger process requires you to set up a new element for l:i18n, and an
l:l10n element for each language, and then copy the nodes for each language
into its l:l10n element. All this goes into a temporary variable that I
named 'local.l10n.merged'.

The last step converts the merged elements into a genuine node-set so that
the DocBook templates can query the data with XPath expressions.  This has
to be done because the act of merging the elements into a parameter this way
converts the node-set delivered by the document() function into a result
tree fragment, which can't be queried with XPath.

This solution isn't very elegant, because it requires you to keep track of
all the pieces in different parameter names so you can merge them.  But it
does work.  I just wonder if it would be simpler to just put them all in one
place.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Wim Lemkens" <wim.lemkens@tiscali.be>
To: <docbook-apps@lists.oasis-open.org>
Sent: Saturday, July 10, 2004 6:14 PM
Subject: [docbook-apps] mulitple


> Hello,
>
> I have an extension that includes  the standard docbook and 2 other .xsl
> sheets. In those 2 sheets I both have some localizations for my templates.
>
> I declared the this way:
> <xsl:param name="local.l10n.xml" select="document('')"/>
> <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
>   <l:l10n language="nl">
>     <l:context name="title">
>       <l:template name="something" text="Iets"/>
>     </l:context>
>   </l:l10n>
>   <l:l10n language="en">
>     <l:context name="title">
>       <l:template name="something" text="Something"/>
>     </l:context>
>   </l:l10n>
> </l:i18n>
>
> But it seems that my second sheet overwrites the definitions of my first
> sheet. How should I declare it, so that I am able to keep de declarations
in
> these seperate documents?
>
>
> Thanks,
>
> Wim Lemkens
>
> To unsubscribe from this list, send a post to
docbook-apps-unsubscribe@lists.oasis-open.org, or visit
http://www.oasis-open.org/mlmanage/.
>
>
>



To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]