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

[Fwd: [xml-dev] Localizable XML description of form]

From: Felix Sasaki <fsasaki@w3.org>
Date: Tue, 25 Jul 2006 13:13:27 +0900
Message-ID: <44C59A67.6010309@w3.org>
To: public-i18n-its@w3.org
Hi,

I found this question on the xml-dev list. Maybe the task is an
interesting use case for a future ITS. Any opinions?

Cheers,

Felix

attached mail follows:


Hello,

I am defining an XML schema for a (quite complex) form. Ideally I
would like to put just the values that can change (i.e. the fields)
into the schema, but it must be translatable to other languages so I
have come up with the solution below. However it is quite messy so I'd
like to know if there is a better approach.

I put both the labels and fields in the schema, and to elements which
only contain label information i add an xs:appinfo that says "i18n"
and to elements which only contain field information i add an
xs:appinfo that says "field". Then I use an xslt transform to seperate
them into two different .xsd files. The instances of the i18n version
then contains the translation of the labels into various languages and
the field version contains the filled in values of a particular form.
E.g.:

<xs:element name="Form">
         <xs:complexType>
                 <xs:sequence>
                         <xs:element name="name_i18n" type="xs:string">

<xs:annotation><xs:appinfo>i18n</xs:appinfo></xs:annotation>
                        </xs:element name="name" type="xs:string">

<xs:annotation><xs:appinfo>value</xs:appinfo></xs:annotation>
                        <xs:element >
                 </xs:sequence>
         </xs:complexType>
</xs:element>


An xslt transform is used to automatically create two schemas:

<xs:element name="Form">
         <xs:complexType>
                 <xs:sequence>
                         <xs:element name="name_i18n" type="xs:string">

<xs:annotation><xs:appinfo>i18n</xs:appinfo></xs:annotation>
                 </xs:sequence>
         </xs:complexType>
</xs:element>

and:
<xs:element name="Form">
         <xs:complexType>
                        </xs:element name="name" type="xs:string">

<xs:annotation><xs:appinfo>value</xs:appinfo></xs:annotation>
                        <xs:element>
         </xs:complexType>
</xs:element>


So an instance of the first may be:
<form><name_i18n>Name</name_i18n></form> or
<form><name_i18n>Nom</name_i18n></form> or
<form><name_i18n>Nombre</name_i18n></form> or
<form><name_i18n>Namn</name_i18n></form>

etc for different languages, while instaces of the second will be:

<form><name>John Doe</name></form>

The xslt that is used to convert this to human readable html would
then run on the instance_i18n_english.xml or instance_i18n_french.xml
etc and be:

<xsl:template match="form">
       <xsl:value-of select="name_i18n">: <xsl:value-of
select="document('instance_field.xml')/form/name">
</xsl:template>

Giving "Name: John Doe" or "Nom: John Doe" etc depending on which of
the instance_i18n_xxx.xml's the xslt is run on.


So this works but is quite messy, especially if you start dividing
your schema into several different files and include/import them. So
once again, does anyone know of a better way to do this?

Best Regards,
David

-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>



Received on Tuesday, 25 July 2006 04:13:49 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:43:07 UTC