If you are using xalan, I've used this method in a project:

   1. Define the attribute xmlns:Dict="xalan://com.example.Dict" in
   xsl:stylesheet tag.
   2. Put the label: <xsl:value-of select="Dict:trans(
   str:new(string('test')) "/>
   3. Create a class Dict with a method trans(String) and put it in your
   classpath. This method can read an application.properties with a
   PropertiesHandler and get the value of the label.

JM

2011/6/17 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>

> humm, that could do the trick. Altough I would need to extend it to get the
> locale from the ActionContext.
>
> 2011/6/17 Maurizio Cucchiara <mcucchi...@apache.org>
>
> > is that [1] what you are looking for?
> >
> > [1]
> http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt.html?page=3
> >
> > On 17 June 2011 09:26, <jlm...@gmail.com> wrote:
> > >
> > > Well, the XML comes from an external provider through a webservice, so
> I
> > would prefer otheer solution...if possible.
> > > Sent via BlackBerry from T-Mobile
> > >
> > > -----Original Message-----
> > > From: Chris Pratt <thechrispr...@gmail.com>
> > > Date: Thu, 16 Jun 2011 22:24:33
> > > To: Struts Users Mailing List<user@struts.apache.org>
> > > Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
> > > Subject: Re: getText on XSLT transformation on an Action
> > >
> > > There's no reason the XSL should be dynamic.  The XML is typically the
> > > dynamic part with the XSL being static (so that it can be parsed and
> > cached
> > > for efficiency).  Why not include a section in the XML with the
> > replacement
> > > text, then reference the strings using XPath?
> > >  (*Chris*)
> > >
> > > On Thu, Jun 16, 2011 at 5:34 PM, Miguel <miguel...@gmail.com> wrote:
> > >
> > > > Yes, if you want this, you need to create the XSLT on the fly,
> > > > You can use freemarker to achieve this. substituying the placeholders
> > > > with the appropiate text.
> > > > You can use even apache commons StringUtils if you only want to
> > > > susbtitute placeholders with fixed text.
> > > >
> > > > Cheers,
> > > >
> > > > Si quieres ser más positivo, pierde un electrón
> > > > Miguel Ruiz Velasco Sobrino
> > > >
> > > >
> > > >
> > > > On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL <
> jlm...@gmail.com
> > >
> > > > wrote:
> > > > > could you expand that? do you mean to create the XSLT on the fly?
> > > > >
> > > > > 2011/6/16 Maurizio Cucchiara <mcucchi...@apache.org>
> > > > >
> > > > >> The first solution I thought is: a template engine.
> > > > >> Currently your xslt file is static, you should consider to make
> > dynamic
> > > > in
> > > > >> order to include dynamic content.
> > > > >>
> > > > >> Maurizio Cucchiara
> > > > >>
> > > > >> Il giorno 16/giu/2011 19.37, "JOSE L MARTINEZ-AVIAL" <
> > jlm...@gmail.com>
> > > > ha
> > > > >> scritto:
> > > > >> > Hi,
> > > > >> > I'm using Struts 2.1.8.1. I have an action that retrieves some
> XML
> > > > data
> > > > >> > from a webservice, and transform it to HTML using XSLT. The
> > > > >> transformation
> > > > >> > is done in the action, and the output is returned as a stream
> and
> > sent
> > > > to
> > > > >> > the client. It works fine, but now I need to write some labels
> > that
> > > > >> depend
> > > > >> > on the user's locale. Is there any way to call getText from the
> > XSLT
> > > > >> > stylesheet, so it uses the action that called the transformer as
> > the
> > > > >> basis
> > > > >> > to look for the package with the labels in the diferent
> languages?
> > It
> > > > >> should
> > > > >> > also use the user's locale, but since it gets it from the
> > > > ActionContext,
> > > > >> it
> > > > >> > should work fine.
> > > > >> >
> > > > >> > Thanks
> > > > >> >
> > > > >> > Jose
> > > > >>
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > Maurizio Cucchiara
> >
>

Reply via email to