<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://okapiframework.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Translate5Support</id>
	<title>Okapi Framework - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://okapiframework.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Translate5Support"/>
	<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php/Special:Contributions/Translate5Support"/>
	<updated>2026-04-18T06:04:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1054</id>
		<title>SRX</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1054"/>
		<updated>2026-01-10T08:24:08Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Standards Common Menu}}&lt;br /&gt;
__TOC__&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The SRX (Segmentation Rules eXchange) format is a standard to save segmentation rules in a file so they can be used between different tools.&lt;br /&gt;
&lt;br /&gt;
It originally maintained by the OSCAR special interest group of the Localisation Industry Standards Association (LISA). In March 2011 LISA was closed and its standards moved under Creative Commons license.&lt;br /&gt;
&lt;br /&gt;
The version 2.0 is the latest version of the specification and can be found here: http://www.gala-global.org/oscarStandards/srx/srx20.html.&lt;br /&gt;
&lt;br /&gt;
SRX rules are grouped into named sets that are activated based the code of the language of the text to process. Each rule defines the text parts before and after the inter-segment location, and specifies if the location should be a break or not. The text parts are defined using [[Regular Expressions|regular expressions]].&lt;br /&gt;
&lt;br /&gt;
Example of SRX simple rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
 &amp;lt;/header&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;languagerules&amp;gt;&lt;br /&gt;
   &amp;lt;languagerule languagerulename=&amp;quot;default&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;([A-Z]\.){2,}&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
   &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;maprules&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;default&amp;quot;&amp;gt;&amp;lt;/languagemap&amp;gt;&lt;br /&gt;
  &amp;lt;/maprules&amp;gt;&lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there are two rules.&lt;br /&gt;
&lt;br /&gt;
The second one specifies that when an inter-character location is preceded by a period and followed by a white space, the rule is to break at that position. &lt;br /&gt;
&lt;br /&gt;
The first rule specifies that when an inter-character location is preceded by the patter &amp;lt;code&amp;gt;([A-Z]\.){2,}&amp;lt;/code&amp;gt; and followed by a white paces, the rule is to not break at that position. Because the first rule is placed before the second rule it takes precedence.&lt;br /&gt;
&lt;br /&gt;
So, based on those rules, the following text:&lt;br /&gt;
&lt;br /&gt;
 I'm in the U.K. for now. But I plan to move to Papua New Guinea.&lt;br /&gt;
&lt;br /&gt;
will break down into two segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K. for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
If the first rule was not there, it would break down into three segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K.]&lt;br /&gt;
 [ for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
==SRX Versions Issue==&lt;br /&gt;
&lt;br /&gt;
There are two versions of SRX: 1.0 and 2.0.&lt;br /&gt;
&lt;br /&gt;
SRX version 1.0 has been implemented by several tools that interpreted how to process the SRX rules in different ways. As a result the same SRX 1.0 document used on different tools may give you different segmentation.&lt;br /&gt;
&lt;br /&gt;
To resolve this issue, an updated version 2.0 specification has been published and provides better implementation guidelines. So, in theory, the same version 2.0 document should give you the same segmentation in all tools.&lt;br /&gt;
&lt;br /&gt;
You can find the specifications of SRX on the LISA web site:&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0: http://www.gala-global.org/oscarStandards/srx/srx10.html&lt;br /&gt;
* SRX 2.0: http://www.gala-global.org/oscarStandards/srx/srx20.html&lt;br /&gt;
&lt;br /&gt;
===Implementation Differences for SRX 1.0===&lt;br /&gt;
&lt;br /&gt;
There are two main types of implementations of SRX 1.0: the intended one, and one that use a cascading matching of the language maps.&lt;br /&gt;
&lt;br /&gt;
Tools like SDLX implemented the intended SRX 1.0 behavior (non-cascading). Others, like Swordfish implemented SRX 1.0 with a cascading behavior.&lt;br /&gt;
&lt;br /&gt;
In an SRX document, the segmentation rules are grouped into several &amp;lt;code&amp;gt;&amp;amp;lt;languagerule&amp;gt;&amp;lt;/code&amp;gt; elements. This way you can define different sets of rules that you apply for different languages. The select of which group of rules is to use for a given language is driven by a table defined in the &amp;lt;maprules&amp;gt; element. Each entry in &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt;. This entry has two information: a regular expression pattern that corresponds to what language code should use the entry, and a pointer to the group of rules for this entry.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;languagerules&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='default'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='japanese'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
&amp;lt;languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;maprules&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='ja.*' languagerulename='japanese'/&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='.*' languagerulename='default'/&amp;gt;&lt;br /&gt;
&amp;lt;/maprules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference between the SRX 1.0 implementations is how they lookup the &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; for a given language code.&lt;br /&gt;
&lt;br /&gt;
# Some will use only the first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that has a languagepattern matching the language code. &lt;br /&gt;
# Other will use all &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that have a &amp;lt;code&amp;gt;languagepattern&amp;lt;/code&amp;gt; matching the language code.&lt;br /&gt;
&lt;br /&gt;
The first interpretation is the correct one: In SRX 1.0 you use the only first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that matches the given language code.&lt;br /&gt;
&lt;br /&gt;
It is true that there is nothing in the SRX 1.0 specification that says explicitly it should work that way. But there is also nothing explicitly (or implicitly) that says all matching &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; should be used.&lt;br /&gt;
&lt;br /&gt;
The clue to the intended behavior is in the example of the SRX 1.0 specification:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s[a-z]&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Japanese&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[\xff61\x3002\xff0e\xff1f\xff01]+&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;maprules&amp;gt;&lt;br /&gt;
  &amp;lt;maprule maprulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;JA.*&amp;quot; languagerulename=&amp;quot;Japanese&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;Default&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/maprule&amp;gt;&lt;br /&gt;
 &amp;lt;/maprules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there is the same rules defined in both the Default and the Japanese groups. If SRX 1.0 intended to use all the &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; elements that match the given language code, there would be no point to have duplicated rules in Japanese. The Japanese group would have only the extra Japanese-specific rules.&lt;br /&gt;
&lt;br /&gt;
===How to Convert From SRX 1.0 to SRX 2.0?===&lt;br /&gt;
&lt;br /&gt;
The SRX 2.0 specification resolve the cascading issue by making it an option.&lt;br /&gt;
&lt;br /&gt;
When loading or importing SRX 1.0 documents into an SRX 2.0 editor, you must be careful about setting properly the cascade option depending on the provenance of the document.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Trados, SDLX and some other tools that implement the normal SRX 1.0 behavior (no cascading). So you should make sure that option is not set after you open the file.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Heartsome, Swordfish, and some other tools that are designed with cascading. So you should make sure that option is set after you have open the file.&lt;br /&gt;
&lt;br /&gt;
==SRX and Java==&lt;br /&gt;
&lt;br /&gt;
The SRX standard uses ICU regular expressions, however it is very difficult to implement the same set of expression using Java and some other programing languages.&lt;br /&gt;
&lt;br /&gt;
See more details in the [[SRX and Java]] section.&lt;br /&gt;
&lt;br /&gt;
==SRX in the Okapi Framework==&lt;br /&gt;
&lt;br /&gt;
The Okapi framework uses SRX in many places. For example:&lt;br /&gt;
&lt;br /&gt;
* [[Ratel]] is an application to edit SRX rules in WYSIWYG mode.&lt;br /&gt;
* Steps like the [[Segmentation Step]], the [[Sentence Alignment Step]] or the [[Batch Translation Step]] use SRX rules.&lt;br /&gt;
&lt;br /&gt;
'''Note that the framework implements a [[SRX Extensions|few extensions to SRX]].'''&lt;br /&gt;
&lt;br /&gt;
==Hint: Knowing when a no-break rule will match==&lt;br /&gt;
&lt;br /&gt;
Like any regular expression, a no-break rule matches a number of characters in a string. For example, the pattern &amp;quot;\s+&amp;quot; matches all whitespaces within the string: &amp;lt;pre&amp;gt;&amp;quot;   &amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whether a no-break rule takes effect to overwrite a break rule that follows further down in the SRX is defined by&lt;br /&gt;
&lt;br /&gt;
* if it matches the part of the string, that should not break&lt;br /&gt;
* AND if the position where it matches THE LAST is the same position or an earlier position than the last position, where the break-rule matches&lt;br /&gt;
&lt;br /&gt;
Therefore, the following SRX will NOT prevent splitting the sentence after &amp;quot;Co.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.\s&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this one will prevent the break:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Segmentation]] [[Category:SRX]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1053</id>
		<title>SRX</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1053"/>
		<updated>2026-01-10T08:23:04Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Standards Common Menu}}&lt;br /&gt;
__TOC__&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The SRX (Segmentation Rules eXchange) format is a standard to save segmentation rules in a file so they can be used between different tools.&lt;br /&gt;
&lt;br /&gt;
It originally maintained by the OSCAR special interest group of the Localisation Industry Standards Association (LISA). In March 2011 LISA was closed and its standards moved under Creative Commons license.&lt;br /&gt;
&lt;br /&gt;
The version 2.0 is the latest version of the specification and can be found here: http://www.gala-global.org/oscarStandards/srx/srx20.html.&lt;br /&gt;
&lt;br /&gt;
SRX rules are grouped into named sets that are activated based the code of the language of the text to process. Each rule defines the text parts before and after the inter-segment location, and specifies if the location should be a break or not. The text parts are defined using [[Regular Expressions|regular expressions]].&lt;br /&gt;
&lt;br /&gt;
Example of SRX simple rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
 &amp;lt;/header&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;languagerules&amp;gt;&lt;br /&gt;
   &amp;lt;languagerule languagerulename=&amp;quot;default&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;([A-Z]\.){2,}&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
   &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;maprules&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;default&amp;quot;&amp;gt;&amp;lt;/languagemap&amp;gt;&lt;br /&gt;
  &amp;lt;/maprules&amp;gt;&lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there are two rules.&lt;br /&gt;
&lt;br /&gt;
The second one specifies that when an inter-character location is preceded by a period and followed by a white space, the rule is to break at that position. &lt;br /&gt;
&lt;br /&gt;
The first rule specifies that when an inter-character location is preceded by the patter &amp;lt;code&amp;gt;([A-Z]\.){2,}&amp;lt;/code&amp;gt; and followed by a white paces, the rule is to not break at that position. Because the first rule is placed before the second rule it takes precedence.&lt;br /&gt;
&lt;br /&gt;
So, based on those rules, the following text:&lt;br /&gt;
&lt;br /&gt;
 I'm in the U.K. for now. But I plan to move to Papua New Guinea.&lt;br /&gt;
&lt;br /&gt;
will break down into two segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K. for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
If the first rule was not there, it would break down into three segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K.]&lt;br /&gt;
 [ for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
==SRX Versions Issue==&lt;br /&gt;
&lt;br /&gt;
There are two versions of SRX: 1.0 and 2.0.&lt;br /&gt;
&lt;br /&gt;
SRX version 1.0 has been implemented by several tools that interpreted how to process the SRX rules in different ways. As a result the same SRX 1.0 document used on different tools may give you different segmentation.&lt;br /&gt;
&lt;br /&gt;
To resolve this issue, an updated version 2.0 specification has been published and provides better implementation guidelines. So, in theory, the same version 2.0 document should give you the same segmentation in all tools.&lt;br /&gt;
&lt;br /&gt;
You can find the specifications of SRX on the LISA web site:&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0: http://www.gala-global.org/oscarStandards/srx/srx10.html&lt;br /&gt;
* SRX 2.0: http://www.gala-global.org/oscarStandards/srx/srx20.html&lt;br /&gt;
&lt;br /&gt;
===Implementation Differences for SRX 1.0===&lt;br /&gt;
&lt;br /&gt;
There are two main types of implementations of SRX 1.0: the intended one, and one that use a cascading matching of the language maps.&lt;br /&gt;
&lt;br /&gt;
Tools like SDLX implemented the intended SRX 1.0 behavior (non-cascading). Others, like Swordfish implemented SRX 1.0 with a cascading behavior.&lt;br /&gt;
&lt;br /&gt;
In an SRX document, the segmentation rules are grouped into several &amp;lt;code&amp;gt;&amp;amp;lt;languagerule&amp;gt;&amp;lt;/code&amp;gt; elements. This way you can define different sets of rules that you apply for different languages. The select of which group of rules is to use for a given language is driven by a table defined in the &amp;lt;maprules&amp;gt; element. Each entry in &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt;. This entry has two information: a regular expression pattern that corresponds to what language code should use the entry, and a pointer to the group of rules for this entry.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;languagerules&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='default'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='japanese'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
&amp;lt;languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;maprules&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='ja.*' languagerulename='japanese'/&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='.*' languagerulename='default'/&amp;gt;&lt;br /&gt;
&amp;lt;/maprules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference between the SRX 1.0 implementations is how they lookup the &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; for a given language code.&lt;br /&gt;
&lt;br /&gt;
# Some will use only the first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that has a languagepattern matching the language code. &lt;br /&gt;
# Other will use all &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that have a &amp;lt;code&amp;gt;languagepattern&amp;lt;/code&amp;gt; matching the language code.&lt;br /&gt;
&lt;br /&gt;
The first interpretation is the correct one: In SRX 1.0 you use the only first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that matches the given language code.&lt;br /&gt;
&lt;br /&gt;
It is true that there is nothing in the SRX 1.0 specification that says explicitly it should work that way. But there is also nothing explicitly (or implicitly) that says all matching &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; should be used.&lt;br /&gt;
&lt;br /&gt;
The clue to the intended behavior is in the example of the SRX 1.0 specification:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s[a-z]&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Japanese&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[\xff61\x3002\xff0e\xff1f\xff01]+&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;maprules&amp;gt;&lt;br /&gt;
  &amp;lt;maprule maprulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;JA.*&amp;quot; languagerulename=&amp;quot;Japanese&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;Default&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/maprule&amp;gt;&lt;br /&gt;
 &amp;lt;/maprules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there is the same rules defined in both the Default and the Japanese groups. If SRX 1.0 intended to use all the &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; elements that match the given language code, there would be no point to have duplicated rules in Japanese. The Japanese group would have only the extra Japanese-specific rules.&lt;br /&gt;
&lt;br /&gt;
===How to Convert From SRX 1.0 to SRX 2.0?===&lt;br /&gt;
&lt;br /&gt;
The SRX 2.0 specification resolve the cascading issue by making it an option.&lt;br /&gt;
&lt;br /&gt;
When loading or importing SRX 1.0 documents into an SRX 2.0 editor, you must be careful about setting properly the cascade option depending on the provenance of the document.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Trados, SDLX and some other tools that implement the normal SRX 1.0 behavior (no cascading). So you should make sure that option is not set after you open the file.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Heartsome, Swordfish, and some other tools that are designed with cascading. So you should make sure that option is set after you have open the file.&lt;br /&gt;
&lt;br /&gt;
==SRX and Java==&lt;br /&gt;
&lt;br /&gt;
The SRX standard uses ICU regular expressions, however it is very difficult to implement the same set of expression using Java and some other programing languages.&lt;br /&gt;
&lt;br /&gt;
See more details in the [[SRX and Java]] section.&lt;br /&gt;
&lt;br /&gt;
==SRX in the Okapi Framework==&lt;br /&gt;
&lt;br /&gt;
The Okapi framework uses SRX in many places. For example:&lt;br /&gt;
&lt;br /&gt;
* [[Ratel]] is an application to edit SRX rules in WYSIWYG mode.&lt;br /&gt;
* Steps like the [[Segmentation Step]], the [[Sentence Alignment Step]] or the [[Batch Translation Step]] use SRX rules.&lt;br /&gt;
&lt;br /&gt;
'''Note that the framework implements a [[SRX Extensions|few extensions to SRX]].'''&lt;br /&gt;
&lt;br /&gt;
==Hint: Knowing when a no-break rule will match==&lt;br /&gt;
&lt;br /&gt;
Like any regular expression, a no-break rule matches a number of characters in a string. For example, the pattern &amp;quot;\s+&amp;quot; matches all whitespaces within the string &amp;lt;pre&amp;gt;&amp;quot;   &amp;quot;&amp;lt;/pre&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Whether a no-break rule takes effect to overwrite a break rule that follows further down in the SRX is defined by&lt;br /&gt;
&lt;br /&gt;
* if it matches the part of the string, that should not break&lt;br /&gt;
* AND if the position where it matches THE LAST is the same position or an earlier position than the last position, where the break-rule matches&lt;br /&gt;
&lt;br /&gt;
Therefore, the following SRX will NOT prevent splitting the sentence after &amp;quot;Co.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.\s&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this one will prevent the break:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Segmentation]] [[Category:SRX]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1052</id>
		<title>SRX</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=SRX&amp;diff=1052"/>
		<updated>2026-01-10T08:17:00Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Standards Common Menu}}&lt;br /&gt;
__TOC__&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The SRX (Segmentation Rules eXchange) format is a standard to save segmentation rules in a file so they can be used between different tools.&lt;br /&gt;
&lt;br /&gt;
It originally maintained by the OSCAR special interest group of the Localisation Industry Standards Association (LISA). In March 2011 LISA was closed and its standards moved under Creative Commons license.&lt;br /&gt;
&lt;br /&gt;
The version 2.0 is the latest version of the specification and can be found here: http://www.gala-global.org/oscarStandards/srx/srx20.html.&lt;br /&gt;
&lt;br /&gt;
SRX rules are grouped into named sets that are activated based the code of the language of the text to process. Each rule defines the text parts before and after the inter-segment location, and specifies if the location should be a break or not. The text parts are defined using [[Regular Expressions|regular expressions]].&lt;br /&gt;
&lt;br /&gt;
Example of SRX simple rules:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot; version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
  &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
 &amp;lt;/header&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;languagerules&amp;gt;&lt;br /&gt;
   &amp;lt;languagerule languagerulename=&amp;quot;default&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;([A-Z]\.){2,}&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
    &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
     &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
    &amp;lt;/rule&amp;gt;&lt;br /&gt;
   &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;maprules&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;default&amp;quot;&amp;gt;&amp;lt;/languagemap&amp;gt;&lt;br /&gt;
  &amp;lt;/maprules&amp;gt;&lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there are two rules.&lt;br /&gt;
&lt;br /&gt;
The second one specifies that when an inter-character location is preceded by a period and followed by a white space, the rule is to break at that position. &lt;br /&gt;
&lt;br /&gt;
The first rule specifies that when an inter-character location is preceded by the patter &amp;lt;code&amp;gt;([A-Z]\.){2,}&amp;lt;/code&amp;gt; and followed by a white paces, the rule is to not break at that position. Because the first rule is placed before the second rule it takes precedence.&lt;br /&gt;
&lt;br /&gt;
So, based on those rules, the following text:&lt;br /&gt;
&lt;br /&gt;
 I'm in the U.K. for now. But I plan to move to Papua New Guinea.&lt;br /&gt;
&lt;br /&gt;
will break down into two segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K. for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
If the first rule was not there, it would break down into three segments:&lt;br /&gt;
&lt;br /&gt;
 [I'm in the U.K.]&lt;br /&gt;
 [ for now.]&lt;br /&gt;
 [ But I plan to move to Papua New Guinea.]&lt;br /&gt;
&lt;br /&gt;
==SRX Versions Issue==&lt;br /&gt;
&lt;br /&gt;
There are two versions of SRX: 1.0 and 2.0.&lt;br /&gt;
&lt;br /&gt;
SRX version 1.0 has been implemented by several tools that interpreted how to process the SRX rules in different ways. As a result the same SRX 1.0 document used on different tools may give you different segmentation.&lt;br /&gt;
&lt;br /&gt;
To resolve this issue, an updated version 2.0 specification has been published and provides better implementation guidelines. So, in theory, the same version 2.0 document should give you the same segmentation in all tools.&lt;br /&gt;
&lt;br /&gt;
You can find the specifications of SRX on the LISA web site:&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0: http://www.gala-global.org/oscarStandards/srx/srx10.html&lt;br /&gt;
* SRX 2.0: http://www.gala-global.org/oscarStandards/srx/srx20.html&lt;br /&gt;
&lt;br /&gt;
===Implementation Differences for SRX 1.0===&lt;br /&gt;
&lt;br /&gt;
There are two main types of implementations of SRX 1.0: the intended one, and one that use a cascading matching of the language maps.&lt;br /&gt;
&lt;br /&gt;
Tools like SDLX implemented the intended SRX 1.0 behavior (non-cascading). Others, like Swordfish implemented SRX 1.0 with a cascading behavior.&lt;br /&gt;
&lt;br /&gt;
In an SRX document, the segmentation rules are grouped into several &amp;lt;code&amp;gt;&amp;amp;lt;languagerule&amp;gt;&amp;lt;/code&amp;gt; elements. This way you can define different sets of rules that you apply for different languages. The select of which group of rules is to use for a given language is driven by a table defined in the &amp;lt;maprules&amp;gt; element. Each entry in &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt;. This entry has two information: a regular expression pattern that corresponds to what language code should use the entry, and a pointer to the group of rules for this entry.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;languagerules&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='default'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;languagerule languagerulename='japanese'&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
&amp;lt;languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;maprules&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='ja.*' languagerulename='japanese'/&amp;gt;&lt;br /&gt;
 &amp;lt;languagemap languagepattern='.*' languagerulename='default'/&amp;gt;&lt;br /&gt;
&amp;lt;/maprules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The difference between the SRX 1.0 implementations is how they lookup the &amp;lt;code&amp;gt;&amp;amp;lt;maprules&amp;gt;&amp;lt;/code&amp;gt; for a given language code.&lt;br /&gt;
&lt;br /&gt;
# Some will use only the first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that has a languagepattern matching the language code. &lt;br /&gt;
# Other will use all &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that have a &amp;lt;code&amp;gt;languagepattern&amp;lt;/code&amp;gt; matching the language code.&lt;br /&gt;
&lt;br /&gt;
The first interpretation is the correct one: In SRX 1.0 you use the only first &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; that matches the given language code.&lt;br /&gt;
&lt;br /&gt;
It is true that there is nothing in the SRX 1.0 specification that says explicitly it should work that way. But there is also nothing explicitly (or implicitly) that says all matching &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; should be used.&lt;br /&gt;
&lt;br /&gt;
The clue to the intended behavior is in the example of the SRX 1.0 specification:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;languagerules&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s[a-z]&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
  &amp;lt;languagerule languagerulename=&amp;quot;Japanese&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;blue&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;^\s*[0-9]+\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span class=&amp;quot;green&amp;quot;&amp;gt;  &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[Ee][Tt][Cc]\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
   &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;beforebreak&amp;gt;[\xff61\x3002\xff0e\xff1f\xff01]+&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
    &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
   &amp;lt;/rule&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
  &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
 &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;maprules&amp;gt;&lt;br /&gt;
  &amp;lt;maprule maprulename=&amp;quot;Default&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;JA.*&amp;quot; languagerulename=&amp;quot;Japanese&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;languagemap languagepattern=&amp;quot;.*&amp;quot; languagerulename=&amp;quot;Default&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/maprule&amp;gt;&lt;br /&gt;
 &amp;lt;/maprules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, there is the same rules defined in both the Default and the Japanese groups. If SRX 1.0 intended to use all the &amp;lt;code&amp;gt;&amp;amp;lt;languagemap&amp;gt;&amp;lt;/code&amp;gt; elements that match the given language code, there would be no point to have duplicated rules in Japanese. The Japanese group would have only the extra Japanese-specific rules.&lt;br /&gt;
&lt;br /&gt;
===How to Convert From SRX 1.0 to SRX 2.0?===&lt;br /&gt;
&lt;br /&gt;
The SRX 2.0 specification resolve the cascading issue by making it an option.&lt;br /&gt;
&lt;br /&gt;
When loading or importing SRX 1.0 documents into an SRX 2.0 editor, you must be careful about setting properly the cascade option depending on the provenance of the document.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Trados, SDLX and some other tools that implement the normal SRX 1.0 behavior (no cascading). So you should make sure that option is not set after you open the file.&lt;br /&gt;
&lt;br /&gt;
* SRX 1.0 rules coming from Heartsome, Swordfish, and some other tools that are designed with cascading. So you should make sure that option is set after you have open the file.&lt;br /&gt;
&lt;br /&gt;
==SRX and Java==&lt;br /&gt;
&lt;br /&gt;
The SRX standard uses ICU regular expressions, however it is very difficult to implement the same set of expression using Java and some other programing languages.&lt;br /&gt;
&lt;br /&gt;
See more details in the [[SRX and Java]] section.&lt;br /&gt;
&lt;br /&gt;
==SRX in the Okapi Framework==&lt;br /&gt;
&lt;br /&gt;
The Okapi framework uses SRX in many places. For example:&lt;br /&gt;
&lt;br /&gt;
* [[Ratel]] is an application to edit SRX rules in WYSIWYG mode.&lt;br /&gt;
* Steps like the [[Segmentation Step]], the [[Sentence Alignment Step]] or the [[Batch Translation Step]] use SRX rules.&lt;br /&gt;
&lt;br /&gt;
'''Note that the framework implements a [[SRX Extensions|few extensions to SRX]].'''&lt;br /&gt;
&lt;br /&gt;
==Hint: When a no-break rule will match and when not==&lt;br /&gt;
&lt;br /&gt;
A no-break rule can (as any regex) matches a number of characters in a string. Like \s+ does match all whitespaces within this string &amp;quot;   &amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If a no-break rule takes effect to overwrite a break-rule that follows further down in the srx is defined by&lt;br /&gt;
&lt;br /&gt;
* if it matches the part of the string, that should not break&lt;br /&gt;
* AND if the position where it matches THE LAST is the same position or an earlier position than the last position, where the break-rule matches&lt;br /&gt;
&lt;br /&gt;
Therefore the following srx will NOT lead to prevent the splitting of the sentence after &amp;quot;Co.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.\s&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But this one will prevent the break:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;srx xmlns=&amp;quot;http://www.lisa.org/srx20&amp;quot;&lt;br /&gt;
     xmlns:okpsrx=&amp;quot;http://okapi.sf.net/srx-extensions&amp;quot;&lt;br /&gt;
     version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;header segmentsubflows=&amp;quot;yes&amp;quot; cascade=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;start&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;end&amp;quot; include=&amp;quot;yes&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
    &amp;lt;formathandle type=&amp;quot;isolated&amp;quot; include=&amp;quot;no&amp;quot;&amp;gt;&amp;lt;/formathandle&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:options oneSegmentIncludesAll=&amp;quot;no&amp;quot;&lt;br /&gt;
                    trimLeadingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    trimTrailingWhitespaces=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useJavaRegex=&amp;quot;yes&amp;quot;&lt;br /&gt;
                    useIcu4JBreakRules=&amp;quot;no&amp;quot;&lt;br /&gt;
                    treatIsolatedCodesAsWhitespace=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/okpsrx:options&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:sample language=&amp;quot;de&amp;quot; useMappedRules=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
      Die Test GmbH + Co. KG mit Sitz in Stuttgart ist cool.&lt;br /&gt;
    &amp;lt;/okpsrx:sample&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;okpsrx:rangeRule&amp;gt;&amp;lt;/okpsrx:rangeRule&amp;gt;&lt;br /&gt;
  &amp;lt;/header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;languagerules&amp;gt;&lt;br /&gt;
      &amp;lt;languagerule languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;no&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\bCo\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;!-- sentence final punctuation (incl. quotation marks) - GERMAN --&amp;gt;&lt;br /&gt;
        &amp;lt;rule break=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;beforebreak&amp;gt;\.&amp;lt;/beforebreak&amp;gt;&lt;br /&gt;
          &amp;lt;afterbreak&amp;gt;\s&amp;lt;/afterbreak&amp;gt;&lt;br /&gt;
        &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;/languagerule&amp;gt;&lt;br /&gt;
    &amp;lt;/languagerules&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;maprules&amp;gt;&lt;br /&gt;
      &amp;lt;languagemap languagepattern=&amp;quot;(DE|de).*&amp;quot;&lt;br /&gt;
                   languagerulename=&amp;quot;German&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/languagemap&amp;gt;&lt;br /&gt;
    &amp;lt;/maprules&amp;gt;&lt;br /&gt;
  &amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/srx&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
while both no-break-rules match the relevant part &amp;quot;Co.&amp;quot; in the sentence.&lt;br /&gt;
&lt;br /&gt;
[[Category:Segmentation]] [[Category:SRX]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=JSON_Filter&amp;diff=1051</id>
		<title>JSON Filter</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=JSON_Filter&amp;diff=1051"/>
		<updated>2025-12-18T17:37:16Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Filters Header}}&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The JSON Filter is an Okapi component that implements the IFilter interface for JSON (Javascript Object Notation).&lt;br /&gt;
&lt;br /&gt;
The implementation is based on the JSON specifications: http://www.json.org/&lt;br /&gt;
&lt;br /&gt;
The following is an example of a very simple JSON file. The translatable text is highlighted:&lt;br /&gt;
&lt;br /&gt;
 {&amp;quot;menu&amp;quot;: {&lt;br /&gt;
   &amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;File&amp;lt;/span&amp;gt;&amp;quot;,&lt;br /&gt;
    &amp;quot;popup&amp;quot;: {&lt;br /&gt;
       &amp;quot;menuitem&amp;quot;: [&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;New&amp;lt;/span&amp;gt;&amp;quot;},&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Open&amp;lt;/span&amp;gt;&amp;quot;},&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Close&amp;lt;/span&amp;gt;&amp;quot;}&lt;br /&gt;
       ]&lt;br /&gt;
    }&lt;br /&gt;
 }}&lt;br /&gt;
&lt;br /&gt;
==Processing Details==&lt;br /&gt;
&lt;br /&gt;
===Input Encoding===&lt;br /&gt;
&lt;br /&gt;
JSON files are normally in one of the Unicode encoding, but the filter supports any encoding. It decides which encoding to use for the input file using the following logic:&lt;br /&gt;
&lt;br /&gt;
* If the file has a Unicode Byte-Order-Mark:&lt;br /&gt;
** Then, the corresponding encoding (e.g. UTF-8, UTF-16, etc.) is used.&lt;br /&gt;
* Else, if a header entry with a &amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt; declaration exists in the first 1000 characters of the file:&lt;br /&gt;
** If the value of the &amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt; is &amp;quot;&amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt;&amp;quot; (case insensitive):&lt;br /&gt;
*** Then the file is likely to be a template with no encoding declared, so the current encoding (auto-detected or default) is used.&lt;br /&gt;
*** Else, the declared encoding is used. Note that if the encoding has been detected from a Byte-Order-Mark and the encoding declared in the header entry does not match, a warning is generated and the encoding of the Byte-Order-Mark is used.&lt;br /&gt;
* Otherwise, the input encoding used is the default encoding that was specified when setting the filter options.&lt;br /&gt;
&lt;br /&gt;
===Output Encoding===&lt;br /&gt;
&lt;br /&gt;
If the output encoding is UTF-8:&lt;br /&gt;
&lt;br /&gt;
* If the input encoding was also UTF-8, a Byte-Order-Mark is used for the output document only if one was detected in the input document.&lt;br /&gt;
* If the input encoding was not UTF-8, no Byte-Order-Mark is used in the output document.&lt;br /&gt;
&lt;br /&gt;
===Line-Breaks===&lt;br /&gt;
&lt;br /&gt;
The type of line-breaks of the output is the same as the one of the original input.&lt;br /&gt;
&lt;br /&gt;
===Comments===&lt;br /&gt;
&lt;br /&gt;
Though not technically legal in JSON these comment types are supported:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
* // comment&lt;br /&gt;
* # comment&lt;br /&gt;
* /* comment */&lt;br /&gt;
* &amp;amp;lt;!-- comment --&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Options Tab===&lt;br /&gt;
&lt;br /&gt;
====Stand-alone strings====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Extract strings without associated key&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to extract string that are not associated directly to a key value.&lt;br /&gt;
&lt;br /&gt;
====Strings with keys====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Extract all key/strings pairs&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to extract all strings that have a key associated. If a regular expression for exceptions is defined, the strings that have a key matching the expression are not extracted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Do not extract key/string pairs&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set the option to not extract any string that has an associated key. If a regular expression for exceptions is defined, the strings that have a key matching the expression are extracted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Excepted when the key matches the following regular expression&amp;lt;/cite&amp;gt; &amp;amp;mdash; Enter a regular expression that correspond to the keys that should have a behavior inverse to the default behavior you have selected for the key/strings pairs.&lt;br /&gt;
For example, you could exclude a key-value with &amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt;.&lt;br /&gt;
In combination with &amp;lt;code&amp;gt;Use the full key path&amp;lt;/code&amp;gt; you can exclude all nested elements in a JSON structure with &amp;lt;code&amp;gt;^.*?/excludedStructure/.*&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Use the key as the resname&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the value of the key as the value of the name of the extracted item (&amp;lt;code&amp;gt;resname&amp;lt;/code&amp;gt; in XLIFF).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Use the full key path&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the full key path in the &amp;lt;code&amp;gt;resname&amp;lt;/code&amp;gt;. For example: &amp;lt;code&amp;gt;/menu/value/popup/menuitem/value&amp;lt;/code&amp;gt;. The use key name as resname option must be set for this option to take effect. If enabled, exception regular expressions apply to the full path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Include leading &amp;quot;/&amp;quot; on key path&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to have a leading character '/' in the full key path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys that are notes, values of which to appear as &amp;lt;note&amp;gt; in XLIFF&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify regular expression. The values of the matching keys will be transferred to &amp;amp;lt;note&amp;gt; elements in XLIFF.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are added as TextUnit Metadata&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify regular expression. The values of the matching keys will be written out as &amp;amp;lt;context-group&amp;gt; elements in XLIFF.&lt;br /&gt;
&lt;br /&gt;
===New Extraction Rules &amp;gt;= version M39===&lt;br /&gt;
&amp;lt;b&amp;gt;If specified these will override the corresponding rules above.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are extracted (overrides extraction exceptions)&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys that are notes, values of which to appear as &amp;lt;note&amp;gt; in XLIFF&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys which are ID's (resname in XLIFF), overrides &amp;quot;use key as resname&amp;quot;&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Hint:&amp;lt;/b&amp;gt; If you have the following json, that contains the actual key in the value of a neighboring key/value pair&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
	&amp;quot;key&amp;quot;: &amp;quot;datePicker_marchMonth&amp;quot;,&lt;br /&gt;
	&amp;quot;text&amp;quot;: &amp;quot;March&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
	&amp;quot;key&amp;quot;: &amp;quot;datePicker_aprilMonth&amp;quot;,&lt;br /&gt;
	&amp;quot;text&amp;quot;: &amp;quot;April&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and define simply the regex &amp;quot;key&amp;quot; in this configuration option, you would get the following xliff extracted&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;trans-unit id=&amp;quot;tu1&amp;quot; resname=&amp;quot;datePicker_marchMonth&amp;quot; xml:space=&amp;quot;preserve&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;source xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;March&amp;lt;/source&amp;gt;&lt;br /&gt;
  &amp;lt;target xml:lang=&amp;quot;de-DE&amp;quot;&amp;gt;&amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/trans-unit&amp;gt;&lt;br /&gt;
&amp;lt;trans-unit id=&amp;quot;tu2&amp;quot; resname=&amp;quot;datePicker_aprilMonth&amp;quot; xml:space=&amp;quot;preserve&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;source xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;April&amp;lt;/source&amp;gt;&lt;br /&gt;
  &amp;lt;target xml:lang=&amp;quot;de-DE&amp;quot;&amp;gt;&amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/trans-unit&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are added as TextUnit Metadata&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys that are numbers, values of which will be extracted as maxwidth property in XLIFF&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If specified, its extracted value is used as maxwidth of all other elements of the array on that level.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;There is only one matching array element for the regex allowed on each hierarchy level of the regex.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If there are nested array levels, for all parent-child levels and also different sibling levels different maxwidth values can be defined.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If there are different values defined, still the key of all definitions can be the same.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If on a sublevel no key matches the regex within the current level, but a key on a higher level does, the definition on the higher level determines the max length of the deepest hierarchy level (and only this one - not higher levels) and its siblings without matching key.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;If on a higher level a key matches and on all lower levels also keys match, than for all elements of the corresponding levels values are extrated. BUT: For the higher level(s) the matching key must be defined after the last child element.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;The size unit property to use when maxwidth poperties are extracted&amp;lt;/cite&amp;gt;&lt;br /&gt;
The string that is entered here is used as value for the size-unit attribute of the trans-unit in xliff with length restriction.&lt;br /&gt;
&lt;br /&gt;
====Example FPRM Settings:====&lt;br /&gt;
Regex rules apply to key names.&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&amp;lt;b&amp;gt;extraction rules (use instead of rule exceptions):&amp;lt;/b&amp;gt;&lt;br /&gt;
extractionRules=/widgets/body.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;note rules (add values to TextUnits as notes):&amp;lt;/b&amp;gt;&lt;br /&gt;
noteRules=/widgets/name.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;id rules (overrides useKeyAsName):&amp;lt;/b&amp;gt;&lt;br /&gt;
idRules=/widgets/id.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;generic metadata (matched key:values are added as metadata to TextUnit):&amp;lt;/b&amp;gt;&lt;br /&gt;
genericMetaRules=/widgets/image.*'''&lt;br /&gt;
&lt;br /&gt;
===Content Processing Tab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Process text content with this sub-filter&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify an Okapi filter ID (e.g. &amp;lt;code&amp;gt;okf_html&amp;lt;/code&amp;gt;) to process the content of all translatable text with that filter. Leave this field blank for default behavior.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Find inline codes by patterns defined below&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the specified regular expressions on the text of the extracted items. Any match will be converted to an inline code.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This option cannot be used together with the sub-filtering option.&lt;br /&gt;
&lt;br /&gt;
By default the expression is:&lt;br /&gt;
&lt;br /&gt;
 ((%(([-0+#]?)[-0+#]?)((\d\$)?)(([\d\*]*)(\.[\d\*]*)?)[dioxXucsfeEgGpn])&lt;br /&gt;
 |((\\r\\n)|\\a|\\b|\\f|\\n|\\r|\\t|\\v)&lt;br /&gt;
 |(\{\d.*?\}))&lt;br /&gt;
&lt;br /&gt;
{{CodeFinder Help}}&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
&lt;br /&gt;
Comments within a JSON string are parsed as part of the string content, not as comments. A configured subfilter will then process these as true comments (they will become part of the skeleton or whatever the filter is configured to do).&lt;br /&gt;
[[Category:Filters]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1004</id>
		<title>XML Filter</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1004"/>
		<updated>2024-03-28T21:23:47Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: /* Filter Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Filters Header}}&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
This filter allows you to process XML documents. It uses a DOM-based parser, which allows it to implement [[ITS]]. If you need to process very large XML documents and have no need for ITS, you may want to look at using the [[XML Stream Filter]].&lt;br /&gt;
&lt;br /&gt;
The following is an example of a simple XML document. The translatable text is highlighted. Because each format based on XML is different, you need information on what are the translatable parts, what are the inline elements, etc. The XML Filter [[#ITS Support|implements the ITS W3C Recommendation]] to address this issue.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;amp;lt;myDoc&amp;gt;&lt;br /&gt;
  &amp;amp;lt;prolog&amp;gt;&lt;br /&gt;
   &amp;amp;lt;author&amp;gt;Zebulon Fairfield&amp;lt;/author&amp;gt;&lt;br /&gt;
   &amp;amp;lt;version&amp;gt;version 12, revision 2 - 2006-08-14&amp;lt;/version&amp;gt;&lt;br /&gt;
   &amp;amp;lt;keywords&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;horse&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;appaloosa&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;/keywords&amp;gt;&lt;br /&gt;
   &amp;amp;lt;storageKey&amp;gt;articles-6D272BA9-3B89CAD8&amp;lt;/storageKey&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/prolog&amp;gt;&lt;br /&gt;
  &amp;amp;lt;body&amp;gt;&lt;br /&gt;
   &amp;amp;lt;title&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Appaloosa&amp;lt;/span&amp;gt;&amp;amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;The Appaloosas are rugged horses originally breed by &lt;br /&gt;
 the &amp;lt;kw&amp;gt;Nez-Perce&amp;lt;/kw&amp;gt; tribe in the US Northwest.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;They are often characterized by their spotted coats.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;amp;lt;/myDoc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This filter is implemented in the class &amp;lt;code&amp;gt;net.sf.okapi.filters.xml.XMLFilter&amp;lt;/code&amp;gt; of the library.&lt;br /&gt;
&lt;br /&gt;
==Processing Details==&lt;br /&gt;
&lt;br /&gt;
===Input Encoding===&lt;br /&gt;
&lt;br /&gt;
The filter decides which encoding to use for the input document using the following logic:&lt;br /&gt;
&lt;br /&gt;
* If the document has an encoding declaration it is used. &lt;br /&gt;
* Otherwise, UTF-8 is used as the default encoding (regardless the actual default encoding that was specified when opening the document). &lt;br /&gt;
&lt;br /&gt;
===Output Encoding===&lt;br /&gt;
&lt;br /&gt;
If the output encoding is UTF-8:&lt;br /&gt;
&lt;br /&gt;
* If the input encoding was also UTF-8, a Byte-Order-Mark is used for the output document only if one was detected in the input document. &lt;br /&gt;
* If the input encoding was not UTF-8, no Byte-Order-Mark is used in the output document. &lt;br /&gt;
&lt;br /&gt;
If the original document had an XML encoding declaration it is updated, if it did not, one is automatically added.&lt;br /&gt;
&lt;br /&gt;
===Line-Breaks===&lt;br /&gt;
&lt;br /&gt;
The type of line-breaks of the output is the same as the one of the original input.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
This filter stores its parameters in an XML file and does not provide an editor to modify it. You can edit the file in a simple text editor, or with an XML editor. For an example, see the article &amp;quot;[[How to Create a Custom Configuration for the XML Filter]]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===ITS Support===&lt;br /&gt;
&lt;br /&gt;
By default the filter process the XML documents based on the '''ITS defaults'''. That is:&lt;br /&gt;
&lt;br /&gt;
* the content of all elements is translatable,&lt;br /&gt;
* and none of the values of the attribute translatable.&lt;br /&gt;
&lt;br /&gt;
Different behavior can occur if the input document contains ITS markup, or if a filter parameters file is specified. The parameters file used by the the XML Filter is [[ITS|an ITS document]].&lt;br /&gt;
&lt;br /&gt;
The '''Internationalization Tag set (ITS)''' is a W3C recommendation that defines a set of elements and attributes you can use to specify different internationalization- and localization-related aspects of your XML document, for instance: ITS defines what attribute values are translatable, what element content should be protected, what element should be treated as a nested sub-flow of text, and much more.&lt;br /&gt;
&lt;br /&gt;
The filter supports ITS 1.0 and ITS 2.0 (2.0 is backward compatible with 1.0)&lt;br /&gt;
&lt;br /&gt;
* The ITS 1.0 specification is available at http://www.w3.org/TR/its/.&lt;br /&gt;
* The ITS 2.0 specification is available at http://www.w3.org/TR/its20/.&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[[ITS]]&amp;quot; page for more details on the format.&lt;br /&gt;
&lt;br /&gt;
The filter supports global and local rules and most data categories. See the '''[[ITS Components]]''' page for a detailed list of how the data categories are supported and other information on the implementation.&lt;br /&gt;
&lt;br /&gt;
===ITS Extensions===&lt;br /&gt;
&lt;br /&gt;
The filter supports extensions to the ITS specification. These extension use the namespace URI http://www.w3.org/2008/12/its-extensions.&lt;br /&gt;
&lt;br /&gt;
* [[#idValue and xml:id|idValue and xml:id]]&lt;br /&gt;
* [[#whiteSpaces|whiteSpaces]]&lt;br /&gt;
&lt;br /&gt;
====idValue and xml:id====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#idvalue Id Value] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
When the attribute &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; is found on a translatable element, it is used as the name of the text unit generated for that element.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;p xml:id=&amp;quot;id1&amp;quot;&amp;gt;Text&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; used in the ITS &amp;lt;code&amp;gt;translateRule&amp;lt;/code&amp;gt; element allows you to define an XPath expression that correspeonds to the identifier value for the given selection. The value of &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; must be an expression that can return a string. A node location is a valid expression: it will return the value of the first node at the given location.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; has precedence over &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; declaration. For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;xid1&amp;lt;/code&amp;gt;&amp;quot;, not &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p xml:id=&amp;quot;xid1&amp;quot; name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can build complex ID based on different attributes, element or event hard-coded text. Any of the String functions offered by XPath can be used.&lt;br /&gt;
&lt;br /&gt;
For example, in the file below, the two elements &amp;lt;code&amp;gt;&amp;amp;tl;text&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt; are translatable, but they have only one corresponding ID, the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; attribute in their parent element. To make sure you have a unique identifier for both the content of &amp;lt;code&amp;gt;&amp;amp;lt;text&amp;gt;&amp;lt;/code&amp;gt; and the content of &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt;, you can use the rules set in the example. The XPath expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_t')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_t&amp;lt;/code&amp;gt;&amp;quot; and the expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_d')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_d&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//text&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_t')&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//desc&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_d')&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;msg name=&amp;quot;id1&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;text&amp;gt;Value of text&amp;lt;/text&amp;gt;&lt;br /&gt;
  &amp;lt;desc&amp;gt;Value of desc&amp;lt;/desc&amp;gt;&lt;br /&gt;
 &amp;lt;/msg&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====whiteSpaces====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#preservespace Preserve Space] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
The extension attribute whiteSpaces allows you to apply globally the equivalent of a local &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
For example, if you have a format where all element &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; must have their spaces, tabs and line breaks preserved, you can specify the attribute &amp;lt;code&amp;gt;whiteSpaces=&amp;quot;preserve&amp;quot;&amp;lt;/code&amp;gt; in a &amp;lt;code&amp;gt;&amp;amp;lt;its:translateRule&amp;gt;&amp;lt;/code&amp;gt; element for the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; elements. In the example below, the spaces in the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; element will be preserved on extraction.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;lt;pre&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute has precedence over &amp;lt;code&amp;gt;whiteSpaces&amp;lt;/code&amp;gt;. For example, in the following example, the white spaces in the content of &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; may '''not''' be preserved because the attribute &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; has the value &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;&amp;amp;lt;pre xml:space=&amp;quot;default&amp;quot;&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Filter Options===&lt;br /&gt;
&lt;br /&gt;
The filter supports also options in addition to ITS and ITS extension. These options use the namespace URI &amp;lt;code&amp;gt;okapi-framework:xmlfilter-options&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|The filter options must be placed in the parameters file (.fprm) used with the filter, not in embedded or linked ITS rules. Options placed in embedded or linked ITS rules have no effect.}}&lt;br /&gt;
&lt;br /&gt;
When you use several options, they must be set in a single &amp;lt;code&amp;gt;&amp;amp;lt;okp:options&amp;gt;&amp;lt;/code&amp;gt; element, as shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;&lt;br /&gt;
              escapeQuotes=&amp;quot;no&amp;quot;&lt;br /&gt;
              escapeGT=&amp;quot;yes&amp;quot;&lt;br /&gt;
 /&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following options are available:&lt;br /&gt;
&lt;br /&gt;
* [[#lineBreakAsCode|lineBreakAsCode]]&lt;br /&gt;
* [[#codeFinder|codeFinder]]&lt;br /&gt;
* [[#omitXMLDeclaration|omitXMLDeclaration]]&lt;br /&gt;
* [[#escapeQuotes|escapeQuotes]]&lt;br /&gt;
* [[#escapeGT|escapeGT]]&lt;br /&gt;
* [[#escapeNbsp|escapeNbsp]]&lt;br /&gt;
* [[#extractIfOnlyCodes|extractIfOnlyCodes]]&lt;br /&gt;
* [[#inlineCdata|inlineCdata]]&lt;br /&gt;
* [[#extractUntranslatable|extractUntranslatable]]&lt;br /&gt;
&lt;br /&gt;
====lineBreakAsCode====&lt;br /&gt;
&lt;br /&gt;
In some cases the content of element includes line-breaks that need to be included as part of the content but without using an actual line-break in the extracted text. For example in some XML documents generated by Excel, the formatting of the cells is marked up with &amp;lt;code&amp;gt;&amp;amp;amp;#10;&amp;lt;/code&amp;gt; entity references. They need to be passed as inline codes.&lt;br /&gt;
&lt;br /&gt;
By default this option is set to false.&lt;br /&gt;
&lt;br /&gt;
To specify this the filter use the extension &amp;lt;code&amp;gt;lineBreakAsCode&amp;lt;/code&amp;gt; extension attribute. This affect all the extracted content.&lt;br /&gt;
&lt;br /&gt;
For example: The following code is an ITS document with the option to treat line-breaks as code. It can be used along with the example of XML document listed below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;data&amp;gt;line 1&amp;amp;amp;#10;line 2.&amp;lt;/data&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====codeFinder====&lt;br /&gt;
&lt;br /&gt;
You can define a set of regular expressions to capture span of extracted text that should be treated as inline codes. For example, some element content may have variables, or HTML tags that need to be protected from modification and treated as codes. Use the codeFinder element for this.&lt;br /&gt;
&lt;br /&gt;
In the following parameters file, the &amp;lt;code&amp;gt;codeFinder&amp;lt;/code&amp;gt; element defines two rules:&lt;br /&gt;
&lt;br /&gt;
* The first one (rule0) is &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; and matches any XML-type tags (e.g. &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;br/&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;)&lt;br /&gt;
* The second one (rule1) is &amp;quot;&amp;lt;code&amp;gt;(#\w+?\#)|(%\d+?%)&amp;lt;/code&amp;gt;&amp;quot; and matches any word enclosed in &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;#VAR#&amp;lt;/code&amp;gt;&amp;quot;) or number enclosed in &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;%1%&amp;lt;/code&amp;gt;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:codeFinder useCodeFinder=&amp;quot;yes&amp;quot;&amp;gt;#v1&lt;br /&gt;
count.i=2&lt;br /&gt;
rule0=&amp;amp;amp;lt;(/?)\w+[^&amp;amp;amp;gt;]*?&amp;amp;amp;gt;&lt;br /&gt;
rule1=(#\w+?\#)|(%\d+?%)&lt;br /&gt;
 &amp;lt;/okp:codeFinder&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some important details:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;lt;code&amp;gt;useCodeFinder&amp;lt;/code&amp;gt; to &amp;quot;yes&amp;quot; to have the rules used, if the attribute is missing its value is assumed to be &amp;quot;no&amp;quot;.&lt;br /&gt;
* Make sure the first line of the &amp;lt;code&amp;gt;&amp;amp;lt;codeFinder&amp;gt;&amp;lt;/code&amp;gt; element content is &amp;lt;code&amp;gt;#v1&amp;lt;/code&amp;gt;. &lt;br /&gt;
* Each entry in the content must be on a separate line. &lt;br /&gt;
* &amp;lt;code&amp;gt;count.i=N&amp;lt;/code&amp;gt; must be before any rules and &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; must be the number of rules. &lt;br /&gt;
* &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt; must be incremented starting at 0. &lt;br /&gt;
* The pattern for a rule must be escaped for XML, for example: &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; must be entered &amp;quot;&amp;lt;code&amp;gt;&amp;amp;amp;lt;(/?)\w[^&amp;amp;amp;lt;]*?&amp;amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot; in the parameters file. &lt;br /&gt;
* Do not put spaces before &amp;lt;code&amp;gt;count.i&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt;, and not after your expressions.&lt;br /&gt;
&lt;br /&gt;
To facilitate the creation of code finder rules [[Rainbow - Code Finder Editor|Rainbow provides the Code Finder Editor]].&lt;br /&gt;
&lt;br /&gt;
====omitXMLDeclaration====&lt;br /&gt;
&lt;br /&gt;
By default an XML declaration is always set at the top of the output document (regardless wether the original document has one or not). It is an important part of the XML document and it is especially needed when the encoding of the output document is not UTF-8, UTF-16 or UTF-32, as its name must be specified in the XML declaration. However, there are a few special cases when the declaration is better left off. To handle those rare cases, you can use &amp;lt;code&amp;gt;omitXMLDeclation&amp;lt;/code&amp;gt; to indicate the filter to not output the XML declaration.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options omitXMLDeclaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that XML documents without an XML declaration may be read incorrectly if the encoding of the document is not UTF-8, UTF-16 or UTF-32.&lt;br /&gt;
&lt;br /&gt;
====escapeQuotes====&lt;br /&gt;
&lt;br /&gt;
By default, when processing the document, the filter uses double-quotes to enclose all attributes (translatable or not) and use the following rules for escaping/not-escaping the literal quotes:&lt;br /&gt;
&lt;br /&gt;
* Inside the attribute values:&lt;br /&gt;
** Single-quotes (=apostrophes) are never escaped&lt;br /&gt;
** Double-quotes are always escaped&lt;br /&gt;
* In element content:&lt;br /&gt;
** Single-quotes (=apostrophes) are not escaped&lt;br /&gt;
** Double-quotes are escaped by default&lt;br /&gt;
&lt;br /&gt;
You cannot change the escaping rules for attributes.&lt;br /&gt;
&lt;br /&gt;
For element content: If the document is processed without triggering any rule that allow the translation of an attribute, then (and only then) the filter takes into account the &amp;lt;code&amp;gt;escapeQuotes&amp;lt;/code&amp;gt; option to escape or not double-quotes in the translatable content.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file allows to not escape double-quotes in element content (for the documents where there is no rule for translatable attributes are triggered):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeQuotes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeGT====&lt;br /&gt;
&lt;br /&gt;
By default the character '&amp;lt;code&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;' is escaped. You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeGT&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape greater-than characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeGT=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeNbsp====&lt;br /&gt;
&lt;br /&gt;
By default the non-breaking space character is escaped (in the form &amp;lt;code&amp;gt;&amp;amp;amp;#x00a0;&amp;lt;/code&amp;gt;). You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeNbsp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape the non-breaking space characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeNbsp=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractIfOnlyCodes====&lt;br /&gt;
&lt;br /&gt;
By default all extractable entries are extracted even when they contain only white-spaces and/or inline codes. You can indicate to the filter to not extract such entries using the &amp;lt;code&amp;gt;extractIfOnlyCodes&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not extract entries with only whte-spaces and/or inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractIfOnlyCodes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====inlineCdata====&lt;br /&gt;
&lt;br /&gt;
By default, CDATA sections will be exposed as regular content, and the CDATA markers themselves will be discarded.  When the &amp;lt;code&amp;gt;inlineCdata&amp;lt;/code&amp;gt; option is set,&lt;br /&gt;
the CDATA markers will be exposed as inline codes.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file will expose CDATA markers as inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options inlineCdata=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractUntranslatable====&lt;br /&gt;
&lt;br /&gt;
All untranslatable entries (&amp;lt;code&amp;gt;its:translate=&amp;quot;no&amp;quot;&amp;lt;/code&amp;gt;) are not extracted by default. And in order to allow the extraction of such entries for context reasons, the following option has to be used: &amp;lt;code&amp;gt;extractUntranslatable&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Below is an example of this option declaration: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractUntranslatable=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this option contents that are untranslatable will be extracted, but marked as translate=&amp;quot;no&amp;quot; in xliff.&lt;br /&gt;
&lt;br /&gt;
Hint: If you want to extract certain untranslatable contents and others not: By default all untranslatable contents are extracted, if extractUntranslatable=&amp;quot;yes&amp;quot;. To exclude certain contents, you can use the following rule and &amp;quot;misuse&amp;quot; the  localeFilterList ITS attribute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractUntranslatable=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;its:localeFilterRule selector=&amp;quot;//yourTagThatShouldNotBeExtracted&amp;quot; localeFilterList=&amp;quot;!*&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
&lt;br /&gt;
* Currently, in some cases, the ITS rule &amp;lt;code&amp;gt;withinTextRule&amp;lt;/code&amp;gt; with the value &amp;lt;code&amp;gt;nested&amp;lt;/code&amp;gt; may act like it has a value &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
* In output, the values of the &amp;lt;code&amp;gt;xml:lang&amp;lt;/code&amp;gt; attributes are not updated to reflect the target language.&lt;br /&gt;
* When doing the extraction, the whole input file is loaded into memory. You may run into memory limitation if the document is very large.&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]] [[Category:ITS]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=JSON_Filter&amp;diff=1003</id>
		<title>JSON Filter</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=JSON_Filter&amp;diff=1003"/>
		<updated>2024-03-13T16:33:41Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: /* New Extraction Rules &amp;gt;= version M39 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Filters Header}}&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
The JSON Filter is an Okapi component that implements the IFilter interface for JSON (Javascript Object Notation).&lt;br /&gt;
&lt;br /&gt;
The implementation is based on the JSON specifications: http://www.json.org/&lt;br /&gt;
&lt;br /&gt;
The following is an example of a very simple JSON file. The translatable text is highlighted:&lt;br /&gt;
&lt;br /&gt;
 {&amp;quot;menu&amp;quot;: {&lt;br /&gt;
   &amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;File&amp;lt;/span&amp;gt;&amp;quot;,&lt;br /&gt;
    &amp;quot;popup&amp;quot;: {&lt;br /&gt;
       &amp;quot;menuitem&amp;quot;: [&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;New&amp;lt;/span&amp;gt;&amp;quot;},&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Open&amp;lt;/span&amp;gt;&amp;quot;},&lt;br /&gt;
          {&amp;quot;value&amp;quot;: &amp;quot;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Close&amp;lt;/span&amp;gt;&amp;quot;}&lt;br /&gt;
       ]&lt;br /&gt;
    }&lt;br /&gt;
 }}&lt;br /&gt;
&lt;br /&gt;
==Processing Details==&lt;br /&gt;
&lt;br /&gt;
===Input Encoding===&lt;br /&gt;
&lt;br /&gt;
JSON files are normally in one of the Unicode encoding, but the filter supports any encoding. It decides which encoding to use for the input file using the following logic:&lt;br /&gt;
&lt;br /&gt;
* If the file has a Unicode Byte-Order-Mark:&lt;br /&gt;
** Then, the corresponding encoding (e.g. UTF-8, UTF-16, etc.) is used.&lt;br /&gt;
* Else, if a header entry with a &amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt; declaration exists in the first 1000 characters of the file:&lt;br /&gt;
** If the value of the &amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt; is &amp;quot;&amp;lt;code&amp;gt;charset&amp;lt;/code&amp;gt;&amp;quot; (case insensitive):&lt;br /&gt;
*** Then the file is likely to be a template with no encoding declared, so the current encoding (auto-detected or default) is used.&lt;br /&gt;
*** Else, the declared encoding is used. Note that if the encoding has been detected from a Byte-Order-Mark and the encoding declared in the header entry does not match, a warning is generated and the encoding of the Byte-Order-Mark is used.&lt;br /&gt;
* Otherwise, the input encoding used is the default encoding that was specified when setting the filter options.&lt;br /&gt;
&lt;br /&gt;
===Output Encoding===&lt;br /&gt;
&lt;br /&gt;
If the output encoding is UTF-8:&lt;br /&gt;
&lt;br /&gt;
* If the input encoding was also UTF-8, a Byte-Order-Mark is used for the output document only if one was detected in the input document.&lt;br /&gt;
* If the input encoding was not UTF-8, no Byte-Order-Mark is used in the output document.&lt;br /&gt;
&lt;br /&gt;
===Line-Breaks===&lt;br /&gt;
&lt;br /&gt;
The type of line-breaks of the output is the same as the one of the original input.&lt;br /&gt;
&lt;br /&gt;
===Comments===&lt;br /&gt;
&lt;br /&gt;
Though not technically legal in JSON these comment types are supported:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
* // comment&lt;br /&gt;
* # comment&lt;br /&gt;
* /* comment */&lt;br /&gt;
* &amp;amp;lt;!-- comment --&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
=== Options Tab===&lt;br /&gt;
&lt;br /&gt;
====Stand-alone strings====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Extract strings without associated key&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to extract string that are not associated directly to a key value.&lt;br /&gt;
&lt;br /&gt;
====Strings with keys====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Extract all key/strings pairs&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to extract all strings that have a key associated. If a regular expression for exceptions is defined, the strings that have a key matching the expression are not extracted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Do not extract key/string pairs&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set the option to not extract any string that has an associated key. If a regular expression for exceptions is defined, the strings that have a key matching the expression are extracted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Excepted when the key matches the following regular expression&amp;lt;/cite&amp;gt; &amp;amp;mdash; Enter a regular expression that correspond to the keys that should have a behavior inverse to the default behavior you have selected for the key/strings pairs.&lt;br /&gt;
For example, you could exclude a key-value with &amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt;.&lt;br /&gt;
In combination with &amp;lt;code&amp;gt;Use the full key path&amp;lt;/code&amp;gt; you can exclude all nested elements in a JSON structure with &amp;lt;code&amp;gt;^.*?/excludedStructure/.*&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Use the key as the resname&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the value of the key as the value of the name of the extracted item (&amp;lt;code&amp;gt;resname&amp;lt;/code&amp;gt; in XLIFF).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Use the full key path&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the full key path in the &amp;lt;code&amp;gt;resname&amp;lt;/code&amp;gt;. For example: &amp;lt;code&amp;gt;/menu/value/popup/menuitem/value&amp;lt;/code&amp;gt;. The use key name as resname option must be set for this option to take effect. If enabled, exception regular expressions apply to the full path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Include leading &amp;quot;/&amp;quot; on key path&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to have a leading character '/' in the full key path.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys that are notes, values of which to appear as &amp;lt;note&amp;gt; in XLIFF&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify regular expression. The values of the matching keys will be transferred to &amp;amp;lt;note&amp;gt; elements in XLIFF.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are added as TextUnit Metadata&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify regular expression. The values of the matching keys will be written out as &amp;amp;lt;context-group&amp;gt; elements in XLIFF.&lt;br /&gt;
&lt;br /&gt;
===New Extraction Rules &amp;gt;= version M39===&lt;br /&gt;
&amp;lt;b&amp;gt;If specified these will override the corresponding rules above.&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are extracted (overrides extraction exceptions)&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys that are notes, values of which to appear as &amp;lt;note&amp;gt; in XLIFF&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys which are ID's (resname in XLIFF), overrides &amp;quot;use key as resname&amp;quot;&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Hint:&amp;lt;/b&amp;gt; If you have the following json, that contains the actual key in the value of a neighboring key/value pair&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
  {&lt;br /&gt;
	&amp;quot;key&amp;quot;: &amp;quot;datePicker_marchMonth&amp;quot;,&lt;br /&gt;
	&amp;quot;text&amp;quot;: &amp;quot;March&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  {&lt;br /&gt;
	&amp;quot;key&amp;quot;: &amp;quot;datePicker_aprilMonth&amp;quot;,&lt;br /&gt;
	&amp;quot;text&amp;quot;: &amp;quot;April&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and define simply the regex &amp;quot;key&amp;quot; in this configuration option, you would get the following xliff extracted&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;trans-unit id=&amp;quot;tu1&amp;quot; resname=&amp;quot;datePicker_marchMonth&amp;quot; xml:space=&amp;quot;preserve&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;source xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;March&amp;lt;/source&amp;gt;&lt;br /&gt;
  &amp;lt;target xml:lang=&amp;quot;de-DE&amp;quot;&amp;gt;&amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/trans-unit&amp;gt;&lt;br /&gt;
&amp;lt;trans-unit id=&amp;quot;tu2&amp;quot; resname=&amp;quot;datePicker_aprilMonth&amp;quot; xml:space=&amp;quot;preserve&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;source xml:lang=&amp;quot;en-US&amp;quot;&amp;gt;April&amp;lt;/source&amp;gt;&lt;br /&gt;
  &amp;lt;target xml:lang=&amp;quot;de-DE&amp;quot;&amp;gt;&amp;lt;/target&amp;gt;&lt;br /&gt;
&amp;lt;/trans-unit&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Regex matching keys who's values are added as TextUnit Metadata&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Example FPRM Settings:====&lt;br /&gt;
Regex rules apply to key names.&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
&amp;lt;b&amp;gt;extraction rules (use instead of rule exceptions):&amp;lt;/b&amp;gt;&lt;br /&gt;
extractionRules=/widgets/body.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;note rules (add values to TextUnits as notes):&amp;lt;/b&amp;gt;&lt;br /&gt;
noteRules=/widgets/name.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;id rules (overrides useKeyAsName):&amp;lt;/b&amp;gt;&lt;br /&gt;
idRules=/widgets/id.*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;generic metadata (matched key:values are added as metadata to TextUnit):&amp;lt;/b&amp;gt;&lt;br /&gt;
genericMetaRules=/widgets/image.*'''&lt;br /&gt;
&lt;br /&gt;
===Content Processing Tab===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Process text content with this sub-filter&amp;lt;/cite&amp;gt; &amp;amp;mdash; Specify an Okapi filter ID (e.g. &amp;lt;code&amp;gt;okf_html&amp;lt;/code&amp;gt;) to process the content of all translatable text with that filter. Leave this field blank for default behavior.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cite&amp;gt;Find inline codes by patterns defined below&amp;lt;/cite&amp;gt; &amp;amp;mdash; Set this option to use the specified regular expressions on the text of the extracted items. Any match will be converted to an inline code.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' This option cannot be used together with the sub-filtering option.&lt;br /&gt;
&lt;br /&gt;
By default the expression is:&lt;br /&gt;
&lt;br /&gt;
 ((%(([-0+#]?)[-0+#]?)((\d\$)?)(([\d\*]*)(\.[\d\*]*)?)[dioxXucsfeEgGpn])&lt;br /&gt;
 |((\\r\\n)|\\a|\\b|\\f|\\n|\\r|\\t|\\v)&lt;br /&gt;
 |(\{\d.*?\}))&lt;br /&gt;
&lt;br /&gt;
{{CodeFinder Help}}&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
&lt;br /&gt;
Comments within a JSON string are parsed as part of the string content, not as comments. A configured subfilter will then process these as true comments (they will become part of the skeleton or whatever the filter is configured to do).&lt;br /&gt;
[[Category:Filters]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1002</id>
		<title>XML Filter</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1002"/>
		<updated>2024-02-22T21:34:06Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: /* Filter Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Filters Header}}&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
This filter allows you to process XML documents. It uses a DOM-based parser, which allows it to implement [[ITS]]. If you need to process very large XML documents and have no need for ITS, you may want to look at using the [[XML Stream Filter]].&lt;br /&gt;
&lt;br /&gt;
The following is an example of a simple XML document. The translatable text is highlighted. Because each format based on XML is different, you need information on what are the translatable parts, what are the inline elements, etc. The XML Filter [[#ITS Support|implements the ITS W3C Recommendation]] to address this issue.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;amp;lt;myDoc&amp;gt;&lt;br /&gt;
  &amp;amp;lt;prolog&amp;gt;&lt;br /&gt;
   &amp;amp;lt;author&amp;gt;Zebulon Fairfield&amp;lt;/author&amp;gt;&lt;br /&gt;
   &amp;amp;lt;version&amp;gt;version 12, revision 2 - 2006-08-14&amp;lt;/version&amp;gt;&lt;br /&gt;
   &amp;amp;lt;keywords&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;horse&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;appaloosa&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;/keywords&amp;gt;&lt;br /&gt;
   &amp;amp;lt;storageKey&amp;gt;articles-6D272BA9-3B89CAD8&amp;lt;/storageKey&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/prolog&amp;gt;&lt;br /&gt;
  &amp;amp;lt;body&amp;gt;&lt;br /&gt;
   &amp;amp;lt;title&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Appaloosa&amp;lt;/span&amp;gt;&amp;amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;The Appaloosas are rugged horses originally breed by &lt;br /&gt;
 the &amp;lt;kw&amp;gt;Nez-Perce&amp;lt;/kw&amp;gt; tribe in the US Northwest.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;They are often characterized by their spotted coats.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;amp;lt;/myDoc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This filter is implemented in the class &amp;lt;code&amp;gt;net.sf.okapi.filters.xml.XMLFilter&amp;lt;/code&amp;gt; of the library.&lt;br /&gt;
&lt;br /&gt;
==Processing Details==&lt;br /&gt;
&lt;br /&gt;
===Input Encoding===&lt;br /&gt;
&lt;br /&gt;
The filter decides which encoding to use for the input document using the following logic:&lt;br /&gt;
&lt;br /&gt;
* If the document has an encoding declaration it is used. &lt;br /&gt;
* Otherwise, UTF-8 is used as the default encoding (regardless the actual default encoding that was specified when opening the document). &lt;br /&gt;
&lt;br /&gt;
===Output Encoding===&lt;br /&gt;
&lt;br /&gt;
If the output encoding is UTF-8:&lt;br /&gt;
&lt;br /&gt;
* If the input encoding was also UTF-8, a Byte-Order-Mark is used for the output document only if one was detected in the input document. &lt;br /&gt;
* If the input encoding was not UTF-8, no Byte-Order-Mark is used in the output document. &lt;br /&gt;
&lt;br /&gt;
If the original document had an XML encoding declaration it is updated, if it did not, one is automatically added.&lt;br /&gt;
&lt;br /&gt;
===Line-Breaks===&lt;br /&gt;
&lt;br /&gt;
The type of line-breaks of the output is the same as the one of the original input.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
This filter stores its parameters in an XML file and does not provide an editor to modify it. You can edit the file in a simple text editor, or with an XML editor. For an example, see the article &amp;quot;[[How to Create a Custom Configuration for the XML Filter]]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===ITS Support===&lt;br /&gt;
&lt;br /&gt;
By default the filter process the XML documents based on the '''ITS defaults'''. That is:&lt;br /&gt;
&lt;br /&gt;
* the content of all elements is translatable,&lt;br /&gt;
* and none of the values of the attribute translatable.&lt;br /&gt;
&lt;br /&gt;
Different behavior can occur if the input document contains ITS markup, or if a filter parameters file is specified. The parameters file used by the the XML Filter is [[ITS|an ITS document]].&lt;br /&gt;
&lt;br /&gt;
The '''Internationalization Tag set (ITS)''' is a W3C recommendation that defines a set of elements and attributes you can use to specify different internationalization- and localization-related aspects of your XML document, for instance: ITS defines what attribute values are translatable, what element content should be protected, what element should be treated as a nested sub-flow of text, and much more.&lt;br /&gt;
&lt;br /&gt;
The filter supports ITS 1.0 and ITS 2.0 (2.0 is backward compatible with 1.0)&lt;br /&gt;
&lt;br /&gt;
* The ITS 1.0 specification is available at http://www.w3.org/TR/its/.&lt;br /&gt;
* The ITS 2.0 specification is available at http://www.w3.org/TR/its20/.&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[[ITS]]&amp;quot; page for more details on the format.&lt;br /&gt;
&lt;br /&gt;
The filter supports global and local rules and most data categories. See the '''[[ITS Components]]''' page for a detailed list of how the data categories are supported and other information on the implementation.&lt;br /&gt;
&lt;br /&gt;
===ITS Extensions===&lt;br /&gt;
&lt;br /&gt;
The filter supports extensions to the ITS specification. These extension use the namespace URI http://www.w3.org/2008/12/its-extensions.&lt;br /&gt;
&lt;br /&gt;
* [[#idValue and xml:id|idValue and xml:id]]&lt;br /&gt;
* [[#whiteSpaces|whiteSpaces]]&lt;br /&gt;
&lt;br /&gt;
====idValue and xml:id====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#idvalue Id Value] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
When the attribute &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; is found on a translatable element, it is used as the name of the text unit generated for that element.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;p xml:id=&amp;quot;id1&amp;quot;&amp;gt;Text&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; used in the ITS &amp;lt;code&amp;gt;translateRule&amp;lt;/code&amp;gt; element allows you to define an XPath expression that correspeonds to the identifier value for the given selection. The value of &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; must be an expression that can return a string. A node location is a valid expression: it will return the value of the first node at the given location.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; has precedence over &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; declaration. For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;xid1&amp;lt;/code&amp;gt;&amp;quot;, not &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p xml:id=&amp;quot;xid1&amp;quot; name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can build complex ID based on different attributes, element or event hard-coded text. Any of the String functions offered by XPath can be used.&lt;br /&gt;
&lt;br /&gt;
For example, in the file below, the two elements &amp;lt;code&amp;gt;&amp;amp;tl;text&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt; are translatable, but they have only one corresponding ID, the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; attribute in their parent element. To make sure you have a unique identifier for both the content of &amp;lt;code&amp;gt;&amp;amp;lt;text&amp;gt;&amp;lt;/code&amp;gt; and the content of &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt;, you can use the rules set in the example. The XPath expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_t')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_t&amp;lt;/code&amp;gt;&amp;quot; and the expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_d')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_d&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//text&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_t')&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//desc&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_d')&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;msg name=&amp;quot;id1&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;text&amp;gt;Value of text&amp;lt;/text&amp;gt;&lt;br /&gt;
  &amp;lt;desc&amp;gt;Value of desc&amp;lt;/desc&amp;gt;&lt;br /&gt;
 &amp;lt;/msg&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====whiteSpaces====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#preservespace Preserve Space] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
The extension attribute whiteSpaces allows you to apply globally the equivalent of a local &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
For example, if you have a format where all element &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; must have their spaces, tabs and line breaks preserved, you can specify the attribute &amp;lt;code&amp;gt;whiteSpaces=&amp;quot;preserve&amp;quot;&amp;lt;/code&amp;gt; in a &amp;lt;code&amp;gt;&amp;amp;lt;its:translateRule&amp;gt;&amp;lt;/code&amp;gt; element for the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; elements. In the example below, the spaces in the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; element will be preserved on extraction.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;lt;pre&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute has precedence over &amp;lt;code&amp;gt;whiteSpaces&amp;lt;/code&amp;gt;. For example, in the following example, the white spaces in the content of &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; may '''not''' be preserved because the attribute &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; has the value &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;&amp;amp;lt;pre xml:space=&amp;quot;default&amp;quot;&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Filter Options===&lt;br /&gt;
&lt;br /&gt;
The filter supports also options in addition to ITS and ITS extension. These options use the namespace URI &amp;lt;code&amp;gt;okapi-framework:xmlfilter-options&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|The filter options must be placed in the parameters file (.fprm) used with the filter, not in embedded or linked ITS rules. Options placed in embedded or linked ITS rules have no effect.}}&lt;br /&gt;
&lt;br /&gt;
When you use several options, they must be set in a single &amp;lt;code&amp;gt;&amp;amp;lt;okp:options&amp;gt;&amp;lt;/code&amp;gt; element, as shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;&lt;br /&gt;
              escapeQuotes=&amp;quot;no&amp;quot;&lt;br /&gt;
              escapeGT=&amp;quot;yes&amp;quot;&lt;br /&gt;
 /&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need to switch on an option for certain parts of your XML filter and switch it off for others: &lt;br /&gt;
&lt;br /&gt;
* The ITS definitions are evaluated from top to bottom. &lt;br /&gt;
* For ITS definitions placed above the first occurrence of the option, the default setting of the option will be active. &lt;br /&gt;
* To switch it off again further down, set the option again with the attribute value &amp;quot;no&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following options are available:&lt;br /&gt;
&lt;br /&gt;
* [[#lineBreakAsCode|lineBreakAsCode]]&lt;br /&gt;
* [[#codeFinder|codeFinder]]&lt;br /&gt;
* [[#omitXMLDeclaration|omitXMLDeclaration]]&lt;br /&gt;
* [[#escapeQuotes|escapeQuotes]]&lt;br /&gt;
* [[#escapeGT|escapeGT]]&lt;br /&gt;
* [[#escapeNbsp|escapeNbsp]]&lt;br /&gt;
* [[#extractIfOnlyCodes|extractIfOnlyCodes]]&lt;br /&gt;
* [[#inlineCdata|inlineCdata]]&lt;br /&gt;
* [[#extractUntranslatable|extractUntranslatable]]&lt;br /&gt;
&lt;br /&gt;
====lineBreakAsCode====&lt;br /&gt;
&lt;br /&gt;
In some cases the content of element includes line-breaks that need to be included as part of the content but without using an actual line-break in the extracted text. For example in some XML documents generated by Excel, the formatting of the cells is marked up with &amp;lt;code&amp;gt;&amp;amp;amp;#10;&amp;lt;/code&amp;gt; entity references. They need to be passed as inline codes.&lt;br /&gt;
&lt;br /&gt;
By default this option is set to false.&lt;br /&gt;
&lt;br /&gt;
To specify this the filter use the extension &amp;lt;code&amp;gt;lineBreakAsCode&amp;lt;/code&amp;gt; extension attribute. This affect all the extracted content.&lt;br /&gt;
&lt;br /&gt;
For example: The following code is an ITS document with the option to treat line-breaks as code. It can be used along with the example of XML document listed below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;data&amp;gt;line 1&amp;amp;amp;#10;line 2.&amp;lt;/data&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====codeFinder====&lt;br /&gt;
&lt;br /&gt;
You can define a set of regular expressions to capture span of extracted text that should be treated as inline codes. For example, some element content may have variables, or HTML tags that need to be protected from modification and treated as codes. Use the codeFinder element for this.&lt;br /&gt;
&lt;br /&gt;
In the following parameters file, the &amp;lt;code&amp;gt;codeFinder&amp;lt;/code&amp;gt; element defines two rules:&lt;br /&gt;
&lt;br /&gt;
* The first one (rule0) is &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; and matches any XML-type tags (e.g. &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;br/&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;)&lt;br /&gt;
* The second one (rule1) is &amp;quot;&amp;lt;code&amp;gt;(#\w+?\#)|(%\d+?%)&amp;lt;/code&amp;gt;&amp;quot; and matches any word enclosed in &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;#VAR#&amp;lt;/code&amp;gt;&amp;quot;) or number enclosed in &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;%1%&amp;lt;/code&amp;gt;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:codeFinder useCodeFinder=&amp;quot;yes&amp;quot;&amp;gt;#v1&lt;br /&gt;
count.i=2&lt;br /&gt;
rule0=&amp;amp;amp;lt;(/?)\w+[^&amp;amp;amp;gt;]*?&amp;amp;amp;gt;&lt;br /&gt;
rule1=(#\w+?\#)|(%\d+?%)&lt;br /&gt;
 &amp;lt;/okp:codeFinder&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some important details:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;lt;code&amp;gt;useCodeFinder&amp;lt;/code&amp;gt; to &amp;quot;yes&amp;quot; to have the rules used, if the attribute is missing its value is assumed to be &amp;quot;no&amp;quot;.&lt;br /&gt;
* Make sure the first line of the &amp;lt;code&amp;gt;&amp;amp;lt;codeFinder&amp;gt;&amp;lt;/code&amp;gt; element content is &amp;lt;code&amp;gt;#v1&amp;lt;/code&amp;gt;. &lt;br /&gt;
* Each entry in the content must be on a separate line. &lt;br /&gt;
* &amp;lt;code&amp;gt;count.i=N&amp;lt;/code&amp;gt; must be before any rules and &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; must be the number of rules. &lt;br /&gt;
* &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt; must be incremented starting at 0. &lt;br /&gt;
* The pattern for a rule must be escaped for XML, for example: &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; must be entered &amp;quot;&amp;lt;code&amp;gt;&amp;amp;amp;lt;(/?)\w[^&amp;amp;amp;lt;]*?&amp;amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot; in the parameters file. &lt;br /&gt;
* Do not put spaces before &amp;lt;code&amp;gt;count.i&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt;, and not after your expressions.&lt;br /&gt;
&lt;br /&gt;
To facilitate the creation of code finder rules [[Rainbow - Code Finder Editor|Rainbow provides the Code Finder Editor]].&lt;br /&gt;
&lt;br /&gt;
====omitXMLDeclaration====&lt;br /&gt;
&lt;br /&gt;
By default an XML declaration is always set at the top of the output document (regardless wether the original document has one or not). It is an important part of the XML document and it is especially needed when the encoding of the output document is not UTF-8, UTF-16 or UTF-32, as its name must be specified in the XML declaration. However, there are a few special cases when the declaration is better left off. To handle those rare cases, you can use &amp;lt;code&amp;gt;omitXMLDeclation&amp;lt;/code&amp;gt; to indicate the filter to not output the XML declaration.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options omitXMLDeclaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that XML documents without an XML declaration may be read incorrectly if the encoding of the document is not UTF-8, UTF-16 or UTF-32.&lt;br /&gt;
&lt;br /&gt;
====escapeQuotes====&lt;br /&gt;
&lt;br /&gt;
By default, when processing the document, the filter uses double-quotes to enclose all attributes (translatable or not) and use the following rules for escaping/not-escaping the literal quotes:&lt;br /&gt;
&lt;br /&gt;
* Inside the attribute values:&lt;br /&gt;
** Single-quotes (=apostrophes) are never escaped&lt;br /&gt;
** Double-quotes are always escaped&lt;br /&gt;
* In element content:&lt;br /&gt;
** Single-quotes (=apostrophes) are not escaped&lt;br /&gt;
** Double-quotes are escaped by default&lt;br /&gt;
&lt;br /&gt;
You cannot change the escaping rules for attributes.&lt;br /&gt;
&lt;br /&gt;
For element content: If the document is processed without triggering any rule that allow the translation of an attribute, then (and only then) the filter takes into account the &amp;lt;code&amp;gt;escapeQuotes&amp;lt;/code&amp;gt; option to escape or not double-quotes in the translatable content.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file allows to not escape double-quotes in element content (for the documents where there is no rule for translatable attributes are triggered):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeQuotes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeGT====&lt;br /&gt;
&lt;br /&gt;
By default the character '&amp;lt;code&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;' is escaped. You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeGT&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape greater-than characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeGT=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeNbsp====&lt;br /&gt;
&lt;br /&gt;
By default the non-breaking space character is escaped (in the form &amp;lt;code&amp;gt;&amp;amp;amp;#x00a0;&amp;lt;/code&amp;gt;). You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeNbsp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape the non-breaking space characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeNbsp=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractIfOnlyCodes====&lt;br /&gt;
&lt;br /&gt;
By default all extractable entries are extracted even when they contain only white-spaces and/or inline codes. You can indicate to the filter to not extract such entries using the &amp;lt;code&amp;gt;extractIfOnlyCodes&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not extract entries with only whte-spaces and/or inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractIfOnlyCodes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====inlineCdata====&lt;br /&gt;
&lt;br /&gt;
By default, CDATA sections will be exposed as regular content, and the CDATA markers themselves will be discarded.  When the &amp;lt;code&amp;gt;inlineCdata&amp;lt;/code&amp;gt; option is set,&lt;br /&gt;
the CDATA markers will be exposed as inline codes.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file will expose CDATA markers as inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options inlineCdata=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractUntranslatable====&lt;br /&gt;
&lt;br /&gt;
All untranslatable entries (&amp;lt;code&amp;gt;its:translate=&amp;quot;no&amp;quot;&amp;lt;/code&amp;gt;) are not extracted by default. And in order to allow the extraction of such entries for context reasons, the following option has to be used: &amp;lt;code&amp;gt;extractUntranslatable&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Below is an example of this option declaration: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractUntranslatable=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
&lt;br /&gt;
* Currently, in some cases, the ITS rule &amp;lt;code&amp;gt;withinTextRule&amp;lt;/code&amp;gt; with the value &amp;lt;code&amp;gt;nested&amp;lt;/code&amp;gt; may act like it has a value &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
* In output, the values of the &amp;lt;code&amp;gt;xml:lang&amp;lt;/code&amp;gt; attributes are not updated to reflect the target language.&lt;br /&gt;
* When doing the extraction, the whole input file is loaded into memory. You may run into memory limitation if the document is very large.&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]] [[Category:ITS]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
	<entry>
		<id>http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1001</id>
		<title>XML Filter</title>
		<link rel="alternate" type="text/html" href="http://okapiframework.org/wiki/index.php?title=XML_Filter&amp;diff=1001"/>
		<updated>2024-02-22T21:33:36Z</updated>

		<summary type="html">&lt;p&gt;Translate5Support: /* Filter Options */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Filters Header}}&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
This filter allows you to process XML documents. It uses a DOM-based parser, which allows it to implement [[ITS]]. If you need to process very large XML documents and have no need for ITS, you may want to look at using the [[XML Stream Filter]].&lt;br /&gt;
&lt;br /&gt;
The following is an example of a simple XML document. The translatable text is highlighted. Because each format based on XML is different, you need information on what are the translatable parts, what are the inline elements, etc. The XML Filter [[#ITS Support|implements the ITS W3C Recommendation]] to address this issue.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
 &amp;amp;lt;myDoc&amp;gt;&lt;br /&gt;
  &amp;amp;lt;prolog&amp;gt;&lt;br /&gt;
   &amp;amp;lt;author&amp;gt;Zebulon Fairfield&amp;lt;/author&amp;gt;&lt;br /&gt;
   &amp;amp;lt;version&amp;gt;version 12, revision 2 - 2006-08-14&amp;lt;/version&amp;gt;&lt;br /&gt;
   &amp;amp;lt;keywords&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;horse&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;kw&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;appaloosa&amp;lt;/span&amp;gt;&amp;lt;/kw&amp;gt;&amp;lt;/keywords&amp;gt;&lt;br /&gt;
   &amp;amp;lt;storageKey&amp;gt;articles-6D272BA9-3B89CAD8&amp;lt;/storageKey&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/prolog&amp;gt;&lt;br /&gt;
  &amp;amp;lt;body&amp;gt;&lt;br /&gt;
   &amp;amp;lt;title&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;Appaloosa&amp;lt;/span&amp;gt;&amp;amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;The Appaloosas are rugged horses originally breed by &lt;br /&gt;
 the &amp;lt;kw&amp;gt;Nez-Perce&amp;lt;/kw&amp;gt; tribe in the US Northwest.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
   &amp;amp;lt;p&amp;gt;&amp;lt;span class=&amp;quot;hi&amp;quot;&amp;gt;They are often characterized by their spotted coats.&amp;lt;/span&amp;gt;&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;amp;lt;/myDoc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This filter is implemented in the class &amp;lt;code&amp;gt;net.sf.okapi.filters.xml.XMLFilter&amp;lt;/code&amp;gt; of the library.&lt;br /&gt;
&lt;br /&gt;
==Processing Details==&lt;br /&gt;
&lt;br /&gt;
===Input Encoding===&lt;br /&gt;
&lt;br /&gt;
The filter decides which encoding to use for the input document using the following logic:&lt;br /&gt;
&lt;br /&gt;
* If the document has an encoding declaration it is used. &lt;br /&gt;
* Otherwise, UTF-8 is used as the default encoding (regardless the actual default encoding that was specified when opening the document). &lt;br /&gt;
&lt;br /&gt;
===Output Encoding===&lt;br /&gt;
&lt;br /&gt;
If the output encoding is UTF-8:&lt;br /&gt;
&lt;br /&gt;
* If the input encoding was also UTF-8, a Byte-Order-Mark is used for the output document only if one was detected in the input document. &lt;br /&gt;
* If the input encoding was not UTF-8, no Byte-Order-Mark is used in the output document. &lt;br /&gt;
&lt;br /&gt;
If the original document had an XML encoding declaration it is updated, if it did not, one is automatically added.&lt;br /&gt;
&lt;br /&gt;
===Line-Breaks===&lt;br /&gt;
&lt;br /&gt;
The type of line-breaks of the output is the same as the one of the original input.&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&lt;br /&gt;
This filter stores its parameters in an XML file and does not provide an editor to modify it. You can edit the file in a simple text editor, or with an XML editor. For an example, see the article &amp;quot;[[How to Create a Custom Configuration for the XML Filter]]&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===ITS Support===&lt;br /&gt;
&lt;br /&gt;
By default the filter process the XML documents based on the '''ITS defaults'''. That is:&lt;br /&gt;
&lt;br /&gt;
* the content of all elements is translatable,&lt;br /&gt;
* and none of the values of the attribute translatable.&lt;br /&gt;
&lt;br /&gt;
Different behavior can occur if the input document contains ITS markup, or if a filter parameters file is specified. The parameters file used by the the XML Filter is [[ITS|an ITS document]].&lt;br /&gt;
&lt;br /&gt;
The '''Internationalization Tag set (ITS)''' is a W3C recommendation that defines a set of elements and attributes you can use to specify different internationalization- and localization-related aspects of your XML document, for instance: ITS defines what attribute values are translatable, what element content should be protected, what element should be treated as a nested sub-flow of text, and much more.&lt;br /&gt;
&lt;br /&gt;
The filter supports ITS 1.0 and ITS 2.0 (2.0 is backward compatible with 1.0)&lt;br /&gt;
&lt;br /&gt;
* The ITS 1.0 specification is available at http://www.w3.org/TR/its/.&lt;br /&gt;
* The ITS 2.0 specification is available at http://www.w3.org/TR/its20/.&lt;br /&gt;
&lt;br /&gt;
See the &amp;quot;[[ITS]]&amp;quot; page for more details on the format.&lt;br /&gt;
&lt;br /&gt;
The filter supports global and local rules and most data categories. See the '''[[ITS Components]]''' page for a detailed list of how the data categories are supported and other information on the implementation.&lt;br /&gt;
&lt;br /&gt;
===ITS Extensions===&lt;br /&gt;
&lt;br /&gt;
The filter supports extensions to the ITS specification. These extension use the namespace URI http://www.w3.org/2008/12/its-extensions.&lt;br /&gt;
&lt;br /&gt;
* [[#idValue and xml:id|idValue and xml:id]]&lt;br /&gt;
* [[#whiteSpaces|whiteSpaces]]&lt;br /&gt;
&lt;br /&gt;
====idValue and xml:id====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#idvalue Id Value] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
When the attribute &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; is found on a translatable element, it is used as the name of the text unit generated for that element.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;p xml:id=&amp;quot;id1&amp;quot;&amp;gt;Text&amp;amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; used in the ITS &amp;lt;code&amp;gt;translateRule&amp;lt;/code&amp;gt; element allows you to define an XPath expression that correspeonds to the identifier value for the given selection. The value of &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; must be an expression that can return a string. A node location is a valid expression: it will return the value of the first node at the given location.&lt;br /&gt;
&lt;br /&gt;
For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;code&amp;gt;xml:id&amp;lt;/code&amp;gt; has precedence over &amp;lt;code&amp;gt;idValue&amp;lt;/code&amp;gt; declaration. For example, in the example below, the resource name associated with the text unit for the &amp;lt;code&amp;gt;&amp;amp;lt;p&amp;gt;&amp;lt;/code&amp;gt; element is &amp;quot;&amp;lt;code&amp;gt;xid1&amp;lt;/code&amp;gt;&amp;quot;, not &amp;quot;&amp;lt;code&amp;gt;id1&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//p&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;@name&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;p xml:id=&amp;quot;xid1&amp;quot; name=&amp;quot;id1&amp;quot;&amp;gt;text 1&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can build complex ID based on different attributes, element or event hard-coded text. Any of the String functions offered by XPath can be used.&lt;br /&gt;
&lt;br /&gt;
For example, in the file below, the two elements &amp;lt;code&amp;gt;&amp;amp;tl;text&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt; are translatable, but they have only one corresponding ID, the &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; attribute in their parent element. To make sure you have a unique identifier for both the content of &amp;lt;code&amp;gt;&amp;amp;lt;text&amp;gt;&amp;lt;/code&amp;gt; and the content of &amp;lt;code&amp;gt;&amp;amp;lt;desc&amp;gt;&amp;lt;/code&amp;gt;, you can use the rules set in the example. The XPath expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_t')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_t&amp;lt;/code&amp;gt;&amp;quot; and the expression &amp;quot;&amp;lt;code&amp;gt;concat(../@name, '_d')&amp;lt;/code&amp;gt;&amp;quot; will give the ID &amp;quot;&amp;lt;code&amp;gt;id1_d&amp;lt;/code&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;doc&amp;gt;&lt;br /&gt;
 &amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
  xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//text&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_t')&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;its:translateRule selector=&amp;quot;//desc&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:idValue=&amp;quot;concat(../@name, '_d')&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
 &amp;lt;msg name=&amp;quot;id1&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;text&amp;gt;Value of text&amp;lt;/text&amp;gt;&lt;br /&gt;
  &amp;lt;desc&amp;gt;Value of desc&amp;lt;/desc&amp;gt;&lt;br /&gt;
 &amp;lt;/msg&amp;gt;&lt;br /&gt;
&amp;lt;/doc&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====whiteSpaces====&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|This extension was defined for ITS 1.0, ITS 2.0 offers the new [http://www.w3.org/TR/its20/#preservespace Preserve Space] data category that should be used instead of this extension.}}&lt;br /&gt;
&lt;br /&gt;
The extension attribute whiteSpaces allows you to apply globally the equivalent of a local &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
For example, if you have a format where all element &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; must have their spaces, tabs and line breaks preserved, you can specify the attribute &amp;lt;code&amp;gt;whiteSpaces=&amp;quot;preserve&amp;quot;&amp;lt;/code&amp;gt; in a &amp;lt;code&amp;gt;&amp;amp;lt;its:translateRule&amp;gt;&amp;lt;/code&amp;gt; element for the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; elements. In the example below, the spaces in the &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; element will be preserved on extraction.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;lt;pre&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; attribute has precedence over &amp;lt;code&amp;gt;whiteSpaces&amp;lt;/code&amp;gt;. For example, in the following example, the white spaces in the content of &amp;lt;code&amp;gt;&amp;amp;lt;pre&amp;gt;&amp;lt;/code&amp;gt; may '''not''' be preserved because the attribute &amp;lt;code&amp;gt;xml:space&amp;lt;/code&amp;gt; has the value &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot; xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
   xmlns:itsx=&amp;quot;http://www.w3.org/2008/12/its-extensions&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
   &amp;lt;its:translateRule selector=&amp;quot;//pre&amp;quot; translate=&amp;quot;yes&amp;quot; itsx:whiteSpaces=&amp;quot;preserve&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;/its:rules&amp;gt;&lt;br /&gt;
  &amp;amp;&amp;amp;lt;pre xml:space=&amp;quot;default&amp;quot;&amp;gt;Some txt with    many spaces.  &amp;amp;lt;/pre&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Filter Options===&lt;br /&gt;
&lt;br /&gt;
The filter supports also options in addition to ITS and ITS extension. These options use the namespace URI &amp;lt;code&amp;gt;okapi-framework:xmlfilter-options&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{NoteBox|The filter options must be placed in the parameters file (.fprm) used with the filter, not in embedded or linked ITS rules. Options placed in embedded or linked ITS rules have no effect.}}&lt;br /&gt;
&lt;br /&gt;
When you use several options, they must be set in a single &amp;lt;code&amp;gt;&amp;amp;lt;okp:options&amp;gt;&amp;lt;/code&amp;gt; element, as shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;&lt;br /&gt;
              escapeQuotes=&amp;quot;no&amp;quot;&lt;br /&gt;
              escapeGT=&amp;quot;yes&amp;quot;&lt;br /&gt;
 /&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need to switch on an option for certain parts of your XML filter and switch it off for others: &lt;br /&gt;
&lt;br /&gt;
* The ITS definitions are evaluated from top to bottom. &lt;br /&gt;
* For ITS definitions placed above the first occurrence of the option, the default setting of the option will be active. &lt;br /&gt;
* To switch it off again further down, set the option again with the attribute value &amp;quot;no&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The following options are available:&lt;br /&gt;
&lt;br /&gt;
* [[#lineBreakAsCode|lineBreakAsCode]]&lt;br /&gt;
* [[#codeFinder|codeFinder]]&lt;br /&gt;
* [[#omitXMLDeclaration|omitXMLDeclaration]]&lt;br /&gt;
* [[#escapeQuotes|escapeQuotes]]&lt;br /&gt;
* [[#escapeGT|escapeGT]]&lt;br /&gt;
* [[#escapeNbsp|escapeNbsp]]&lt;br /&gt;
* [[#extractIfOnlyCodes|extractIfOnlyCodes]]&lt;br /&gt;
* [[#inlineCdata|inlineCdata]]&lt;br /&gt;
* [[#extractUntranslatable|extractUntranslatable]]&lt;br /&gt;
&lt;br /&gt;
====lineBreakAsCode====&lt;br /&gt;
&lt;br /&gt;
In some cases the content of element includes line-breaks that need to be included as part of the content but without using an actual line-break in the extracted text. For example in some XML documents generated by Excel, the formatting of the cells is marked up with &amp;lt;code&amp;gt;&amp;amp;amp;#10;&amp;lt;/code&amp;gt; entity references. They need to be passed as inline codes.&lt;br /&gt;
&lt;br /&gt;
By default this option is set to false.&lt;br /&gt;
&lt;br /&gt;
To specify this the filter use the extension &amp;lt;code&amp;gt;lineBreakAsCode&amp;lt;/code&amp;gt; extension attribute. This affect all the extracted content.&lt;br /&gt;
&lt;br /&gt;
For example: The following code is an ITS document with the option to treat line-breaks as code. It can be used along with the example of XML document listed below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options lineBreakAsCode=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;doc&amp;gt;&lt;br /&gt;
  &amp;lt;data&amp;gt;line 1&amp;amp;amp;#10;line 2.&amp;lt;/data&amp;gt;&lt;br /&gt;
 &amp;lt;/doc&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====codeFinder====&lt;br /&gt;
&lt;br /&gt;
You can define a set of regular expressions to capture span of extracted text that should be treated as inline codes. For example, some element content may have variables, or HTML tags that need to be protected from modification and treated as codes. Use the codeFinder element for this.&lt;br /&gt;
&lt;br /&gt;
In the following parameters file, the &amp;lt;code&amp;gt;codeFinder&amp;lt;/code&amp;gt; element defines two rules:&lt;br /&gt;
&lt;br /&gt;
* The first one (rule0) is &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; and matches any XML-type tags (e.g. &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;br/&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;)&lt;br /&gt;
* The second one (rule1) is &amp;quot;&amp;lt;code&amp;gt;(#\w+?\#)|(%\d+?%)&amp;lt;/code&amp;gt;&amp;quot; and matches any word enclosed in &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;#VAR#&amp;lt;/code&amp;gt;&amp;quot;) or number enclosed in &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; (e.g. &amp;quot;&amp;lt;code&amp;gt;%1%&amp;lt;/code&amp;gt;&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:codeFinder useCodeFinder=&amp;quot;yes&amp;quot;&amp;gt;#v1&lt;br /&gt;
count.i=2&lt;br /&gt;
rule0=&amp;amp;amp;lt;(/?)\w+[^&amp;amp;amp;gt;]*?&amp;amp;amp;gt;&lt;br /&gt;
rule1=(#\w+?\#)|(%\d+?%)&lt;br /&gt;
 &amp;lt;/okp:codeFinder&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some important details:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;lt;code&amp;gt;useCodeFinder&amp;lt;/code&amp;gt; to &amp;quot;yes&amp;quot; to have the rules used, if the attribute is missing its value is assumed to be &amp;quot;no&amp;quot;.&lt;br /&gt;
* Make sure the first line of the &amp;lt;code&amp;gt;&amp;amp;lt;codeFinder&amp;gt;&amp;lt;/code&amp;gt; element content is &amp;lt;code&amp;gt;#v1&amp;lt;/code&amp;gt;. &lt;br /&gt;
* Each entry in the content must be on a separate line. &lt;br /&gt;
* &amp;lt;code&amp;gt;count.i=N&amp;lt;/code&amp;gt; must be before any rules and &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; must be the number of rules. &lt;br /&gt;
* &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt; must be incremented starting at 0. &lt;br /&gt;
* The pattern for a rule must be escaped for XML, for example: &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;(/?)\w[^&amp;gt;]*?&amp;gt;&amp;lt;/code&amp;gt;&amp;quot; must be entered &amp;quot;&amp;lt;code&amp;gt;&amp;amp;amp;lt;(/?)\w[^&amp;amp;amp;lt;]*?&amp;amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot; in the parameters file. &lt;br /&gt;
* Do not put spaces before &amp;lt;code&amp;gt;count.i&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;ruleN&amp;lt;/code&amp;gt;, and not after your expressions.&lt;br /&gt;
&lt;br /&gt;
To facilitate the creation of code finder rules [[Rainbow - Code Finder Editor|Rainbow provides the Code Finder Editor]].&lt;br /&gt;
&lt;br /&gt;
====omitXMLDeclaration====&lt;br /&gt;
&lt;br /&gt;
By default an XML declaration is always set at the top of the output document (regardless wether the original document has one or not). It is an important part of the XML document and it is especially needed when the encoding of the output document is not UTF-8, UTF-16 or UTF-32, as its name must be specified in the XML declaration. However, there are a few special cases when the declaration is better left off. To handle those rare cases, you can use &amp;lt;code&amp;gt;omitXMLDeclation&amp;lt;/code&amp;gt; to indicate the filter to not output the XML declaration.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options omitXMLDeclaration=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that XML documents without an XML declaration may be read incorrectly if the encoding of the document is not UTF-8, UTF-16 or UTF-32.&lt;br /&gt;
&lt;br /&gt;
====escapeQuotes====&lt;br /&gt;
&lt;br /&gt;
By default, when processing the document, the filter uses double-quotes to enclose all attributes (translatable or not) and use the following rules for escaping/not-escaping the literal quotes:&lt;br /&gt;
&lt;br /&gt;
* Inside the attribute values:&lt;br /&gt;
** Single-quotes (=apostrophes) are never escaped&lt;br /&gt;
** Double-quotes are always escaped&lt;br /&gt;
* In element content:&lt;br /&gt;
** Single-quotes (=apostrophes) are not escaped&lt;br /&gt;
** Double-quotes are escaped by default&lt;br /&gt;
&lt;br /&gt;
You cannot change the escaping rules for attributes.&lt;br /&gt;
&lt;br /&gt;
For element content: If the document is processed without triggering any rule that allow the translation of an attribute, then (and only then) the filter takes into account the &amp;lt;code&amp;gt;escapeQuotes&amp;lt;/code&amp;gt; option to escape or not double-quotes in the translatable content.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file allows to not escape double-quotes in element content (for the documents where there is no rule for translatable attributes are triggered):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeQuotes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeGT====&lt;br /&gt;
&lt;br /&gt;
By default the character '&amp;lt;code&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;' is escaped. You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeGT&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape greater-than characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeGT=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====escapeNbsp====&lt;br /&gt;
&lt;br /&gt;
By default the non-breaking space character is escaped (in the form &amp;lt;code&amp;gt;&amp;amp;amp;#x00a0;&amp;lt;/code&amp;gt;). You can indicate to the filter to not escape it using the &amp;lt;code&amp;gt;escapeNbsp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not escape the non-breaking space characters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options escapeNbsp=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractIfOnlyCodes====&lt;br /&gt;
&lt;br /&gt;
By default all extractable entries are extracted even when they contain only white-spaces and/or inline codes. You can indicate to the filter to not extract such entries using the &amp;lt;code&amp;gt;extractIfOnlyCodes&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file indicates to not extract entries with only whte-spaces and/or inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractIfOnlyCodes=&amp;quot;no&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====inlineCdata====&lt;br /&gt;
&lt;br /&gt;
By default, CDATA sections will be exposed as regular content, and the CDATA markers themselves will be discarded.  When the &amp;lt;code&amp;gt;inlineCdata&amp;lt;/code&amp;gt; option is set,&lt;br /&gt;
the CDATA markers will be exposed as inline codes.&lt;br /&gt;
&lt;br /&gt;
For example, the following parameters file will expose CDATA markers as inline codes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options inlineCdata=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====extractUntranslatable====&lt;br /&gt;
&lt;br /&gt;
All untranslatable entries (&amp;lt;code&amp;gt;its:translate=&amp;quot;no&amp;quot;&amp;lt;/code&amp;gt;) are not extracted by default. And in order to allow the extraction of such entries for context reasons, the following option has to be used: &amp;lt;code&amp;gt;extractUntranslatable&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Below is an example of this option declaration: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;its:rules version=&amp;quot;1.0&amp;quot;&lt;br /&gt;
 xmlns:its=&amp;quot;http://www.w3.org/2005/11/its&amp;quot;&lt;br /&gt;
 xmlns:okp=&amp;quot;okapi-framework:xmlfilter-options&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;okp:options extractUntranslatable=&amp;quot;yes&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/its:rules&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
&lt;br /&gt;
* Currently, in some cases, the ITS rule &amp;lt;code&amp;gt;withinTextRule&amp;lt;/code&amp;gt; with the value &amp;lt;code&amp;gt;nested&amp;lt;/code&amp;gt; may act like it has a value &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt; instead.&lt;br /&gt;
* In output, the values of the &amp;lt;code&amp;gt;xml:lang&amp;lt;/code&amp;gt; attributes are not updated to reflect the target language.&lt;br /&gt;
* When doing the extraction, the whole input file is loaded into memory. You may run into memory limitation if the document is very large.&lt;br /&gt;
&lt;br /&gt;
[[Category:Filters]] [[Category:ITS]]&lt;/div&gt;</summary>
		<author><name>Translate5Support</name></author>
	</entry>
</feed>