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 & 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