[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Use XSL:Variable


Subject: Re: [xsl] Use XSL:Variable
From: António Mota <amsmota@xxxxxxxxx>
Date: Tue, 1 Feb 2005 16:17:39 +0000

Yes, by opposite to a "procedural" way of thinking that most
programmers have. At least that's wath's happened to me when i started
working on XSL not so long ago...

:)


On Tue, 1 Feb 2005 16:04:30 -0000, Paulo Mendes Pinto
<paulo.pinto@xxxxxxx> wrote:
> I think that's it ... the XSL kind of thinking.... eeheheheheh
>
> PMP
>
> > -----Original Message-----
> > From: Antsnio Mota [mailto:amsmota@xxxxxxxxx]
>
> > Sent: terga-feira, 1 de Fevereiro de 2005 16:00
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [xsl] Use XSL:Variable
> >
> > Just to clarify, I *did not say* that variables are most used in
> > matematic calculations, far from that. I was saying they are variables
> > as they are used in the matematical equations, instead of they are
> > used in languages like Java ou Vb .
> >
> > Glad you solved you're problem, remember that normally the ways to do
> > things ib XSLT are more simple then they appear at first, you just
> > have to think about then in a "xslt" way...
> >
> > Fica bem.
> >
> >
> > On Tue, 1 Feb 2005 15:48:42 -0000, Paulo Mendes Pinto
> > <paulo.pinto@xxxxxxx> wrote:
> > > Hummmm
> > >
> > > In my CONTROL node I have the Extentions of the file and in my
ObjectIndex Node
> > a want to concatenate it to the file name (without extention).
> > >
> > > I have to put in one variable the value read in the CONTROL node and
concatenate
> > with the file name in ObjectIndex Node.
> > >
> > > Try to explain in Portuguese:
> > > No ns de Control tenho definido a extensco dos ficheiros e quando aplico
um
> > template ao ns ObjectIndex quero que, ao nome do ficheiro aqui definido,
seja
> > concatenado a extensco que foi lida no ns de CONTROL.
> > >
> > > Falaste que as variaveis sco mais usados para contas matematicas... sera
que
> > podemos guardar um valor num template e usar noutro template?
> > >
> > > Tkx in avance
> > >
> > >
> > > PMP
> > >
> > > > -----Original Message-----
> > > > From: Antsnio Mota [mailto:amsmota@xxxxxxxxx]
> > > > Sent: terga-feira, 1 de Fevereiro de 2005 15:36
> > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > Subject: Re: [xsl] Use XSL:Variable
> > > >
> > > > As i said you should explain what you want to do, giving examples of
> > > > XML and the XSL you have so far. Like this no one can help.
> > > >
> > > > You must remember that variables aren't variable ;) , once you define
> > > > then you can not change their value. So you don't define in one place
> > > > and assign in another place. Variables in XSL are variables in the
> > > > mathematical sense, not in "placeholder" sense like in procedural
> > > > languages, like Java or VB...
> > > >
> > > > I use vars all the time, you just have to be a little more
specific...
> > > >
> > > >
> > > > On Tue, 1 Feb 2005 15:22:44 -0000, Paulo Mendes Pinto
> > > > <paulo.pinto@xxxxxxx> wrote:
> > > > > Obrigado Antsnio.
> > > > >
> > > > > Something I've learn from you response: I have to define my variable
in / and
> > not
> > > > in template.
> > > > >
> > > > > If someone can post here examples of use of variable defined as
global, assign
> > in
> > > > one template and  used in another, that will be nice.
> > > > >
> > > > > Tkx in avance
> > > > >
> > > > > Realmente ter tugas nestas listas i sempre interessante.... um
abrago
> > > > >
> > > > > PMP
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Antsnio Mota [mailto:amsmota@xxxxxxxxx]
> > > > > > Sent: terga-feira, 1 de Fevereiro de 2005 15:16
> > > > > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > > > > Subject: Re: [xsl] Use XSL:Variable
> > > > > >
> > > > > > Ora viva, i sempre bom encontrar um compatriota :)
> > > > > >
> > > > > > I'm not one of the lists experts, there are many people here who
> > > > > > really excels in this area, making this one of the most useful
lists
> > > > > > i've seen. But i can point some obvious things.
> > > > > >
> > > > > > First, there are no "tags" in XSL, XSL works on "nodes" not on
"tags".
> > > > > > So you work by selecting nodes, apllying temnplates on then,
etc...
> > > > > >
> > > > > > Second your var
> > > > > >
> > > > > > >      <xsl:template match="ObjectFormat">
> > > > > > >           <xsl:variable name="FileExtention"><xsl:value-of
> > > > > > select="@FileExtention"/></xsl:variable>
> > > > > > >      </xsl:template>
> > > > > > >
> > > > > >
> > > > > > exist only inside the template where you define it, so you can't
use
> > > > > > it anywhere else. You'll have to define it  at the root level you
want
> > > > > > it to be global. But it's not clear what you're trying to do, you
> > > > > > should post more info, along with examples of your XML . That
template
> > > > > > like it is does nothing...
> > > > > >
> > > > > > Fica bem...
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Tue, 1 Feb 2005 15:04:24 -0000, Paulo Mendes Pinto
> > > > > > <paulo.pinto@xxxxxxx> wrote:
> > > > > > > Hello
> > > > > > >
> > > > > > > I'm new at this List and new in XSL and I have many problems
> > understanding
> > > > how
> > > > > > to do something.
> > > > > > >
> > > > > > > I have a XML that I want to transform to in a CSV text file to
import to
> > Excel.
> > > > Until
> > > > > > now I have the text file like I want with the char set that I want
but there is
> > > > > > something that I want and I don't know how.
> > > > > > >
> > > > > > > In my XML I have a CONTROL tag with some information that I will
use in
> > the
> > > > other
> > > > > > tags. Some of the tags in CONTROL tag will concatenate with some
tags
> > along
> > > > the rest
> > > > > > the XML.
> > > > > > >
> > > > > > > I have to get some data from the CONTROL tag and save it in a
variable
> > and
> > > > use to
> > > > > > concatenate with fields is another tag.
> > > > > > >
> > > > > > > How can I do that? I was trying to do like this.
> > > > > > >
> > > > > > >      <xsl:template match="CONTROL">
> > > > > > >           <xsl:apply-templates/>
> > > > > > >      </xsl:template>
> > > > > > >
> > > > > > >      <xsl:template match="ObjectFormat">
> > > > > > >           <xsl:variable name="FileExtention"><xsl:value-of
> > > > > > select="@FileExtention"/></xsl:variable>
> > > > > > >      </xsl:template>
> > > > > > >
> > > > > > > The FileExtention is an Attribute of Object Format tag in
CONTROL.
> > > > > > >
> > > > > > > <xsl:template match="ObjectIndex">
> > > > > > >      <xsl:value-of select="@Code"/><xsl:text>;</xsl:text>
> > > > > > >      <xsl:value-of
select="@Description"/><xsl:text>;</xsl:text>
> > > > > > >      <xsl:copy-of select="$FileExtention"
/><xsl:text>|</xsl:text>
> > > > > > >      <xsl:text>&#xD;&#xA;</xsl:text>
> > > > > > > </xsl:template>
> > > > > > >
> > > > > > > With this XSL I get an error:
> > > > > > > Invalid variable referenceError in XPath expression. Invalid
variable
> > reference
> > > > > > >
> > > > > > > How can I use this variable?
> > > > > > >
> > > > > > > Tkx in advance
> > > > > > >
> > > > > > > Paulo Aboim Pinto
> > > > > > > Engenheiro de Produto
> > > > > > > ======================
> > > > > > > DSTS - Desenvolvimento e Integragco de Servigos e Tecnologia,
S.A.
> > > > > > > Tel.(+351)21 092 56 28
> > > > > > > Fax.(+351)21 092 56 29


Current Thread
Keywords