]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
its: Add ability to check *.its and *.loc files with XML Schema 1.1.
authorBruno Haible <bruno@clisp.org>
Tue, 15 Oct 2024 00:37:28 +0000 (02:37 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 15 Oct 2024 01:10:03 +0000 (03:10 +0200)
* gettext-tools/src/its.xsd10: Renamed from gettext-tools/src/its.xsd.
(RulesType): Enumerate all possible rules in the ITS namespace, instead of using
a wildcard.
(OtherRuleType): New element.
* gettext-tools/src/its.xsd11: Copied from gettext-tools/src/its.xsd.
(LocNoteRuleType): Enable assertion.
* gettext-tools/src/locating-rules.xsd10: Renamed from
gettext-tools/src/locating-rules.xsd.
* gettext-tools/src/locating-rules.xsd11: Copied from
gettext-tools/src/locating-rules.xsd.
(LocatingRuleType): Enable assertion.
* gettext-tools/src/Makefile.am (schema_DATA): Add its.xsd10, its.xsd11,
locating-rules.xsd10, locating-rules.xsd11. Remove its.xsd, locating-rules.xsd.
* gettext-tools/build-aux/xml-validate-10.in: New file.
* gettext-tools/build-aux/xml-validate-11.in: New file.
* gettext-tools/configure.ac: Substitute HAVE_JAVAEXEC.
(AC_CONFIG_FILES): Create build-aux/xml-validate-10, build-aux/xml-validate-11.
* gettext-tools/Makefile.am (DISTCLEANFILES): Add build-aux/xml-validate-10,
build-aux/xml-validate-11.
* gettext-tools/its/Makefile.am: Revert last commit.
(check-local): Check each file both using the XML Schema 1.0 and the XML Schema
1.1.
* gettext-tools/doc/gettext.texi (ITS Rules): Mention the two versions of
its.xsd.
(Location Rules): Mention the two versions of locating-rules.xsd.
* HACKING: Mention Xerces2-J.

13 files changed:
.gitignore
HACKING
gettext-tools/Makefile.am
gettext-tools/build-aux/xml-validate-10.in [new file with mode: 0644]
gettext-tools/build-aux/xml-validate-11.in [new file with mode: 0644]
gettext-tools/configure.ac
gettext-tools/doc/gettext.texi
gettext-tools/its/Makefile.am
gettext-tools/src/Makefile.am
gettext-tools/src/its.xsd10 [new file with mode: 0644]
gettext-tools/src/its.xsd11 [moved from gettext-tools/src/its.xsd with 96% similarity]
gettext-tools/src/locating-rules.xsd10 [moved from gettext-tools/src/locating-rules.xsd with 97% similarity]
gettext-tools/src/locating-rules.xsd11 [new file with mode: 0644]

index dd22d459a84202fb25881ef7e7e7b5dcad310799..c0645b2299356657d71c46d4c295d22089285558 100644 (file)
@@ -642,6 +642,8 @@ autom4te.cache/
 /gettext-tools/javaexec.sh
 /gettext-tools/libtool
 /gettext-tools/stamp-h1
+/gettext-tools/build-aux/xml-validate-10
+/gettext-tools/build-aux/xml-validate-11
 /gettext-tools/doc/Makefile
 /gettext-tools/emacs/Makefile
 /gettext-tools/examples/Makefile
diff --git a/HACKING b/HACKING
index b29b4ab887c7cc5f942b7b484ed28fba1dbbef5a..60225417c87013af6d64c269ba7d941a766ae8ca 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -147,6 +147,10 @@ are skipped. To this effect, you need to install also:
       - On Debian and Debian-based systems: libxml2-utils,
       - On Red Hat distributions: libxml2.
       - Other: https://repology.org/project/libxml2/versions
+  * The Xerces2 Java XML parser (binary distribution named 'xml-schema-1.1')
+    + Homepage: https://xerces.apache.org/xerces2-j/
+    + Pre-built package name: --
+    + See gettext-tools/build-aux/xml-validate-11.in for more details.
 
   * A C++ compiler
     + Homepage: https://gcc.gnu.org/
index 1d6c665a75ff018f94b08f2f5d8e4cfb28315675..274b9d41a36203e97ffda0c9a8fd623ab624022a 100644 (file)
@@ -23,6 +23,7 @@ SUBDIRS = gnulib-lib libgrep src libgettextpo po its projects styles emacs misc
 
 EXTRA_DIST = misc/DISCLAIM
 MOSTLYCLEANFILES = core *.stackdump
+DISTCLEANFILES = build-aux/xml-validate-10 build-aux/xml-validate-11
 
 
 # Files installed for use by gettextize.
diff --git a/gettext-tools/build-aux/xml-validate-10.in b/gettext-tools/build-aux/xml-validate-10.in
new file mode 100644 (file)
index 0000000..609279f
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/sh
+# Validating an XML document against an XML Schema 1.0.
+
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file 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 file 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/>.
+
+# Written by Bruno Haible <bruno@clisp.org>, 2024.
+
+# func_usage
+# outputs to stdout the --help usage message.
+func_usage ()
+{
+  echo "\
+Usage: xml-validate-10 [OPTION]... SCHEMA DOCUMENT
+
+Invokes an XML Schema 1.0 validator, validating the given XML document
+against the given XML schema.
+
+The exit code is 0 for valid, 1 for invalid.
+
+Options:
+      --help           print this help and exit
+      --version        print version information and exit
+
+Send patches and bug reports to <bug-gettext@gnu.org>."
+}
+
+# func_version
+# outputs to stdout the --version message.
+func_version ()
+{
+  echo "xml-validate-10 (GNU gettext)"
+  echo "Copyright (C) 2024 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+  echo
+  printf 'Written by %s.\n' "Bruno Haible"
+}
+
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+func_fatal_error ()
+{
+  echo "xml-validate-10: *** $1" 1>&2
+  echo "xml-validate-10: *** Stop." 1>&2
+  exit 1
+}
+
+# Outputs a command and runs it.
+func_verbose ()
+{
+  # Make it easy to copy&paste the printed command into a shell in most cases,
+  # by escaping '\\', '"', and '$'. This is not perfect, just good enough.
+  echo "$@" | sed -e 's/\([\\"$]\)/\\\1/g'
+  "$@"
+}
+
+# Command-line option processing.
+while test $# -gt 0; do
+  case "$1" in
+    --help | --hel | --he | --h )
+      func_usage
+      exit 0 ;;
+   --version | --versio | --versi | --vers | --ver | --ve | --v )
+      func_version
+      exit 0 ;;
+    -- )      # Stop option processing
+      shift; break ;;
+    -* )
+      func_fatal_error "unrecognized option: $1"
+      ;;
+    * )
+      break ;;
+  esac
+done
+
+if test $# -lt 2; then
+  func_fatal_error "too few arguments"
+fi
+if test $# -gt 2; then
+  func_fatal_error "too many arguments"
+fi
+
+schema="$1"
+document="$2"
+shift
+shift
+
+if test '@XMLLINT@' != ':'; then
+  func_verbose @XMLLINT@ --noout --schema "$schema" "$document" || exit 1
+fi
diff --git a/gettext-tools/build-aux/xml-validate-11.in b/gettext-tools/build-aux/xml-validate-11.in
new file mode 100644 (file)
index 0000000..c7d08e6
--- /dev/null
@@ -0,0 +1,189 @@
+#!/bin/sh
+# Validating an XML document against an XML Schema 1.1.
+
+# Copyright (C) 2024 Free Software Foundation, Inc.
+#
+# This file 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 file 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/>.
+
+# Written by Bruno Haible <bruno@clisp.org>, 2024.
+
+# The major advantages of XML Schema 1.1, compared to XML Schema 1.0, are:
+# * It fixes an ill-designed "Unique Particle Attribution" rule
+#   <https://en.wikipedia.org/wiki/Unique_Particle_Attribution>
+#   <https://www.xml.com/articles/2018/06/13/upa-xml-schema/>
+#   that makes
+#     <any namespace="##targetNamespace" processContents="skip"/>
+#   elements practically useless.  See
+#   <https://en.wikipedia.org/wiki/Unique_Particle_Attribution>
+#   <https://stackoverflow.com/questions/17580614/>.
+# * It allows to check that, for example, a specific child element and a
+#   specific attribute are not used together in the same XML element.
+#   This is a special case of <xsd:assert .../>.
+#
+# The major drawback of XML Schema 1.1, compared to XML Schema 1.0, are:
+# * (As of 2024) There is only one Free Software implementation of it:
+#   Apache Xerces in version 2.12 or newer, in the "xml-schema-1.1" variant.
+# * The error messages emitted by Apache Xerces are regularly mysterious /
+#   unintelligible.
+
+# func_usage
+# outputs to stdout the --help usage message.
+func_usage ()
+{
+  echo "\
+Usage: xml-validate-11 [OPTION]... SCHEMA DOCUMENT
+
+Invokes an XML Schema 1.1 validator, validating the given XML document
+against the given XML schema.
+
+The exit code is 0 for valid, 1 for invalid.
+
+Options:
+      --help           print this help and exit
+      --version        print version information and exit
+
+The environment variable XERCES_J_DIR should point to a directory that
+contains a binary distribution of Xerces-J version 2.12 (or newer),
+in xml-schema-1.1 variant.  Download location:
+https://dlcdn.apache.org//xerces/j/binaries/Xerces-J-bin.2.12.2-xml-schema-1.1.tar.gz
+
+Send patches and bug reports to <bug-gettext@gnu.org>."
+}
+
+# func_version
+# outputs to stdout the --version message.
+func_version ()
+{
+  echo "xml-validate-11 (GNU gettext)"
+  echo "Copyright (C) 2024 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+  echo
+  printf 'Written by %s.\n' "Bruno Haible"
+}
+
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+func_fatal_error ()
+{
+  echo "xml-validate-11: *** $1" 1>&2
+  echo "xml-validate-11: *** Stop." 1>&2
+  exit 1
+}
+
+# Outputs a command and runs it.
+func_verbose ()
+{
+  # Make it easy to copy&paste the printed command into a shell in most cases,
+  # by escaping '\\', '"', and '$'. This is not perfect, just good enough.
+  echo "$@" | sed -e 's/\([\\"$]\)/\\\1/g'
+  "$@"
+}
+
+# func_tmpdir
+# creates a temporary directory.
+# Sets variable
+# - tmp             pathname of freshly created temporary directory
+func_tmpdir ()
+{
+  # Use the environment variable TMPDIR, falling back to /tmp. This allows
+  # users to specify a different temporary directory, for example, if their
+  # /tmp is filled up or too small.
+  : "${TMPDIR=/tmp}"
+  {
+    # Use the mktemp program if available. If not available, hide the error
+    # message.
+    tmp=`(umask 077 && mktemp -d -q "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
+    test -n "$tmp" && test -d "$tmp"
+  } ||
+  {
+    # Use a simple mkdir command. It is guaranteed to fail if the directory
+    # already exists.  $RANDOM is bash specific and expands to empty in shells
+    # other than bash, ksh and zsh.  Its use does not increase security;
+    # rather, it minimizes the probability of failure in a very cluttered /tmp
+    # directory.
+    tmp=$TMPDIR/gt$$-$RANDOM
+    (umask 077 && mkdir "$tmp")
+  } ||
+  {
+    echo "$0: cannot create a temporary directory in $TMPDIR" >&2
+    { (exit 1); exit 1; }
+  }
+}
+
+# Command-line option processing.
+while test $# -gt 0; do
+  case "$1" in
+    --help | --hel | --he | --h )
+      func_usage
+      exit 0 ;;
+   --version | --versio | --versi | --vers | --ver | --ve | --v )
+      func_version
+      exit 0 ;;
+    -- )      # Stop option processing
+      shift; break ;;
+    -* )
+      func_fatal_error "unrecognized option: $1"
+      ;;
+    * )
+      break ;;
+  esac
+done
+
+if test $# -lt 2; then
+  func_fatal_error "too few arguments"
+fi
+if test $# -gt 2; then
+  func_fatal_error "too many arguments"
+fi
+
+schema="$1"
+document="$2"
+shift
+shift
+
+if test -n '@HAVE_JAVAEXEC@' \
+   && test -n "$XERCES_J_DIR" \
+   && test -d "$XERCES_J_DIR" \
+   && test -f "$XERCES_J_DIR/xercesSamples.jar" \
+   && test -f "$XERCES_J_DIR/xercesImpl.jar" \
+   && test -f "$XERCES_J_DIR/org.eclipse.wst.xml.xpath2.processor_1.2.1.jar" \
+   && test -f "$XERCES_J_DIR/cupv10k-runtime.jar"; then
+  # We don't need to write our own Java program that invokes the validator,
+  # like <https://stackoverflow.com/questions/20807066/>
+  # or <https://stackoverflow.com/questions/20819060/>,
+  # because the Xerces-J FAQ <https://xerces.apache.org/xerces2-j/faq-xs.html>
+  # says:
+  #   "You can also refer to the JAXP sample, SourceValidator, where you can
+  #    validate XML documents against 1.1 schemas by specifying an option
+  #    "-xsd11" when running the sample."
+  # Documentation of this sample:
+  # <https://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator>
+  func_tmpdir
+  echo "sh ../javaexec.sh jaxp.SourceValidator -xsd11 -f -a $schema -i $document"
+  CLASSPATH="$XERCES_J_DIR/xercesSamples.jar:$XERCES_J_DIR/xercesImpl.jar:$XERCES_J_DIR/org.eclipse.wst.xml.xpath2.processor_1.2.1.jar:$XERCES_J_DIR/cupv10k-runtime.jar" \
+    sh ../javaexec.sh jaxp.SourceValidator -xsd11 -f -a "$schema" -i "$document" \
+    > "$tmp"/out 2> "$tmp"/err
+  # The exit code is usually 0, even if there were errors.
+  if test $? != 0 || grep '\[Error\]' "$tmp"/err >/dev/null; then
+    exitcode=1
+  else
+    exitcode=0
+  fi
+  cat "$tmp"/err 1>&2
+  cat "$tmp"/out
+  rm -f "$tmp"/out "$tmp"/err
+  exit $exitcode
+fi
index b9c1311706a22043cc9b75287a7b3d9054a85c1a..86e4f1725d6413d7bd0c8339546f981035cf7434 100644 (file)
@@ -618,6 +618,7 @@ AM_CONDITIONAL([TEST_SYSTEM_LIBINTL], [test $USE_INCLUDED_LIBINTL = no])
 
 dnl Checks for optional programs for the its/* tests.
 AC_PATH_PROGS([XMLLINT], [xmllint], [:])
+AC_SUBST([HAVE_JAVAEXEC])
 
 AC_CONFIG_SUBDIRS([examples])
 
@@ -664,4 +665,9 @@ AC_CONFIG_FILES([system-tests/Makefile])
 
 AC_CONFIG_FILES([gnulib-tests/Makefile])
 
+AC_CONFIG_FILES([build-aux/xml-validate-10],
+                [chmod a+x build-aux/xml-validate-10])
+AC_CONFIG_FILES([build-aux/xml-validate-11],
+                [chmod a+x build-aux/xml-validate-11])
+
 AC_OUTPUT
index a2cbb3c11fa566a7e8f094220e7227c3244c2ac6..6a644b127cde3c80b90a3fd98183d607b061fc94 100644 (file)
@@ -10879,8 +10879,9 @@ second ("A non-translatable string"), the following ITS rules can be used:
 @end example
 
 ITS rules files must have the @file{.its} file extension and obey
-the XML schema encoded by
-@code{its.xsd} and its auxiliary schema @code{its-extensions.xsd}.
+the XML schema version 1.0 encoded by @code{its.xsd10} or
+the XML schema version 1.1 encoded by @code{its.xsd11}
+and its auxiliary schema @code{its-extensions.xsd}.
 
 @node Locating Rules
 @subsubsection Specifying where to find the ITS Rules
@@ -10924,7 +10925,8 @@ of @code{locatingRule} or @code{documentRule}.  If it is specified in a
 have the @code{target} attribute.
 
 Locating rules files must have the @file{.loc} file extension and obey
-the XML schema encoded by @code{locating-rules.xsd}.
+the XML schema version 1.0 encoded by @code{locating-rules.xsd10} or
+the XML schema version 1.1 encoded by @code{locating-rules.xsd11}.
 Both ITS rules files and locating rules files must be installed in the
 @file{$prefix/share/gettext/its} directory.  Once those files are
 properly installed, @code{xgettext} can extract translatable strings
index e372a431125edf3402227c240bab3cd0e0237f6c..9066e7bfdd991925c7b8dac26611b6e259ab2b85 100644 (file)
@@ -38,15 +38,17 @@ dist_its_DATA = $(ITS_FILES) $(LOC_FILES)
 # Checks the XML files against their schemas.
 # Work around <https://gitlab.gnome.org/GNOME/libxml2/-/issues/809>.
 check-local:
-       @if echo '<?xml version="1.0"?><rules xmlns="http://www.w3.org/2005/11/its" version="2.0"/>' | $(XMLLINT) --noout --schema $(top_srcdir)/src/its.xsd - >/dev/null 2>&1; then \
-         for file in $(ITS_FILES); do \
-           echo "Checking $$file..."; \
-           echo "$(XMLLINT) --noout --schema $(top_srcdir)/src/its.xsd $(srcdir)/$$file"; \
-           $(XMLLINT) --noout --schema $(top_srcdir)/src/its.xsd $(srcdir)/$$file || exit 1; \
-         done; \
-       fi
+       @for file in $(ITS_FILES); do \
+         echo "Checking $$file..."; \
+         echo "$(top_builddir)/build-aux/xml-validate-10 $(top_srcdir)/src/its.xsd10 $(srcdir)/$$file"; \
+         $(top_builddir)/build-aux/xml-validate-10 $(top_srcdir)/src/its.xsd10 $(srcdir)/$$file || exit 1; \
+         echo "$(top_builddir)/build-aux/xml-validate-11 $(top_srcdir)/src/its.xsd11 $(srcdir)/$$file"; \
+         $(top_builddir)/build-aux/xml-validate-11 $(top_srcdir)/src/its.xsd11 $(srcdir)/$$file || exit 1; \
+       done
        @for file in $(LOC_FILES); do \
          echo "Checking $$file..."; \
-         echo "$(XMLLINT) --noout --schema $(top_srcdir)/src/locating-rules.xsd $(srcdir)/$$file"; \
-         $(XMLLINT) --noout --schema $(top_srcdir)/src/locating-rules.xsd $(srcdir)/$$file || exit 1; \
+         echo "$(top_builddir)/build-aux/xml-validate-10 $(top_srcdir)/src/locating-rules.xsd10 $(srcdir)/$$file"; \
+         $(top_builddir)/build-aux/xml-validate-10 $(top_srcdir)/src/locating-rules.xsd10 $(srcdir)/$$file || exit 1; \
+         echo "$(top_builddir)/build-aux/xml-validate-11 $(top_srcdir)/src/locating-rules.xsd11 $(srcdir)/$$file"; \
+         $(top_builddir)/build-aux/xml-validate-11 $(top_srcdir)/src/locating-rules.xsd11 $(srcdir)/$$file || exit 1; \
        done
index cd94c389572227d4508a2781c091ea500df2418e..9dd79b26600132ba6c4580a7622b6400566e2ceb 100644 (file)
@@ -796,8 +796,8 @@ uninstall-tcl:
 # Special rules for XML schemas.
 
 schema_DATA = \
-  its.xsd its-extensions.xsd \
-  locating-rules.xsd
+  its.xsd10 its.xsd11 its-extensions.xsd \
+  locating-rules.xsd10 locating-rules.xsd11
 EXTRA_DIST += $(schema_DATA)
 
 
diff --git a/gettext-tools/src/its.xsd10 b/gettext-tools/src/its.xsd10
new file mode 100644 (file)
index 0000000..326edfb
--- /dev/null
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://www.w3.org/2005/11/its" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:its="http://www.w3.org/2005/11/its" xmlns:gt="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" elementFormDefault="qualified">
+
+  <annotation>
+    <documentation>XML schema 1.0 of *.its files, as understood by GNU gettext.
+
+Copyright (C) 2015-2024 Free Software Foundation, Inc.
+
+This file 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 file 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 &lt;https://www.gnu.org/licenses/&gt;.
+
+Written by Bruno Haible &lt;bruno@clisp.org&gt;, 2024.
+</documentation>
+  </annotation>
+
+  <!-- Define elements and types in the gt namespace.  -->
+  <import namespace="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" schemaLocation="its-extensions.xsd"/>
+
+  <element name="rules" type="its:RulesType"></element>
+
+  <complexType name="RulesType">
+    <sequence minOccurs="0" maxOccurs="unbounded">
+      <choice>
+        <element name="translateRule" type="its:TranslateRuleType">
+        </element>
+        <element name="locNoteRule" type="its:LocNoteRuleType">
+        </element>
+        <element name="withinTextRule" type="its:WithinTextRuleType">
+        </element>
+        <element name="preserveSpaceRule" type="its:PreserveSpaceRuleType">
+        </element>
+        <element ref="gt:preserveSpaceRule">
+        </element>
+        <element ref="gt:contextRule">
+        </element>
+        <element ref="gt:escapeRule">
+        </element>
+        <!-- Allow other rules from the ITS namespace (not implemented
+             by GNU gettext).  -->
+        <element name="termRule" type="its:OtherRuleType"/>
+        <element name="dirRule" type="its:OtherRuleType"/>
+        <element name="langRule" type="its:OtherRuleType"/>
+        <element name="domainRule" type="its:OtherRuleType"/>
+        <element name="textAnalysisRule" type="its:OtherRuleType"/>
+        <element name="localeFilterRule" type="its:OtherRuleType"/>
+        <element name="provRule" type="its:OtherRuleType"/>
+        <element name="externalResourceRefRule" type="its:OtherRuleType"/>
+        <element name="targetPointerRule" type="its:OtherRuleType"/>
+        <element name="idValueRule" type="its:OtherRuleType"/>
+        <element name="locQualityIssueRule" type="its:OtherRuleType"/>
+        <element name="mtConfidenceRule" type="its:OtherRuleType"/>
+        <element name="allowedCharactersRule" type="its:OtherRuleType"/>
+        <element name="storageSizeRule" type="its:OtherRuleType"/>
+        <!-- Allow itstool extensions (not implemented by GNU gettext).  -->
+        <any namespace="http://itstool.org/extensions/" processContents="skip"/>
+      </choice>
+    </sequence>
+    <attribute name="version" type="string" use="required" fixed="2.0"></attribute>
+  </complexType>
+
+  <complexType name="TranslateRuleType">
+    <attribute name="selector" type="string" use="required"></attribute>
+    <attribute name="translate" use="required">
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="yes"></enumeration>
+          <enumeration value="no"></enumeration>
+        </restriction>
+      </simpleType>
+    </attribute>
+  </complexType>
+
+  <complexType name="LocNoteRuleType">
+    <annotation>
+      <documentation>Note: An instance should not have both the 'locNotePointer' attribute and a 'locNote' child at the same time.
+</documentation></annotation>
+    <sequence minOccurs="0" maxOccurs="1">
+      <element name="locNote" type="string"></element>
+    </sequence>
+    <attribute name="selector" type="string" use="required"></attribute>
+    <attribute name="locNoteType" use="required">
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="description"></enumeration>
+          <enumeration value="alert"></enumeration>
+        </restriction>
+      </simpleType>
+    </attribute>
+    <attribute name="locNotePointer" type="string" use="optional"></attribute>
+    <!-- Valid in XML Schema 1.1 only:
+    <assert test="not(@locNotePointer and locNote)"/>
+    -->
+  </complexType>
+
+  <complexType name="WithinTextRuleType">
+    <attribute name="selector" type="string" use="required"></attribute>
+    <attribute name="withinText" use="required">
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="yes"></enumeration>
+          <enumeration value="nested"></enumeration>
+          <enumeration value="no"></enumeration>
+        </restriction>
+      </simpleType>
+    </attribute>
+  </complexType>
+
+  <!-- If no <its:preserveSpaceRule> nor <gt:preserveSpaceRule> is present,
+       the default 'space' property is "default".  -->
+  <complexType name="PreserveSpaceRuleType">
+    <attribute name="selector" type="string" use="required"></attribute>
+    <attribute name="space" use="required">
+      <simpleType>
+        <restriction base="string">
+          <enumeration value="preserve"></enumeration>
+          <enumeration value="default"></enumeration>
+        </restriction>
+      </simpleType>
+    </attribute>
+  </complexType>
+
+  <complexType name="OtherRuleType" mixed="true">
+    <sequence>
+      <any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
+    </sequence>
+    <anyAttribute processContents="skip"/>
+  </complexType>
+
+</schema>
similarity index 96%
rename from gettext-tools/src/its.xsd
rename to gettext-tools/src/its.xsd11
index 21cd7f45445df572e74f8286a5e8b048de4c7110..5280bbaf3bb16e868b121b64ca096264a546a8e6 100644 (file)
@@ -2,7 +2,7 @@
 <schema targetNamespace="http://www.w3.org/2005/11/its" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:its="http://www.w3.org/2005/11/its" xmlns:gt="https://www.gnu.org/s/gettext/ns/its/extensions/1.0" elementFormDefault="qualified">
 
   <annotation>
-    <documentation>XML schema of *.its files, as understood by GNU gettext.
+    <documentation>XML schema 1.1 of *.its files, as understood by GNU gettext.
 
 Copyright (C) 2015-2024 Free Software Foundation, Inc.
 
@@ -82,9 +82,8 @@ Written by Bruno Haible &lt;bruno@clisp.org&gt;, 2024.
       </simpleType>
     </attribute>
     <attribute name="locNotePointer" type="string" use="optional"></attribute>
-    <!-- Valid in XML Schema 1.1 only:
-    <xsd:assert test="not(@locNotePointer and locNote)"/>
-    -->
+    <!-- Valid in XML Schema 1.1 only: -->
+    <assert test="not(@locNotePointer and locNote)"/>
   </complexType>
 
   <complexType name="WithinTextRuleType">
similarity index 97%
rename from gettext-tools/src/locating-rules.xsd
rename to gettext-tools/src/locating-rules.xsd10
index 3bb86fd13e99b849eee02581d839c2429907c6f4..1795e6ea4a7112bd4c45e5077915b393758c1301 100644 (file)
@@ -2,7 +2,7 @@
 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <xsd:annotation>
-    <xsd:documentation>XML schema of *.loc files, as understood by GNU gettext.
+    <xsd:documentation>XML schema 1.0 of *.loc files, as understood by GNU gettext.
 
 Copyright (C) 2015-2024 Free Software Foundation, Inc.
 
diff --git a/gettext-tools/src/locating-rules.xsd11 b/gettext-tools/src/locating-rules.xsd11
new file mode 100644 (file)
index 0000000..d4bac98
--- /dev/null
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+  <xsd:annotation>
+    <xsd:documentation>XML schema 1.1 of *.loc files, as understood by GNU gettext.
+
+Copyright (C) 2015-2024 Free Software Foundation, Inc.
+
+This file 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 file 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 &lt;https://www.gnu.org/licenses/&gt;.
+
+Written by Bruno Haible &lt;bruno@clisp.org&gt;, 2024.
+</xsd:documentation></xsd:annotation>
+
+  <xsd:element name="locatingRules" type="LocatingRulesType">
+    <xsd:annotation>
+      <xsd:documentation></xsd:documentation>
+    </xsd:annotation>
+  </xsd:element>
+
+  <xsd:complexType name="LocatingRulesType">
+    <xsd:annotation>
+      <xsd:documentation>Example:
+&lt;locatingRules&gt;
+  &lt;locatingRule name=&quot;Glade&quot; pattern=&quot;*.glade&quot;&gt;
+  &lt;documentRule localName=&quot;GTK-Interface&quot; target=&quot;glade1.its&quot;/&gt;
+  &lt;documentRule localName=&quot;glade-interface&quot; target=&quot;glade2.its&quot;/&gt;
+  &lt;documentRule localName=&quot;interface&quot; target=&quot;gtkbuilder.its&quot;/&gt;
+  &lt;/locatingRule&gt;
+  &lt;locatingRule name=&quot;Glade&quot; pattern=&quot;*.glade2&quot;&gt;
+  &lt;documentRule localName=&quot;glade-interface&quot; target=&quot;glade2.its&quot;/&gt;
+  &lt;/locatingRule&gt;
+  &lt;locatingRule name=&quot;Glade&quot; pattern=&quot;*.ui&quot;&gt;
+  &lt;documentRule localName=&quot;interface&quot; target=&quot;gtkbuilder.its&quot;/&gt;
+  &lt;/locatingRule&gt;
+&lt;/locatingRules&gt;
+</xsd:documentation></xsd:annotation>
+    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+      <xsd:element name="locatingRule" type="LocatingRuleType">
+        <xsd:annotation>
+          <xsd:documentation></xsd:documentation>
+        </xsd:annotation></xsd:element>
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="LocatingRuleType">
+    <xsd:annotation>
+      <xsd:documentation>Example:
+&amp;lt;locatingRule name=&amp;quot;Glade&amp;quot; pattern=&amp;quot;*.glade&amp;quot;&amp;gt;
+  &amp;lt;documentRule localName=&amp;quot;GTK-Interface&amp;quot; target=&amp;quot;glade1.its&amp;quot;/&amp;gt;
+  &amp;lt;documentRule localName=&amp;quot;glade-interface&amp;quot; target=&amp;quot;glade2.its&amp;quot;/&amp;gt;
+  &amp;lt;documentRule localName=&amp;quot;interface&amp;quot; target=&amp;quot;gtkbuilder.its&amp;quot;/&amp;gt;
+&amp;lt;/locatingRule&amp;gt;
+
+Note: An instance should not have both the 'target' attribute and a 'documentRule' child at the same time.
+</xsd:documentation></xsd:annotation>
+    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+      <xsd:element name="documentRule" type="DocumentRuleType"></xsd:element>
+    </xsd:sequence>
+    <xsd:attribute name="pattern" type="xsd:string" use="required"></xsd:attribute>
+    <xsd:attribute name="name" type="xsd:string" use="optional"></xsd:attribute>
+    <xsd:attribute name="target" type="xsd:string" use="optional"></xsd:attribute>
+    <!-- Valid in XML Schema 1.1 only: -->
+    <xsd:assert test="not(@target and documentRule)"/>
+  </xsd:complexType>
+
+  <xsd:complexType name="DocumentRuleType">
+    <xsd:annotation>
+      <xsd:documentation>Example:
+&lt;documentRule localName=&quot;GTK-Interface&quot; target=&quot;glade1.its&quot;/&gt;
+</xsd:documentation>
+    </xsd:annotation>
+    <xsd:attribute name="target" type="xsd:string" use="required"></xsd:attribute>
+    <xsd:attribute name="ns" type="xsd:string" use="optional"></xsd:attribute>
+    <xsd:attribute name="localName" type="xsd:string" use="optional"></xsd:attribute>
+  </xsd:complexType>
+</xsd:schema>