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

RE: XML/XSLT formatting problem

Subject: RE: XML/XSLT formatting problem
From: "Chris Hicks" <chrish2000@xxxxxxxxxxxxxx>
Date: Thu, 6 Jan 2005 21:46:28 +1100
barney jpg
I think I've solved my problem,

<xsl:apply-templates select="image[id =
$lastid]/following-sibling::image[count(. | key('idkey', id)[1])=1]"/> 

Thanks for all the help.

Chris

> -----Original Message-----
> From: Chris Hicks [mailto:chrish2000@xxxxxxxxxxxxxx] 
> Sent: Thursday, 6 January 2005 8:50 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  XML/XSLT formatting problem
> 
> Thanks Michael,
> 
> This has further been complicated by the fact that I have 
> image ID's in the result set that are repeated..in what is 
> essentially a de-normalised structure
> 
> Eg. 
> 
> <results lastid="9">
>   <image>
>     <id>37</id>
>     <imagetitle>Fred</imagetitle>
>     <imagelocation>fred.jpg</imagelocation>
>     <imagesubject>Fred</imagesubject>
>   </image>
>   <image>
>     <id>9</id>
>     <imagetitle>Wilma</imagetitle>
>     <imagelocation>wilma.jpg</imagelocation>
>     <imagesubject>Wives</imagesubject>
>   </image>
>   <image>
>     <id>9</id>
>     <imagetitle>Wilma</imagetitle>
>     <imagelocation>wilma.jpg</imagelocation>
>     <imagesubject>Women</imagesubject>
>   </image>
>   <image>
>     <id>9</id>
>     <imagetitle>Wilma</imagetitle>
>     <imagelocation>wilma.jpg</imagelocation>
>     <imagesubject>Fred</imagesubject>
>   </image>
>   <image>
>     <id>22</id>
>     <imagetitle>Barney</imagetitle>
>     <imagelocation>barney.jpg</imagelocation>
>     <imagesubject>Bam Bam</imagesubject>
>   </image>
>   <image>
>     <id>22</id>
>     <imagetitle>Barney</imagetitle>
>     <imagelocation>barney.jpg</imagelocation>
>     <imagesubject>Betty</imagesubject>
>   </image>
>   <image>
>     <id>24</id>
>     <imagetitle>Dino</imagetitle>
>     <imagelocation>dino.jpg</imagelocation>
>     <imagesubject>Dino</imagesubject>
>   </image>
>   <image>
>     <id>24</id>
>     <imagetitle>Dino</imagetitle>
>     <imagelocation>dino.jpg</imagelocation>
>     <imagesubject>Fred</imagesubject>
>   </image>
> </results>
> 
> So what I have is a key on id at the top of my template:
> 
> <xsl:key name="idkey" match="image" use="id"/> ..
> 
> Then I want to output a line for each unique ID using:
> 
> <xsl:for-each select="photographs::[count(. | key('idkey', 
> id)[1])=1]"> ..
> 
> Is there any way in the above line I can apply the 
> restriction that the id must be in a sibling of the image 
> with the @lastid so I only output items with id's of 22 and 24?
> 
> Cheers,
> 
> Chris
> 
> 
> 
> 
> > -----Original Message-----
> > From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> > Sent: Thursday, 6 January 2005 8:29 PM
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: RE:  XML/XSLT formatting problem
> > 
> > 
> > <xsl:template match="results">
> >   
> >   <xsl:apply-templates
> > select="image[id=current()/@lastid]/following-sibling::*">
> >    ...
> > 
> > Michael Kay
> > http://www.saxonica.com/
> > 
> > > -----Original Message-----
> > > From: Chris Hicks [mailto:chrish2000@xxxxxxxxxxxxxx]
> > > Sent: 06 January 2005 07:09
> > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > > Subject:  XML/XSLT formatting problem
> > > 
> > > Hi,
> > > 
> > > I have a problem where I need to start printing values from
> > a nodeset
> > > starting from a certain position in the set.
> > > 
> > > My xml looks similar to this:
> > > 
> > > <results lastid="9">
> > >   <image>
> > >     <id>37</id>
> > >     <imagetitle>Fred</imagetitle>
> > >     <imagelocation>fred.jpg</imagelocation>
> > >   </image>
> > >   <image>
> > >     <id>22</id>
> > >     <imagetitle>Barney</imagetitle>
> > >     <imagelocation>barney.jpg</imagelocation>
> > >   </image>
> > >   <image>
> > >     <id>9</id>
> > >     <imagetitle>Wilma</imagetitle>
> > >     <imagelocation>wilma.jpg</imagelocation>
> > >   </image>
> > >   <image>
> > >     <id>12</id>
> > >     <imagetitle>Dino</imagetitle>
> > >     <imagelocation>dino.jpg</imagelocation>
> > >   </image>
> > >   <image>
> > >     <id>1</id>
> > >     <imagetitle>Bam Bam</imagetitle>
> > >     <imagelocation>bambam.jpg</imagelocation>
> > >   </image>
> > > </results>
> > > 
> > > I need to check the "lastid" attribute in the result node
> > when looping
> > > through the nodeset in order to know when to start 
> printing results 
> > > (this represents the last id printed on the previous 
> page).  In the 
> > > above example I want to start printing results starting
> > from id = 12.
> > > 
> > > Any tips on where to begin would be appreciated.
> > > 
> > > Cheers,
> > > 
> > > 
> > > Chris

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.