Hi Steve,

>     I have an XForm that is internationalised (ized), and it seems now via use
> of the profiler that alot of the slowness in my form might be attributable to
> that fact. So I am interested to find a better way if possible to achieve the
> same goal as what I currently have.
>     I see that @ref is now supported on <xf:label> elements, so that is
> something to try:
> 
>    
> http://www.agencexml.com/xforms-tests/testsuite/XForms1.1/Edition1/Chapt08/8.2/8.2.1/8.2.1.a.xhtml
>     What I have a present is a second model for my label strings and this has
> a single instance with data of the following structure:
> 
>     <?xml version="1.0" encoding="UTF-8"?>
>     <labels lang="en">
>        <languages>
>           <language lang="en">English</language>
>           <language lang="es">Español</language>
>           <language lang="fr">Français</language>
>        </languages>
>        <label-set id="header-title">
>           <label lang="en">Forms-Wizard Designer (alpha)</label>
>           <label lang="es">Forms-Wizard Designer (alpha)</label>
>           <label lang="fr">Forms-Wizard Designer (alpha)</label>
>        </label-set>
> 
>     The label-set strings are used in the following way in the form:
> 
>     <xf:input ref="@name">
>        <xf:label>
>          <xf:output model="model2"
> ref="label-set[@id='name']/label[@lang=../../@lang]" />
>        </xf:label>
> 
> 
I presume that there is another control such as a select1 to change
/labels/@lang value, is that right?

The caveat with that is that the corresponding instance cannot be stamped as a
read-only one and XSLTForms will check its contents for validation each time it
will consider it necessary.

XPath evaluation for expressions such as "elt[@attr = 'value']" requires, first,
to retrieve all elements named "elt" then to apply a filter to each one. It
sounds like a relational approach with a key. This is not the most optimized XML
structure for XPath.

It would be more efficient to define a sort of map with attributes (elements
would be nicer for rich text values but a bit slower). In your example,
something like this:

<labels lang="en">
   <label-set lang="en" header-title="Forms-Wizard Designer
(alpha)">English</label-set>
   <label-set lang="es" header-title="Forms-Wizard Designer
(alpha)">Español</label-set>
   <label-set lang="fr" header-title="Forms-Wizard Designer
(alpha)">Français</label-set>

and

ref="label-set[@lang=../@lang]/@header-title"

You could, even, add an action to copy the corresponding label-set into a work
instance each time the select1 control has its value changed (not very often, I
presume). It will, then, remove the lang predicate! With XForms 2.0, using a
variable will be even better.

BTW, there is also the itext ODK extension
(http://www.agencexml.com/xsltforms/address.xml) but it does not specify how to
change from one language to another so it is just getting the browser current
language.

I am convinced that XPath 3.1 maps will be useful for performance and JSON/XML
convergence. I am already experimenting them in my own DOM implementation in
Javascript to be used as a replacement for DOM4!


>     Apparently these label <xf:output> references get re-evaluated each time
> there is a recalculation of the form. I did imagine (naively) that this would
> not happen if they where placed into a second model, but that doesn't seem to
> be what is happening in practice.
> 
Dependencies should say that this is not required but I would have to check this
more deeply...

> 
>     Also, I should be able to make that @xml:id to get a quicker scan of the
> labels model I suppose, but does XSLTForms support @id attributes as unique
> identifiers in data models?
> 
Yes, id() function calls mixed with @xml:id usage should improve this.

Thank you for your feedback!

--Alain
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://www.hpccsystems.com
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to