<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "../../Reference_Guide.ent">
%BOOK_ENTITIES;
]>
<section id="sect-Reference_Guide-XML_Resources_Bundles">
	<title>XML Resources Bundles</title>
	<section id="sect-Reference_Guide-XML_Resources_Bundles-Motivation">
		<title>Motivation</title>
		<para>
			Resource bundles are usually stored in property files. However, as property files are plain files, issues with the encoding of the file may arise. The XML resource bundle format has been developed to provide an alternative to property files.
		</para>
		<itemizedlist>
			<listitem>
				<para>
					The XML format declares the encoding of the file. This avoids use of the native2ascii program which can interfere with encoding.
				</para>
			</listitem>
			<listitem>
				<para>
					Property files generally use ISO 8859-1 character encoding which does not cover the full unicode charset. As a result, languages such as Arabic would not be natively supported.
				</para>
			</listitem>
			<listitem>
				<para>
					Tooling for XML files is better supported than the tooling for Java property files and thus the XML editor copes well with the file encoding.
				</para>
			</listitem>
		</itemizedlist>
	</section>
	
	<section id="sect-Reference_Guide-XML_Resources_Bundles-XML_format">
		<title>XML format</title>
		<para>
			The XML format is very simple and has been developed based on the <emphasis>DRY</emphasis> (Don&#39;t Repeat Yourself) principle. Usually resource bundle keys are hierarchically defined and we can leverage the hierarchic nature of the XML for that purpose. Here is an example of turning a property file into an XML resource bundle file:
		</para>
		
<programlisting>UIAccountForm.tab.label.AccountInputSet = ...
UIAccountForm.tab.label.UIUserProfileInputSet = ...
UIAccountForm.label.Profile = ...
UIAccountForm.label.HomeInfo= ...
UIAccountForm.label.BusinessInfo= ...
UIAccountForm.label.password= ...
UIAccountForm.label.Confirmpassword= ...
UIAccountForm.label.email= ...
UIAccountForm.action.Reset= ...
</programlisting>
		
<programlisting role="XML">&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;
&#60;bundle&#62;
  &#60;UIAccountForm&#62;
    &#60;tab&#62;
      &#60;label&#62;
        &#60;AccountInputSet&#62;...&#60;/AccountInputSet&#62;
        &#60;UIUserProfileInputSet&#62;...&#60;/UIUserProfileInputSet&#62;
      &#60;/label&#62;
    &#60;/tab&#62;
    &#60;label&#62;
      &#60;Profile&#62;...&#60;/Profile&#62;
      &#60;HomeInfo&#62;...&#60;/HomeInfo&#62;
      &#60;BusinessInfo&#62;...&#60;/BusinessInfo&#62;
      &#60;password&#62;...&#60;/password&#62;
      &#60;Confirmpassword&#62;...&#60;/Confirmpassword&#62;
      &#60;email&#62;...&#60;/email&#62;
    &#60;/label&#62;
    &#60;action&#62;
      &#60;Reset&#62;...&#60;/Reset&#62;
    &#60;/action&#62;
  &#60;/UIAccountForm&#62;
&#60;/bundle&#62;
</programlisting>
	</section>
	
	<section id="sect-Reference_Guide-XML_Resources_Bundles-Portal_support">
		<title>Portal support</title>
		<para>
			In order to be loaded by the portal at runtime (actually the resource bundle service), the name of the file must be the same as a property file and it must use the <emphasis role="bold">.xml</emphasis> suffix.
		</para>
		<para>
			For example; for the Account Portlet to be displayed in Arabic, the resource bundle would be <emphasis role="bold"> AccountPortlet_ar.xml</emphasis> rather than <emphasis role="bold">AccountPortlet_ar.properties</emphasis>.
		</para>
	</section>

</section>


