OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Localizable XML description of form

[ Lists Home | Date Index | Thread Index ]
  • To: xml-dev@lists.xml.org
  • Subject: Localizable XML description of form
  • From: "David B" <daavidb@gmail.com>
  • Date: Mon, 24 Jul 2006 17:53:30 +0100
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=eWlNKeUeK/Eq7zZpjyI4xxoNU/6UIUNHPT+4rYUlyE9Mty4OIGYzLMbtaEzJY88KcWPWMZcTHXmG/KGdz2Dm4d4aXVl6aHfhdFvcGfhtOnsBtjoA3+/qUBqm7BHYVB9Kb01dQS/ifrVJq2wNb7j0qaZ2PGSQbQnEzuAIb7xi5Kw=

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




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS