Re: DocBook Assemblies: is xml:lang considered in <structure>?

Bob Stayton <[email protected]> Thu, 20 Apr 2023 11:41:15 -0700
Newsgroups gmane.text.docbook.misc
Message-ID <[email protected]>
--------------zrmMB0SYLmray9CslwEHoN87
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hi Thomas,

Indeed, the xml:lang on structure should be carried into the output 
because there is no other way to set that attribute on the root 
element.  That is an oversight.

The <output> element is not appropriate because its intended to alter 
the behavior of the assembly transformation, not insert additional 
content.  So the answer to question #1 is that xml:lang on output will 
have no effect so there is no conflict.

Regarding injecting other attributes (question #2), that is not 
currently a feature defined for assemblies.  Most attributes should 
reside in the resource xml, not specified in the assembly.  Attributes 
like role and os should reside in the resource XML file, it seems to 
me.  Defining those on the fly at assembly time is not a use case I can 
imagine.

That said, the DocBook TC could not imagine all the ways that people 
might use assemblies.  The assembly stylesheet can be customized to 
insert attributes if you need that.

Bob

On 4/19/2023 12:17 AM, Thomas Schraitle wrote:
> Hi,
>
> currently I'm trying to inject language information from a <structure> 
> element,
> but it doesn't work as expected. Either I'm doing something completely 
> wrong or
> this is a bug.
>
> Let's assume I have an assembly structure like this:
>
> ----
> <assembly version="5.2" xml:lang="en"
>     xmlns="http://docbook.org/ns/docbook"
>     xmlns:xlink="http://www.w3.org/1999/xlink"
>     xmlns:xi="http://www.w3.org/2001/XInclude"
>     xmlns:tr="http://docbook.org/ns/transclusion">
>   <resources>
>      <!-- ...pruned... -->
>   </resources>
>
>   <structure>
>      <!-- ... modules comes here ... -->
>   </structure>
> </assembly>
> ----
>
> The real content of <resources> and <structure> isn't that important 
> for this
> post. Let's focus entirely on <structure>. As you can see, it doesn't 
> contain a
> resourceref attribute.
>
> When I call the assemble.xsl stylesheet I get the result file. So far, 
> so good.
>
> However, the result file doesn't contain any language. That was to be 
> expected,
> because we didn't set one. So in my naive view I thought I just add the
> language information to <structure> like this:
>
>   <structure xml:lang="en">
>
> However, this isn't taken into account. My next try was to add it to 
> <output/>:
>
>   <structure>
>     <output xml:lang="en"/>
>
> This also has no effect.
>
> I've looked into the assemble.xsl stylesheet and it seems this was an 
> oversight
> in the following line:
>
> https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/assembly/assemble.xsl#L137 
>
>
> If I change it to this line, it works:
>
>   <xsl:copy-of select="@xml:id|@xml:lang"/>
>
> Can someone confirm this?
> If this is true, it means an author cannot set a language (or other 
> attributes)
> on the output.
>
> I have two additional questions:
>
> 1. What if we have _two_ xml:lang attributes, both on <structure> and on
>    <output>. Which wins? Which has the higher priority?
>    Is that specified or defined anywhere?
>
> 2. What if an author wants to inject other attributes like role, os, 
> or others?
>    Where it is supposed to be inserted? Also same as point 1, who wins 
> when we
>    have the same attributes?
>
>
> Thanks for your idea and answers!
>
>
> -- 
> Gruß/Regards
>   Thomas Schraitle
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--------------zrmMB0SYLmray9CslwEHoN87
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">Hi
          Thomas,</font></font></p>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">Indeed,
          the xml:lang on structure should be carried into the output
          because there is no other way to set that attribute on the
          root element.  That is an oversight.  <br>
        </font></font></p>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">The
          &lt;output&gt; element is not appropriate because its intended
          to alter the behavior of the assembly transformation, not
          insert additional content.  So the answer to question #1 is
          that xml:lang on output will have no effect so there is no
          conflict.</font></font></p>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">Regarding
          injecting other attributes (question #2), that is not
          currently a feature defined for assemblies.  Most attributes
          should reside in the resource xml, not specified in the
          assembly.  Attributes like role and os should reside in the
          resource XML file, it seems to me.  Defining those on the fly
          at assembly time is not a use case I can imagine.<br>
        </font></font></p>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">That
          said, the DocBook TC could not imagine all the ways that
          people might use assemblies.  The assembly stylesheet can be
          customized to insert attributes if you need that.</font></font></p>
    <p><font size="2"><font face="Helvetica, Arial, sans-serif">Bob</font></font><br>
    </p>
    <div class="moz-cite-prefix">On 4/19/2023 12:17 AM, Thomas Schraitle
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">Hi,
      <br>
      <br>
      currently I'm trying to inject language information from a
      &lt;structure&gt; element,
      <br>
      but it doesn't work as expected. Either I'm doing something
      completely wrong or
      <br>
      this is a bug.
      <br>
      <br>
      Let's assume I have an assembly structure like this:
      <br>
      <br>
      ----
      <br>
      &lt;assembly version="5.2" xml:lang="en"
      <br>
          xmlns=<a class="moz-txt-link-rfc2396E" href="http://docbook.org/ns/docbook">"http://docbook.org/ns/docbook"</a>
      <br>
          xmlns:xlink=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xlink">"http://www.w3.org/1999/xlink"</a>
      <br>
          xmlns:xi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XInclude">"http://www.w3.org/2001/XInclude"</a>
      <br>
          xmlns:tr=<a class="moz-txt-link-rfc2396E" href="http://docbook.org/ns/transclusion">"http://docbook.org/ns/transclusion"</a>&gt;
      <br>
        &lt;resources&gt;
      <br>
           &lt;!-- ...pruned... --&gt;
      <br>
        &lt;/resources&gt;
      <br>
      <br>
        &lt;structure&gt;
      <br>
           &lt;!-- ... modules comes here ... --&gt;
      <br>
        &lt;/structure&gt;
      <br>
      &lt;/assembly&gt;
      <br>
      ----
      <br>
      <br>
      The real content of &lt;resources&gt; and &lt;structure&gt; isn't
      that important for this
      <br>
      post. Let's focus entirely on &lt;structure&gt;. As you can see,
      it doesn't contain a
      <br>
      resourceref attribute.
      <br>
      <br>
      When I call the assemble.xsl stylesheet I get the result file. So
      far, so good.
      <br>
      <br>
      However, the result file doesn't contain any language. That was to
      be expected,
      <br>
      because we didn't set one. So in my naive view I thought I just
      add the
      <br>
      language information to &lt;structure&gt; like this:
      <br>
      <br>
        &lt;structure xml:lang="en"&gt;
      <br>
      <br>
      However, this isn't taken into account. My next try was to add it
      to &lt;output/&gt;:
      <br>
      <br>
        &lt;structure&gt;
      <br>
          &lt;output xml:lang="en"/&gt;
      <br>
      <br>
      This also has no effect.
      <br>
      <br>
      I've looked into the assemble.xsl stylesheet and it seems this was
      an oversight
      <br>
      in the following line:
      <br>
      <br>
<a class="moz-txt-link-freetext" href="https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/assembly/assemble.xsl#L137">https://github.com/docbook/xslt10-stylesheets/blob/master/xsl/assembly/assemble.xsl#L137</a>
      <br>
      <br>
      If I change it to this line, it works:
      <br>
      <br>
        &lt;xsl:copy-of select="@xml:id|@xml:lang"/&gt;
      <br>
      <br>
      Can someone confirm this?
      <br>
      If this is true, it means an author cannot set a language (or
      other attributes)
      <br>
      on the output.
      <br>
      <br>
      I have two additional questions:
      <br>
      <br>
      1. What if we have _two_ xml:lang attributes, both on
      &lt;structure&gt; and on
      <br>
         &lt;output&gt;. Which wins? Which has the higher priority?
      <br>
         Is that specified or defined anywhere?
      <br>
      <br>
      2. What if an author wants to inject other attributes like role,
      os, or others?
      <br>
         Where it is supposed to be inserted? Also same as point 1, who
      wins when we
      <br>
         have the same attributes?
      <br>
      <br>
      <br>
      Thanks for your idea and answers!
      <br>
      <br>
      <br>
      --
      <br>
      Gruß/Regards
      <br>
        Thomas Schraitle
      <br>
      <br>
---------------------------------------------------------------------
      <br>
      To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
      <br>
      For additional commands, e-mail: <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
      <br>
      <br>
      <br>
    </blockquote>
  </body>
</html>

--------------zrmMB0SYLmray9CslwEHoN87--