Search code examples
xmlxsltlocalizationinternationalizationschematron

What is the best way to internationalize Schematron error messages?


In your opinion, what is the best way to internationalize Schematron error messages? I don't want to duplicate the schematron files, just the assert and report messages.


Solution

  • I stumbled across this in the schematron ISO standard document:

    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.
    

    Annex 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>