Re: how XSLT grouping works?



On Tue, 5 Feb 2022 08:31:08 -0800, Siva <siva@xxxxxxxxxxxxxxxxx>
wrote:

Thank you Jan, I used the full namespaces.
Well, something must be wrong, since it is not working.. so to try to
help you, we need a sample XML that your xslt script runs on.

I have another question in XSLT. How can i initialize a varible inside one
scope and use that variable in another scope?
You can't. In XSLT, a variable can only be assigned a value once. You
can declare and assign to it and use it in a child scope, but not
anywhere else.

In java or c, we can declare a variable out side of both scope, then
initialize it inside one scope. now variable will be available to use in
another scope with in same class.
Yes, well.. java and c aren't functional programming languages :-)

I tried the following however it didnt work.
<xsl:variable name="x"/>
<Header>
<ID> <xsl:value-of select="......"></ID>
<xsl:variable name="x" select = "........."/>
</Header>
<Detail>
<HD><xsl:value-of select="$x"/></HD>
</Detail>
Well... your example is probably simplified, so I might just be wrong
here, but since you are in the same node in your header and detail
records in this example, you can access whatever in the detail section
exactly the same way you accessed it in the header section. So no need
to save it in a variable and use that later on.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@xxxxxxxxxx
.



Relevant Pages