This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: problem with preceding axis


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]