--- /dev/null
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test of ITS support.
+
+: ${XGETTEXT=xgettext}
+: ${GETTEXTDATADIR=.}
+
+export GETTEXTDATADIR
+
+cat <<\EOF > empty.xml
+<?xml version="1.0"?>
+<empty></empty>
+EOF
+
+${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
+
+test -d its || mkdir its
+test -d its/locators || mkdir its/locators
+test -d its/rules || mkdir its/rules
+
+cat <<\EOF > its/locators/empty-1.loc
+<?xml version="1.0"?>
+<locatingRules/>
+EOF
+
+${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
+
+cat <<\EOF > its/locators/empty-2.loc
+<?xml version="1.0"?>
+<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
+ <documentElement prefix="" localName="empty" uri="empty.its"/>
+</locatingRules>
+EOF
+
+${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
+
+cat <<\EOF > its/rules/empty.its
+<?xml version="1.0"?>
+<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
+</its:rules>
+EOF
+
+${XGETTEXT} --its -o empty.pot empty.xml 2>empty.err || { cat empty.err; exit 1; }
+
+cat <<\EOF > its/locators/messages.loc
+<?xml version="1.0"?>
+<locatingRules xmlns="http://thaiopensource.com/ns/locating-rules/1.0">
+ <documentElement prefix="" localName="messages" uri="messages.its"/>
+</locatingRules>
+EOF
+
+cat <<\EOF > its/rules/messages.its
+<?xml version="1.0"?>
+<its:rules xmlns:its="http://www.w3.org/2005/11/its"
+ xmlns:msg="http://www.gnu.org/s/gettext/ns/messages/1.0"
+ version="1.0">
+ <its:translateRule selector="//msg:message/@comment" translate="yes"/>
+ <its:translateRule selector="//msg:note" translate="no"/>
+ <its:locNoteRule selector="//msg:message/*" locNoteType="alert" locNotePointer="../msg:note"/>
+ <its:withinTextRule selector="//msg:span" withinText="yes"/>
+ <its:preserveSpaceRule selector="//msg:code" space="preserve"/>
+</its:rules>
+EOF
+
+cat <<\EOF >messages.xml
+<messages xmlns="http://www.gnu.org/s/gettext/ns/messages/1.0">
+ <message>
+ <p>This is a test message</p>
+ </message>
+ <message>
+ <p>This is a test message, with an <span>element</span> in a text</p>
+ </message>
+ <message>
+ <p>This is a test message, with an code in a text<code>
+$ echo foo >> /dev/null
+</code>
+ </p>
+ </message>
+ <message comment="This is a comment">
+ <p>This is a test message, with an attribute</p>
+ </message>
+ <message>
+ <note>
+ This is a localization note
+ </note>
+ <p>This is a test message, with a localization note</p>
+ </message>
+</messages>
+EOF
+
+cat <<\EOF >messages.ok
+#. (itstool) path: message/p
+#: messages.xml:3
+msgid "This is a test message"
+msgstr ""
+
+#. (itstool) path: message/p
+#: messages.xml:6
+msgid "This is a test message, with an <span>element</span> in a text"
+msgstr ""
+
+#. (itstool) path: p/code
+#: messages.xml:9
+#, no-wrap
+msgid ""
+"\n"
+"$ echo foo >> /dev/null\n"
+msgstr ""
+
+#. (itstool) path: messages/message@comment
+#: messages.xml:14
+msgid "This is a comment"
+msgstr ""
+
+#. (itstool) path: message/p
+#: messages.xml:15
+msgid "This is a test message, with an attribute"
+msgstr ""
+
+#. This is a localization note
+#. (itstool) path: message/p
+#: messages.xml:21
+msgid "This is a test message, with a localization note"
+msgstr ""
+EOF
+
+${XGETTEXT} --its --omit-header -o messages.pot messages.xml 2>messages.err || { cat messages.err; exit 1; }
+
+: ${DIFF=diff}
+${DIFF} messages.ok messages.pot
+result=$?