RE: Pointing to stuff that's not there

Hi Richard, Yves, all,

I think the issue is similar to problems which can arise with XSLT like
the following:

<xsl:for-each select="//msg/data">
<locNote>
<xsl:value-of select="../notes"/>
</locNote>

Depending on the input data, such usages might give you the same undesired
result as in the case you described below. I agree with Yves that this
should not be an error.

It is maybe rather an issue of how you use XPath, and it can be solved by
a best practice statement for pointing:
"If you do pointing, use in the selector attribute a predicate '[]' that
checks whether the nodes to be pointed to exist".
With the predicate '[]', your example would be like this:

<its:locNoteRule locNoteType="description" selector="//msg/data[../notes]"
                        locNotePointer="../notes"/>

in other words: you put the content of the pointer attribute in square
brackets at the end of the XPath expression, and you can be sure that the
"Pointing to stuff that's not there" case does not occur.

I would propose to describe the issue and the solution either in the ITS
draft (a non-normative subsection) or in the xml i18n BP document. I think
we can do this during the CR phase.

What do you think?

Cheers,

Felix


>
> Hi Richard,
>
>> There is no notes field in the second msg element.
>> Do we say somewhere in the spec what is supposed to happen
>> in this case (since there *is* an element that matches
>> the selector attribute)?
>
> I don't think there is anything in the specification that discusses this
> case.
>
> If there is no node at the place where locNotePointer points to, I would
> assume it is the same as having no note for the selected
> node.
>
> Currently I would return the following test-result file:
>
> <nodeList xmlns:its="http://www.w3.org/2005/11/its">
>   <nodeList datacat="localizationnote">
>     <node path="/myMessages" outputType="default-value">
>       <output />
>     </node>
>     <node path="/myMessages/msg[1]" outputType="default-value">
>       <output />
>     </node>
>     <node path="/myMessages/msg[1]/@id" outputType="default-value">
>       <output />
>     </node>
>     <node path="/myMessages/msg[1]/data[1]" outputType="new-value-global">
>       <output its:locNoteType="description">
>         <its:locNote_Text>Indicates that the resource file {0} could not
> be loaded.</its:locNote_Text>
>       </output>
>     </node>
>     <node path="/myMessages/msg[2]" outputType="default-value">
>       <output />
>     </node>
>     <node path="/myMessages/msg[2]/@id" outputType="default-value">
>       <output />
>     </node>
>     <node path="/myMessages/msg[2]/data[1]" outputType="default-value">
>       <output />
>     </node>
>   </nodeList>
> </nodeList>
>
> I guess the question is also whether this case should result in an error
> or not. I would say not an error, otherwise it may be
> impossible to use the global rules on some files. For example, ResX files
> are very similar to the format you used as an example, and
> the <comment> element is optional.
>
> -yves
>
>
>
> -----Original Message-----
> From: public-i18n-its-request@w3.org
> [mailto:public-i18n-its-request@w3.org] On Behalf Of Richard Ishida
> Sent: Friday, October 27, 2006 12:30 PM
> To: public-i18n-its@w3.org
> Subject: Pointing to stuff that's not there
>
>
> Suppose we have global rules such as
>
> <its:rules its:version="1.0">
> <its:translateRule selector="//msg/notes" translate="no"/>
> <its:locNoteRule locNoteType="description" selector="//msg/data"
> locNotePointer="../notes"/>
> </its:rules>
>
>
> And that the content looks like this:
>
> <msg id="FileNotFound">
> <notes>Indicates that the resource file {0} could not be loaded.</notes>
> <data>Cannot find the file {0}.</data>
> </msg>
> <msg id="DivByZero">
> <data>Invalid parameter.</data>
> </msg>
>
> There is no notes field in the second msg element.  Do we say somewhere in
> the spec what is supposed to happen in this case (since
> there *is* an element that matches the selector attribute)?
>
> RI
>
>
> ============
> Richard Ishida
> Internationalization Lead
> W3C (World Wide Web Consortium)
>
> http://www.w3.org/People/Ishida/
> http://www.w3.org/International/
> http://people.w3.org/rishida/blog/
> http://www.flickr.com/photos/ishida/
>
>
>
>

Received on Saturday, 28 October 2006 15:53:55 UTC