[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

'Variable' question from Newbie

Subject: 'Variable' question from Newbie
From: "Surla, Stacy" <SSurla@xxxxxxxxxxxx>
Date: Fri, 8 Nov 2002 16:17:04 -0500
stacy surla
I (superficially) understand that you can't change the value of a variable
once it's defined.  But although I've looked through the list FAQs and other
sources, I haven't yet grasped how one goes about doing certain things that
would be possible, if only one could update a variable each time through a
loop.  Here's my problem.

I have a collection of publications records in XML that store Discipline,
Title, Date, and other characteristics, including a flag indicating whether
the publication should show up on a Highlights page.  I now want to output
the Highlights page, and I want the value of Discipline to be output only
once per group of records sharing that discipline.  E.g. 

JAILS
Title of Report1, publisher1, date1
Title of Report2, publisher2, date2
[link to Jails subpage]

PRISONS
Title of Report3, publisher3, date3
Title of Report4, publisher4, date4
[link to Prisons subpage]

In the olden days I would have used something like the following logic:

Sort by Discipline
For each record,
Check if Highlights = True
If yes,
  Check if Discipline = $var
  If no,
    Put the value of Disciplines into $var
    Output the value of $var
    Output values of Title, Publisher, and Date
  If yes,
    Output values of Title, Publisher, and Date


I can't do it like this in XSLT.  In fact, I have to learn not to THINK like
this, I'm starting to realize.  Can someone please explain to me how I would
accomplish the same end?  Thanks very much in advance for any help.  Below
is a sample of my XML.

~Stacy


<InstCorr>
	<Record>
		<Title>BJS Drugs &amp; Crime Facts</Title>
		<Disciplines>Institutional Corrections, Jails</Disciplines>
		<Highlights_Discipline>1</Highlights_Discipline>
	</Record>
	<Record>
		<Title>Drug Treatment in the Criminal Justice System</Title>
		<PubDate>March 2001</PubDate>
		<Disciplines>Institutional Corrections, Jails</Disciplines>
		<Highlights_Discipline>0</Highlights_Discipline>
	</Record>
	<Record>
		<Title>Assessing Alcohol, Drug, and Mental Disorders in
Juvenile Detainees</Title>
		<PubDate>January 2001</PubDate>
		<Disciplines>Institutional Corrections, Jails</Disciplines>
		<Highlights_Discipline>1</Highlights_Discipline>
		</Record>
	<Record>
		<Title>TRIAD Drug Treatment Evaluation Project</Title>
		<PubDate>September 2000</PubDate>
		<Disciplines>Institutional Corrections,
Prisons</Disciplines>
		<Highlights_Discipline>0</Highlights_Discipline>
	</Record>
	<Record>
		<Title>Institute for Criminal Justice Healthcare</Title>
		<Disciplines>Institutional Corrections,
Prisons</Disciplines>
		<Highlights_Discipline>1</Highlights_Discipline>
	</Record>
	<Record>
		<Title>Therapeutic Communities in Correctional
Settings</Title>
		<PubDate>November 1999</PubDate>
		<Disciplines>Institutional Corrections,
Prisons</Disciplines>
		<Highlights_Discipline>1</Highlights_Discipline>
	</Record>
	<Record>
		<Title>Substance Abuse Treatment Programs in the Federal
Bureau of Prisonss</Title>
		<PubDate>January 1999</PubDate>
		<Disciplines>Institutional Corrections,
Prisons</Disciplines>
		<Highlights_Discipline>0</Highlights_Discipline>
	</Record>
</InstCorr>





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.