Subject: Re: [xsl] problem with preceding axis From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 11 Oct 2001 10:42:14 +0100 |
Hi Kalpana, > Could anybody tell me how to solve this problem. My problem is that > I use [not(@ID=preceding::Document/@ID)] which protects the next > Documents, having same ID, to be displayed but I can't avoid writing > [not(@ID=preceding::Document/@ID)] also. The predicate that you're using will make sure that you can only ever get the first Documents *in the whole document* with a particular ID. I think that you want to get the first Documents *in a particular Attr* with a particular ID. To do this, you need to compare each Document's ID with that of the Document children of the Year elements that precede this document's parent Year element. The location path is: Year/Document[not(@ID = ../preceding-sibling::Year/Document/@ID)] This location path protects you against situations where an earlier Year element doesn't have a Document child with a particular ID - you still get a row for each Document ID. However, if you use this you should be careful because in the rest of your template, you seem to be assuming that all the Year elements will have the same set of child Documents. If that *is* the case, then rather than use the path above, it would be a lot easier to just get the Document children of the first Year: Year[1]/Document If that *isn't* the case, then you need to change the body of the template so that you create an empty cell if a given Year doesn't have a Document child with the ID that you're interested in, something like: <xsl:for-each select="Year"> <td class="cssbody11"> <xsl:value-of select="Document[@ID = $varDocID]/Value" /> </td> </xsl:for-each> By the way, unless the source XML document is incredibly weird, you shouldn't have all those disable-output-escaping attributes all over the place - they make it very likely that you'll generate non-well-formed HTML. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] problem with preceding axis, kalpana rawat | Thread | [xsl] sum of products, Steve Renshaw |
RE: [xsl] Passing through character, Michael Kay | Date | RE: [xsl] Text output, Michael Kay |
Month |