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] |
Michal, >Thanks for your help. I tried using the key solution and it worked perfectly. >However, I have not been able to get the correct results using the non-key >approach. I changed following to preceding as you suggested. So now my XPath >looks like this: > Test/location/state[not(translate(.,$lowercase,$uppercase)= > translate(preceding::state,$lowercase,$uppercase))] I know why it's not working (and I'm sorry for misleading you about why your previous version wasn't working). The reason is that this is finding any state where the traslated value of the state is not the same as the translated value of preceding::state. preceding::state is a node list; using it within translate() converts it into a string by taking the string value of the node that is first in document order, 'xxxx' in your case. Effectively, then, you are finding states where the content of the state is not 'xxxx' (if the state has a preceding state). What you want to do is test whether there are any preceding states that have the same (translated) value as the state you're looking at. I'm afraid that my mind's gone absolutely blank about how to achieve this on a one-pass XPath. You want something like: Test/location/state[not(preceding::state[translate(., $lowercase, $uppercase) = translate(????, $lowercase, $uppercase)])] but I can't think of anything that you can put in place of the ???? that will make it work. Perhaps someone else has a clue, but I'm leaning towards saying that it can't be done. If you don't want to use keys, you probably need to have a two-stage pass that does something like: <xsl:for-each select="Test/location/state"> <xsl:variable name="state" select="translate(., $lowercase, $uppercase)" /> <xsl:if test="not(preceding::state[translate(., $lowercase, $uppercase) = $state])"> <!-- do what you want to do --> </xsl:if> </xsl:for-each> Sorry I can't be of more help, 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] |