1

在您看来,将 Schematron 错误消息国际化的最佳方式是什么?我不想复制 schematron 文件,只想复制断言和报告消息。

4

2 回答 2

2

我在 schematron ISO 标准文档中偶然发现了这一点:

Diagnostics in multiple languages may be supported 
by using a different diagnostic element for each language, 
with the appropriate xml:lang language attribute, 
and referencing all the unique identifiers of the diagnostic elements 
in the diagnostics attribute of the assertion. 
Annex G gives a simple example of a multi-lingual schema.

附件 G:

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xml:lang="en" >
    <sch:title>Example of Multi-Lingual Schema</sch:title>
    <sch:pattern>
        <sch:rule context="dog">
            <sch:assert test="bone" diagnostics="d1 d2">
    A dog should have a bone.
            </sch:assert>
        </sch:rule>
    </sch:pattern>
    <sch:diagnostics>
        <sch:diagnostic id="d1" xml:lang="en">
    A dog should have a bone.
        </sch:diagnostic>
        <sch:diagnostic id="d2" xml:lang="de">
    Ein Hund sollte ein Bein haben.
        </sch:diagnostic>
    </sch:diagnostics>
</sch:schema>
于 2012-04-18T08:58:16.537 回答
1

有关详细信息,请参阅XML 国际化的最佳实践。简而言之,您可以使用 xml:lang 属性将任何 XML 文档中的消息国际化。

例子:

 <messages xmlns:xml="http://www.w3.org/XML/1998/namespace">
  <message Id="cannot-find-file-msg">
   <message-text xml:lang="en">Cannot find file.</message-text>
   <message-text xml:lang="fr">Fichier non trouvé.</message-text>
  </message>
 </messages> 

在上面的示例中,您可以访问所需的消息文本,给定本地语言、消息标识符和 XPATH 表达式。

于 2012-04-18T05:57:09.787 回答