[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml4lib
Subject:    [XML4LIB] XSL question (complex)
From:       a.giuliano () iccu ! sbn ! it (Andrea Giuliano)
Date:       2003-05-27 7:58:04
Message-ID: 3ED352CC.3090709 () iccu ! sbn ! it
[Download RAW message or body]

Dear Alan,

I admit I took a very rough look to your message, but maybe you could 
use xsl:element to create temporary TEMP elements, each containing all 
SETTAGS element with the same CL attribute, and xsl:attribute to give 
TEMP elements two attributes, one taken from the common CL attribute, 
and one taken from the unique OTL attribute. You will have several TEMP 
element, one for each CL value, so you still need a template to handle 
these TEMP elements, but it should be straightforward. The difficult 
task could be creating TEMP elements in a satisfactory way.

Sorry, at present I can't go through details, and I even can't figure 
them out, but it sounds to me a possible solution to your problem. If I 
can, I will try to write at least the template to create the grouping 
elements.

Best regards.

Alan Manifold wrote:

>Friends,
>I've got some XML that I want to process.  I have included a
>chunk of it below, which I think gives all of the necessary
>detail.
>
>What I'd like to do is to output a web page, with the database
>names (DBN tag) in order, within the values for CL.  So, the
>one where CL=0 should go first, then all of the ones where
>CL=10, then all of the ones where CL=94.  Within those classes,
>the names should be in order.  I can do all this, with XSLT
>like this:
>
><xsl:for-each select="SETTAGS">
>	<xsl:sort select="CL"/>
>	<xsl:sort select="DBN"/>
>		...stuff...
></xsl:for-each>
>
>My problem is that each of the classes needs to have a
>header.  The headers appear as OTL tags in the first record
>of each class, before they are put in order.  I tried adding
>to the code above to get this:
>
>
><xsl:for-each select="SETTAGS">
>	<xsl:sort select="CL"/>
>	<xsl:sort select="DBN"/>
>	<xsl:choose>
>		<xsl:when test="CL != following::CL[position()=1]">
>			...stuff...
>		</xsl:when>
>	</xsl:choose>
></xsl:for-each>
>
>This looks for an instance where the current class (CL) is
>different from the class of the record immediately following,
>then outputs the header (...stuff...) when it finds that
>condition.  Unfortunately, it doesn't work the way I want it
>to (or the way I would expect it to).  Instead of printing a
>header after WorldCat and before Clinical Pharmacology, as I
>would expect, it puts a header after NetAdvantage and before
>Prokaryotes, which are actually in the same class.  This
>seems to be because in the unsorted XML, the entry following
>NetAdvantage has a different value for CL.  The test on
>"following::CL[position()=1]" appears to be performed on the
>unsorted XML, rather than on the sorted XML.
>
>Two questions:
>1.  Does this seems wrong?  I would think that since the
>"following" falls within a "for-each" that is sorted, that
>the "following" should be performed against the sorted
>entries, rather than against the unsorted ones.
>
>2.  Is there a way to do what I want?  I'm an XSL/XML newbie,
>and I can't think of or find any way to do what I want here.
>
>Thanks for any help you can offer.
>
>
>
><!-- XML snippet: -->
><SIMULSUMMARY rc="0">
>	<SETTAGS>
>		<CL>0</CL> 
>		<DBN>Purdue West Lafayette Library Catalog</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<OTL>All Databases, A-Z</OTL>
>		<DBN>WorldCat</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<DBN>Academic Search Elite</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<DBN>EBSCO Animals</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<DBN>Biomedical Reference Collection: Basic</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<DBN>Prokaryotes</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>10</CL> 
>		<DBN>Net Advantage</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>94</CL> 
>		<OTL>Xperimental connectors -- not yet working</OTL> 
>		<DBN>General Science Full Text</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>94</CL> 
>		<DBN>Education Full Text</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>94</CL> 
>		<DBN>Clinical Pharmacology</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>94</CL> 
>		<DBN>Humanities Abstracts</DBN> 
>	</SETTAGS>
>	<SETTAGS>
>		<CL>94</CL> 
>		<DBN>Index to Legal Periodicals and Books</DBN> 
>	</SETTAGS>
></SIMULSUMMARY>
>
>  
>

-- 
Andrea Giuliano, Ph. D.
IT Consultant
ICCU - Istituto Centrale per il Catalogo Unico
Viale Castro Pretorio 105, Rome - ITALY
Tel. +39064989509, Fax +39064059302

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic