W3C home > Mailing lists > Public > public-i18n-its@w3.org > January to March 2006

Re: Directionality Scope/inheritance issue (same as translatability)

From: Felix Sasaki <fsasaki@w3.org>
Date: Sat, 25 Mar 2006 10:00:30 +0900
Message-ID: <4424962E.60406@w3.org>
To: Yves Savourel <ysavourel@translate.com>
Cc: public-i18n-its@w3.org
Hi Yves, all,

Yves Savourel wrote:
> Hi Felix, all,
>> How about differencing two processing steps 
>> instead:
>> - step 1): global rules are applied to instance 
>> documents. result: its markup is integrated into 
>> the document (in memory, or written to a file; 
>> that depends on your implementation). the markup 
>> is "flagged" as being global.
>> - step 2): the output is handled with inheritance 
>> and default rules for local markup.
> Isn't doing this the same as reversing our rules order: Now the first rule wins?
> The problem is that now we have no way to deal with non-ITS like markup.
> If you take this example:
> <myDoc>
>  <head>
>   <its:documentRules xmlns:its="http://www.w3.org/2005/11/its">
>    <its:translateRule its:translate="yes" its:selector="//textInCode"/>
>    <its:translateRule its:translate="no" its:selector="//code"/>
>    <its:translateRule its:translate="yes" its:selector="//*[@trans='true']"/>
>    <its:translateRule its:translate="no" its:selector="//*[@trans='false']"/>
>   </its:documentRules>
>  </head>
>  <body>
>   <p><code>code <textInCode>text in code <code>code in text</code></textInCode></code></p>
>   <p trans="false">some text <code>code <textInCode>text in code</textInCode>code</code>.</p>
>   <p><code trans="true">code <textInCode trans="false">text in code <code trans="true">code in text</code></textInCode></code></p>
>  </body>
> </myDoc>
> The @trans='false|true' is clearly an ITS-equivalent markup. But things like <code> and <textInCode>, while it has implication from
> the translatability viewpoint, is not equivalent to <its:span its:translate>: For example they needs to be overwritten if there is a
> @trans='false|true' in their parent. In the other hand things like <span trans="false"> should not be overwritten. We need to cater
> to both cases.
> If you process this file with the rule we have today (last rule wins), it does not work in several cases and no amount to tinkering
> with the rules order will solve this.
> I'm not sure yet how it will work the way Felix proposes. But if it's the same as a 'first rule wins' like I think, then it probably
> won't work well for the <code> and <textInCode> cases when they are nested.
> But what Felix proposes is closer to a solution it seems. Except I would think we need to control the way the
> inheritance/overwriting is done.

Below I write how the file would look after my execution of step 1):

  <its:documentRules xmlns:its="http://www.w3.org/2005/11/its">
   <its:translateRule its:translate="yes" its:selector="//textInCode"
   <its:translateRule its:translate="no" its:selector="//code"
   <its:translateRule its:translate="yes"
its:selector="//*[@trans='true']" its:ruleId="translate-global-3"/>
   <its:translateRule its:translate="no"
its:selector="//*[@trans='false']" its:ruleId="translate-global-4"/>
  <p><code its:translate-global-2="no">code <textInCode
its:translate-global-1="yes">text in code <code
its:translate-global-2="no">code in text</code></textInCode></code></p>
  <p trans="false" its:translate-global-4="no">some text <code
its:translate-global-2="no">code <textInCode
its:translate-global-1="yes">text in code</textInCode>code</code>.</p>
  <p><code trans="true" its:translate-global-2="no"
its:translate-global-3="yes">code <textInCode trans="false"
its:translate-global-1="yes" its:translate-global-4="no">text in code
<code trans="true" its:translate-global-2="no"
its:translate-global-3="yes">code in text</code></textInCode></code></p>

I'll go through some nodes for step 2) which I described:
/myDoc/body/p[1]/code: only one statement its:translate-global-2="no",
so no  conflict. Result: don't translate this node.

/myDoc/body/p[1]/code/textInCode: only one statement
its:translate-global-1="yes". This overrides its:translate-global-2="no"
from /myDoc/body/code. Result:translate this node.

/myDoc/body/p[1]/code/textInCode/code: only one statement
its:translate-global-2="no". This overrides everything above. Result:
don't translate this node.

and so on.

Now the critical case:
/myDoc/body/p[3]/code: here you have the information
its:translate-global-2="no" , and its:translate-global-3="yes". Since we
have indexed the global rules by their order, *we can still use the
precedence criteria: rule translate-global-3 wins.

One remark: these attributes "xxx-1, xxx-2, ..." are just example
"dummies". In reality, you would probably not change the XML document
directly, but as output of step 1) generate a structure like

/myDoc/body/p[1]/: its:translate-global-2="no"
/myDoc/body/p[1]/code/textInCode: its:translate-global-1="yes"
/myDoc/body/p[1]/code/textInCode/code: its:translate-global-2="no"
/myDoc/body/p[3]/code: its:translate-global-2="no",

as you process step 2), you use this structure in the way described above.
Btw., attribute nodes would be in that list as well. Imagine a rule like

<its:translateRule its:select="//p/@comment" its:translate="yes"/>
as global rule its:translate-global-5. If there are comment attributes
at each p element, this would lead to:

/myDoc/body/p[1]/: its:translate-global-2="no"
/myDoc/body/p[1]/@comment: its:translate-global-5="yes"
/myDoc/body/p[1]/code/textInCode: its:translate-global-1="yes"
/myDoc/body/p[1]/code/textInCode/code: its:translate-global-2="no"
/myDoc/body/p[2]/@comment: its:translate-global-5="yes"
/myDoc/body/p[3]/@comment: its:translate-global-5="yes"
/myDoc/body/p[3]/code: its:translate-global-2="no",



> I've been discussing the problem with Shigemichi Yazawa (he is at ENLASO too and some of you know him), and he noted that maybe we
> could have a priority of some sort associated with the rules. I think this would be better than the 'allowOverwrite' flag I was
> think about, and it reminds me of what Sebastian was doing with his XSLT implementation to get the right precedence order.
> The idea would be that rules of priority 3 would overwrite the ones of priority 2 and 1, the ones of priority 2 would overwrite the
> 1s, etc. And when two rules have the same priority they would not overwrite each other.
> This would allow to build 'groups of rules' and controlling how they interact for inheritance.
> Something like:
> <its:documentRules xmlns:its="http://www.w3.org/2005/11/its">
>  <its:translateRule its:translate="yes" its:selector="//textInCode" its:priority="1"/>
>  <its:translateRule its:translate="no" its:selector="//code" its:priority="1"/>
>  <its:translateRule its:translate="yes" its:selector="//*[@trans='true']" its:priority="2"/>
>  <its:translateRule its:translate="no" its:selector="//*[@trans='false']" its:priority="2"/>
> </its:documentRules>
> Elegance may lead use to think about real group element too...
> I haven't really try this yet or though it throught (like what: is the impact in the order of the rules), but I have the feeling
> this (or something related to this) could be a way to solve the problem.
> Some food for your week-end's thoughts :)
> Cheers,
> -yves

Received on Saturday, 25 March 2006 01:01:06 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:04:09 UTC