Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2015, 09:38 AM
Registered User
 
Join Date: Feb 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is there any method by which an XSLT can hold state?

The output I need to produce via XSLT wraps certain elements in "Group" tags - i.e.

<Group_12>
<Element1>A</Element1>
<Element2>B</Element2>
<Element3>C</Element3>
</Group_12>
<Group_15>
<Element4>D</Element4>
</Group_15>
<Group_17>
<Element5>E</Element5>
<Element6>F</Element6>
</Group_17>

The numbering of the groups will not necessarily be in sequence, as shown above, but will always be greater than the previous group number. In order to produce the output, the previously written <Group_xx> number must be referencable within the XSLT.

Any help/suggestions gratefully received.
 
Old February 12th, 2015, 10:43 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

It is not considered good design to put index or count numbers into XML element or attribute names, as you seem to want to do. As for "holding state", unless you play with XSLT 3.0 accumulators or iterate there is no directly comparable concept but of course you can write templates or functions (functions since XSLT 2.0) which take parameters and call themselves recursively, passing on the state in a parameter. Whether all that is necessary is difficult to tell, so far you have only shown the output you want but no input you want to process and how the input is mapped to the output.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT: Need to concatenate strings in loop and hold them for later use sandeepbhutani304 XSLT 3 January 9th, 2009 11:31 AM
xslt.Load method in c# takes about 8 seconds pradeepn XSLT 2 August 31st, 2007 03:53 PM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM
XSLT Dynamic xsl:sort Method kwilliams XSLT 2 July 20th, 2005 03:19 PM
{ and } to hold an array jaucourt VB.NET 2002/2003 Basics 2 November 25th, 2004 09:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.