Re: [xsl] XSL Problem

Subject: Re: [xsl] XSL Problem
From: Josh Canfield <joshcanfield@xxxxxxxxx>
Date: Tue, 10 Aug 2004 17:46:57 -0700
It looks like you may have been generating the id for the
AdditionalInterestInfo node and then comparing with the id generated
for the NatureInterestCd nodes. Here is some code that works using the
generate-id method. Someone else may come up with something better,
but this works as I understand the problem.

<xsl:template match="/">  
  <xsl:variable name="first-lien-id"
select="generate-id((PersAutoInsurance/PersVeh/AdditionalInterest/AdditionalInterestInfo[NatureInterestCd
= 'LIEN'])[1])"/>

  <xsl:for-each select="
PersAutoInsurance/PersVeh/AdditionalInterest/AdditionalInterestInfo[NatureInterestCd
= 'LIEN' and not(generate-id(.) = $first-lien-id)]">
    <xsl:copy-of select="."/>
  </xsl:for-each>

  </xsl:template>

Hope this helps,
Josh

On Tue, 10 Aug 2004 20:01:23 -0400, Dale Earnest
<dale.earnest@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> I've run into a difficult xslt problem and I was hoping someone may have some insight.
> 
> I have an XML structure that looks like this (the '...'s represent nodes that aren't directly relevant to the question and are omitted):
> 
> <PersAutoInsurance>
> <PersVeh>
>  ...
>  <AdditionalInterest>
>    <AdditionalInterestInfo>
>    <NatureInterestCd>ADDIN</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
>  <AdditionalInterest>
>   ...
>   <AdditionalInterestInfo>
>    <NatureInterestCd>LIEN</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
>  <AdditionalInterest>
>   ...
>   <AdditionalInterestInfo>
>    <NatureInterestCd>LIEN</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
> </PersVeh>
> <PersVeh>
>  <AdditionalInterest>
>   ...
>   <AdditionalInterestInfo>
>    <NatureInterestCd>ADDIN</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
>  <AdditionalInterest>
>   ...
>   <AdditionalInterestInfo>
>    <NatureInterestCd>LIEN</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
>  <AdditionalInterest>
>   ...
>   <AdditionalInterestInfo>
>    <NatureInterestCd>AIL</NatureInterestCd>
>   </AdditionalInterestInfo>
>  </AdditionalInterest>
> </PersVeh>
> </PersAutoInsurance>
> 
> What I'm trying to do is select NatureInterestCd's based on the following criteria:
> 1) I cannot accept the first NatureInterestCd = LIEN for each vehicle (but may accept any subsequent for processing)
> 2) I cannot accept the first NatureInterestCd = AIL for each vehicle (but may accept any subsequent for processing)
> 2) I can accept any other node
> 
> I attempted to use this type of statement to get the nodes and loop over them:
> <xsl:for-each select="PersAutoInsurance/PersVeh/AdditionalInterest/AdditionalInterestInfo[not(NatureInterestCd = 'LIEN') and not(NatureInterestCd = 'AIL')]">
> 
> But that eliminates all nodes, not simply the first.  I tried adding in a position() qualifier, but that ended up only checking the first node in the whole node-set selected.
> 
> I tried generate-id(PersAutoInsurance/PersVeh[1]/AdditionalInterest/AdditionalInterestInfo[NatureInterestCd = 'LIEN'][1]) as that XPATH returns the LIEN I don't want (I had to use it in another part of the xsl), but the ID it generated wasn't the same as the ID that was being generated when I looped over the all the NatureInterestCd's, so I couldn't eliminate the node based on that.
> 
> I'm nearing my wits end on this problem and I was hoping that someone could give some insight into this problem.
> 
> Dale Earnest

Current Thread