]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
its: Support DocBook XML, part 1.
authorBruno Haible <bruno@clisp.org>
Sun, 13 Oct 2024 10:34:35 +0000 (12:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Oct 2024 10:34:35 +0000 (12:34 +0200)
Reported by Guillem Jover <guillem@hadrons.org>
at <https://savannah.gnu.org/bugs/?52415>.

* gettext-tools/its/docbook4.its: New file, copied from
https://github.com/itstool/itstool file its/docbook.its.
* gettext-tools/its/docbook5.its: New file, copied from
https://github.com/itstool/itstool file its/docbook5.its.
* gettext-tools/its/docbook.loc: New file.
* gettext-tools/its/Makefile.am (ITS_FILES): Add docbook4.its, docbook5.its.
(LOC_FILES): Add docbook.loc.

gettext-tools/its/Makefile.am
gettext-tools/its/docbook.loc [new file with mode: 0644]
gettext-tools/its/docbook4.its [new file with mode: 0644]
gettext-tools/its/docbook5.its [new file with mode: 0644]

index 7c50961b9822811717846e115b90a1d73270f9b7..47c74e692afcb04fe70685f258c953add1265fc4 100644 (file)
@@ -24,12 +24,14 @@ itsdir = $(pkgdatadir)$(PACKAGE_SUFFIX)/its
 ITS_FILES = \
   glade1.its glade2.its gtkbuilder.its \
   gsettings.its \
-  metainfo.its
+  metainfo.its \
+  docbook4.its docbook5.its
 
 LOC_FILES = \
   glade.loc \
   gsettings.loc \
-  metainfo.loc
+  metainfo.loc \
+  docbook.loc
 
 dist_its_DATA = $(ITS_FILES) $(LOC_FILES)
 
diff --git a/gettext-tools/its/docbook.loc b/gettext-tools/its/docbook.loc
new file mode 100644 (file)
index 0000000..9baf810
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (C) 2024 Free Software Foundation, Inc.
+  This file was written by Bruno Haible <bruno@clisp.org>, 2024.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<locatingRules>
+  <!-- DocBook 5 documents can be distinguished from DocBook 4 documents
+       either by their DOCTYPE declaration
+       <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+                             "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+       vs. (optional in DocBook 5)
+       <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V5.2//EN"
+                             "http://www.oasis-open.org/docbook/xml/5.2/dtd/docbookx.dtd">
+       or by the namespace in which the root element is sitting:
+       no namespace in DocBook 4, http://docbook.org/ns/docbook in DocBook 5.
+  -->
+  <locatingRule name="docbook5" pattern="*.xml">
+    <documentRule ns="http://docbook.org/ns/docbook" localName="book" target="docbook5.its"/>
+    <documentRule ns="http://docbook.org/ns/docbook" localName="article" target="docbook5.its"/>
+    <!-- https://tdg.docbook.org/tdg/5.2/refentry -->
+    <documentRule ns="http://docbook.org/ns/docbook" localName="refentry" target="docbook5.its"/>
+  </locatingRule>
+  <locatingRule name="docbook4" pattern="*.xml">
+    <documentRule localName="book" target="docbook4.its"/>
+    <documentRule localName="article" target="docbook4.its"/>
+    <!-- https://tdg.docbook.org/tdg/4.5/refentry -->
+    <documentRule localName="refentry" target="docbook4.its"/>
+  </locatingRule>
+</locatingRules>
diff --git a/gettext-tools/its/docbook4.its b/gettext-tools/its/docbook4.its
new file mode 100644 (file)
index 0000000..bdc3e95
--- /dev/null
@@ -0,0 +1,233 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (C) 2010-2018 Shaun McCance
+  This file was written by Shaun McCance <shaunm@gnome.org>, 2010-2018.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<its:rules
+    xmlns:its="http://www.w3.org/2005/11/its"
+    xmlns:itst="http://itstool.org/extensions/"
+    version="2.0">
+
+  <itst:match selector="/book"/>
+  <itst:match selector="/article"/>
+  <itst:match selector="/chapter"/>
+
+  <its:langRule selector="//*[namespace-uri(.) = '']" langPointer="@lang"/>
+
+  <itst:credits appendTo="/book/bookinfo | /article/articleinfo | /chapter/chapterinfo">
+    <othercredit class="translator">
+      <personname>
+        <firstname><itst:value-of select="name"/></firstname>
+      </personname>
+      <email><itst:value-of select="email"/></email>
+    </othercredit>
+    <copyright>
+      <itst:for-each select="years">
+        <year><itst:value-of select="year"/></year>
+      </itst:for-each>
+      <holder><itst:value-of select="name"/></holder>
+    </copyright>
+  </itst:credits>
+
+  <!-- Inline by default, might be overridden -->
+  <its:withinTextRule withinText="yes" selector="//abbrev |
+                                                 //accel |
+                                                 //acronym |
+                                                 //action |
+                                                 //affiliation |
+                                                 //anchor |
+                                                 //application |
+                                                 //arg |
+                                                 //audiodata |
+                                                 //audioobject |
+                                                 //authorinitials |
+                                                 //biblioref |
+                                                 //citation |
+                                                 //citebiblioid |
+                                                 //citerefentry |
+                                                 //citerefentry/manvolnum |
+                                                 //citerefentry/refentrytitle |
+                                                 //citetitle |
+                                                 //city |
+                                                 //classname |
+                                                 //co |
+                                                 //code |
+                                                 //col |
+                                                 //colgroup |
+                                                 //collabname |
+                                                 //command |
+                                                 //computeroutput |
+                                                 //constant |
+                                                 //constraint |
+                                                 //contrib |
+                                                 //country |
+                                                 //database |
+                                                 //date |
+                                                 //email |
+                                                 //emphasis |
+                                                 //envar |
+                                                 //errorcode |
+                                                 //errorname |
+                                                 //errortext |
+                                                 //errortype |
+                                                 //exceptionname |
+                                                 //fax |
+                                                 //filename |
+                                                 //firstname |
+                                                 //firstterm |
+                                                 //footnoteref |
+                                                 //foreignphrase |
+                                                 //funcdef |
+                                                 //funcparams |
+                                                 //function |
+                                                 //glossterm |
+                                                 //group |
+                                                 //guibutton |
+                                                 //guiicon |
+                                                 //guilabel |
+                                                 //guimenu |
+                                                 //guimenuitem |
+                                                 //guisubmenu |
+                                                 //hardware |
+                                                 //holder |
+                                                 //honorific |
+                                                 //imagedata |
+                                                 //imageobject |
+                                                 //imageobjectco |
+                                                 //initializer |
+                                                 //inlineequation |
+                                                 //inlinegraphic |
+                                                 //inlinemediaobject |
+                                                 //interface |
+                                                 //interfacename |
+                                                 //jobtitle |
+                                                 //keycap |
+                                                 //keycode |
+                                                 //keycombo |
+                                                 //keysym |
+                                                 //keyword |
+                                                 //lhs |
+                                                 //lineage |
+                                                 //lineannotation |
+                                                 //link |
+                                                 //literal |
+                                                 //markup |
+                                                 //medialabel |
+                                                 //menuchoice |
+                                                 //methodname |
+                                                 //methodparam |
+                                                 //modifier |
+                                                 //mousebutton |
+                                                 //nonterminal |
+                                                 //olink |
+                                                 //ooclass |
+                                                 //ooexception |
+                                                 //oointerface |
+                                                 //option |
+                                                 //optional |
+                                                 //orgdiv |
+                                                 //orgname |
+                                                 //otheraddr |
+                                                 //othername |
+                                                 //package |
+                                                 //paramdef |
+                                                 //parameter |
+                                                 //personname |
+                                                 //phone |
+                                                 //phrase |
+                                                 //pob |
+                                                 //postcode |
+                                                 //productname |
+                                                 //productnumber |
+                                                 //prompt |
+                                                 //property |
+                                                 //quote |
+                                                 //replaceable |
+                                                 //returnvalue |
+                                                 //revnumber |
+                                                 //revremark |
+                                                 //rhs |
+                                                 //sbr |
+                                                 //sgmltag |
+                                                 //shortaffil |
+                                                 //shortcut |
+                                                 //state |
+                                                 //street |
+                                                 //structfield |
+                                                 //structname |
+                                                 //subscript |
+                                                 //superscript |
+                                                 //surname |
+                                                 //symbol |
+                                                 //systemitem |
+                                                 //termdef |
+                                                 //textobject |
+                                                 //token |
+                                                 //trademark |
+                                                 //type |
+                                                 //ulink |
+                                                 //uri |
+                                                 //userinput |
+                                                 //varargs |
+                                                 //varname |
+                                                 //videodata |
+                                                 //videoobject |
+                                                 //void |
+                                                 //wordasword |
+                                                 //xref |
+                                                 //year "/>
+
+  <!-- Mark footnotes nested, though itstool treats it as "no" -->
+  <its:withinTextRule withinText="nested" selector="//footnote"/>
+
+  <!-- Things with (semi-)structured content -->
+  <its:withinTextRule withinText="no" selector="//confgroup/* | //biblioentry/* | //biblioset/*"/>
+  <its:withinTextRule withinText="yes" selector="//bibliomixed/* | //bibliomset/*"/>
+  <its:withinTextRule withinText="no" selector="//glossentry/*"/>
+  <its:withinTextRule withinText="yes" selector="//indexterm//* |
+                                                 //simplelist[@type = 'inline']/descendant-or-self::*"/>
+
+  <!--
+  We want to break address off into a translation unit because it's
+  supposed to be space-preserving. But because of DocBook wonkiness,
+  address is often just used to provide an email address. In that
+  particular case, just ignore the fact that it's supposed to be a
+  space-preserving translation unit.
+  -->
+  <its:withinTextRule withinText="yes" selector="//address[count(*) = 1 and email]"/>
+  <its:preserveSpaceRule space="preserve" selector="//address[not(count(*) = 1 and email)]"/>
+
+  <!-- Above all else, info is not a text run -->
+  <its:withinTextRule withinText="no" selector="//bookinfo/* | //chapterinfo/* | //articleinfo/*"/>
+
+  <!-- These are always verbatim -->
+  <its:preserveSpaceRule space="preserve" selector="//classsynopsisinfo |
+                                                    //funcsynopsisinfo |
+                                                    //literallayout |
+                                                    //programlisting |
+                                                    //screen |
+                                                    //synopsis "/>
+
+  <!-- Drop editor remarks -->
+  <its:localeFilterRule localeFilterList="" selector="//remark"/>
+
+  <!-- External media files -->
+  <its:externalResourceRefRule externalResourceRefPointer="@fileref"
+                               selector="//audiodata | //imagedata | //videodata"/>
+
+  <!-- Some hacks -->
+  <its:translateRule translate="no" selector="//releaseinfo[@role = 'CVS' and normalize-space(.) = '$Id$']"/>
+</its:rules>
diff --git a/gettext-tools/its/docbook5.its b/gettext-tools/its/docbook5.its
new file mode 100644 (file)
index 0000000..3b2568e
--- /dev/null
@@ -0,0 +1,221 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (C) 2010-2018 Shaun McCance
+  This file was written by Shaun McCance <shaunm@gnome.org>, 2010-2018.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<its:rules
+    xmlns:its="http://www.w3.org/2005/11/its"
+    xmlns:itst="http://itstool.org/extensions/"
+    xmlns:db="http://docbook.org/ns/docbook"
+    version="2.0">
+
+  <itst:match selector="/db:*"/>
+
+  <its:langRule selector="//db:*" langPointer="@xml:lang"/>
+
+  <itst:credits appendTo="/db:*/db:info">
+    <db:othercredit class="translator">
+      <db:personname>
+        <db:firstname><itst:value-of select="name"/></db:firstname>
+      </db:personname>
+      <db:email><itst:value-of select="email"/></db:email>
+    </db:othercredit>
+    <db:copyright>
+      <itst:for-each select="years">
+        <db:year><itst:value-of select="year"/></db:year>
+      </itst:for-each>
+      <db:holder><itst:value-of select="name"/></db:holder>
+    </db:copyright>
+  </itst:credits>
+
+  <!-- Inline by default, might be overridden -->
+  <its:withinTextRule withinText="yes"
+                      selector="//db:abbrev |
+                                //db:accel |
+                                //db:acronym |
+                                //db:affiliation |
+                                //db:alt |
+                                //db:anchor |
+                                //db:application |
+                                //db:arg |
+                                //db:audiodata |
+                                //db:audioobject |
+                                //db:authorinitials |
+                                //db:biblioref |
+                                //db:citation |
+                                //db:citebiblioid |
+                                //db:citerefentry |
+                                //db:citerefentry/db:manvolnum |
+                                //db:citerefentry/db:refentrytitle |
+                                //db:citetitle |
+                                //db:city |
+                                //db:classname |
+                                //db:co |
+                                //db:coref |
+                                //db:code |
+                                //db:col |
+                                //db:colgroup |
+                                //db:command |
+                                //db:computeroutput |
+                                //db:constant |
+                                //db:constraint |
+                                //db:contrib |
+                                //db:country |
+                                //db:database |
+                                //db:date |
+                                //db:email |
+                                //db:emphasis |
+                                //db:envar |
+                                //db:errorcode |
+                                //db:errorname |
+                                //db:errortext |
+                                //db:errortype |
+                                //db:exceptionname |
+                                //db:fax |
+                                //db:filename |
+                                //db:firstname |
+                                //db:firstterm |
+                                //db:footnoteref |
+                                //db:foreignphrase |
+                                //db:funcdef |
+                                //db:funcparams |
+                                //db:function |
+                                //db:givenname |
+                                //db:glossterm |
+                                //db:group |
+                                //db:guibutton |
+                                //db:guiicon |
+                                //db:guilabel |
+                                //db:guimenu |
+                                //db:guimenuitem |
+                                //db:guisubmenu |
+                                //db:hardware |
+                                //db:holder |
+                                //db:honorific |
+                                //db:imagedata |
+                                //db:imageobject |
+                                //db:imageobjectco |
+                                //db:initializer |
+                                //db:inlineequation |
+                                //db:inlinemediaobject |
+                                //db:interfacename |
+                                //db:jobtitle |
+                                //db:keycap |
+                                //db:keycode |
+                                //db:keycombo |
+                                //db:keysym |
+                                //db:keyword |
+                                //db:lhs |
+                                //db:lineage |
+                                //db:lineannotation |
+                                //db:link |
+                                //db:literal |
+                                //db:markup |
+                                //db:menuchoice |
+                                //db:methodname |
+                                //db:methodparam |
+                                //db:modifier |
+                                //db:mousebutton |
+                                //db:multimediaparam |
+                                //db:nonterminal |
+                                //db:olink |
+                                //db:ooclass |
+                                //db:ooexception |
+                                //db:oointerface |
+                                //db:option |
+                                //db:optional |
+                                //db:org |
+                                //db:orgdiv |
+                                //db:orgname |
+                                //db:otheraddr |
+                                //db:othername |
+                                //db:package |
+                                //db:paramdef |
+                                //db:parameter |
+                                //db:personname |
+                                //db:phone |
+                                //db:phrase |
+                                //db:pob |
+                                //db:postcode |
+                                //db:productname |
+                                //db:productnumber |
+                                //db:prompt |
+                                //db:property |
+                                //db:quote |
+                                //db:replaceable |
+                                //db:returnvalue |
+                                //db:revnumber |
+                                //db:revremark |
+                                //db:rhs |
+                                //db:sbr |
+                                //db:shortaffil |
+                                //db:shortcut |
+                                //db:state |
+                                //db:street |
+                                //db:subscript |
+                                //db:superscript |
+                                //db:surname |
+                                //db:symbol |
+                                //db:systemitem |
+                                //db:tag |
+                                //db:termdef |
+                                //db:textobject |
+                                //db:token |
+                                //db:trademark |
+                                //db:type |
+                                //db:uri |
+                                //db:userinput |
+                                //db:varargs |
+                                //db:varname |
+                                //db:videodata |
+                                //db:videoobject |
+                                //db:void |
+                                //db:wordasword |
+                                //db:xref |
+                                //db:year "/>
+
+  <!-- Mark footnotes nested, though itstool treats it as "no" -->
+  <its:withinTextRule withinText="nested" selector="//db:footnote"/>
+
+  <!-- Things with (semi-)structured content -->
+  <its:withinTextRule withinText="no" selector="//db:confgroup/* | //db:biblioentry/* | db:biblioset/*"/>
+  <its:withinTextRule withinText="yes" selector="//db:bibliomixed/* | //db:bibliomset/*"/>
+  <its:withinTextRule withinText="no" selector="//db:glossentry/*"/>
+  <its:withinTextRule withinText="yes" selector="//db:indexterm//* |
+                                                 //db:simplelist[@type = 'inline']/descendant-or-self::*"/>
+
+  <!-- Above all else, info is not a text run -->
+  <its:withinTextRule withinText="no" selector="//db:info/*"/>
+
+  <!-- These are always verbatim -->
+  <its:preserveSpaceRule space="preserve" selector="//db:address |
+                                                    //db:classsynopsisinfo |
+                                                    //db:funcsynopsisinfo |
+                                                    //db:literallayout |
+                                                    //db:programlisting |
+                                                    //db:screen |
+                                                    //db:synopsis "/>
+
+  <!-- Drop editor remarks -->
+  <its:localeFilterRule localeFilterList="" selector="//db:remark"/>
+
+  <!-- External media files -->
+  <its:externalResourceRefRule externalResourceRefPointer="@fileref"
+                               selector="//db:audiodata | //db:imagedata | //db:videodata"/>
+
+  <!-- Some hacks -->
+  <its:translateRule translate="no" selector="//db:releaseinfo[@role = 'CVS' and normalize-space(.) = '$Id$']"/>
+</its:rules>