-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I'm finally getting around to internationalizing the XSLT-based parts
of my application, and I'm running into a problem with non-trivial
uses of <i18n:text> in a template.

Here's an excellent example of the kind of thing I'm having trouble
with. I have a single XML document going through a pipeline with a few
transformations in it. There is one major transform where pretty much
everything interesting happens. I'd like to use <i18n> in there to
produce an HTML <a> element with a localized "title" attribute.
Something like this:

<xsl:template match="p:foo">
  <a href="..." title="This is some English text">click me</a>
</xsl:template>

Localizing the "click me" text is trivial. Doing the same with the
"title" attribute is not.

   <a title="<i18n:text key="some.text" />"  [...] >

That obviously won't work because the attribute won't be parsed and
evaluated by the XSLT parser. Use of {} around it doesn't work because
it's an element, not an expression.

  <xsl:element name="a">
    <xsl:attribute name="title">
      <i18n:text key="some.text" />
    </xsl:attribute>
    [...]
  </xsl:element>

That doesn't work because <xsl:attribute> evidently can't contain
<i18n:text>. At first, this irritated me but then I realized that this
would never work, because the second case would basically degenerate
into the first case after the <map:transform> completed its work for
this template before I (later) ran the I18nTransformer.

The only idea I've had is to flip the current i18n process on its head
and instead do this:

  <map:match pattern="/foo">
    <map:generate src="my.xml.document.xml" />

    <map:transform src="cocoon://localized-transform.xsl" />

    <map:serialize />
  </map:match>

  <map:match pattern="/localized-transform.xsl">
    <map:generate src="original.xsl" />

    <map:transform type="i18n">
      <map:parameter name="locale" value="en_US" />
    </map:transform>

    <map:serialize />
  </map:match>

So instead of transforming the input document with an
internationalized stylesheet, then transforming the result with the
i18n transformer, I first transform the transformer itself to get a
localized transformer, and transform the input document with *that*.

Is that "recommended technique"? Alternatively, is that entirely stupid?

If this is a good idea, how specifically can I accomplish what I have
above? I haven't yet tried it, but I'm concerned I'll have the same
problem with elements not being allowed in other elements.

Any suggestions?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAldDBi0ACgkQ9CaO5/Lv0PC3HQCfQLoPna+oFFoWxXggz0rKwxis
vyAAn1IrMa5SNcy+8fhr6Wt5JxdJ8abT
=i48t
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org

Reply via email to