Re: [xsl] filtering out one element

Subject: Re: [xsl] filtering out one element
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sun, 20 Dec 2009 08:30:33 -0800
I just tried Listing 3 and it works, so something must be wrong with the negatives in Listing 1. Please, what is it?
Mark


Listing 3.
<xsl:template match="Article" mode="format">
<xsl:choose>
<xsl:when test="Title eq preceding-sibling::Article[1]/Title and Year eq preceding-sibling::Article[1]/Year and IssueNumber eq preceding-sibling::Article[1]/IssueNumber">
<!-- Do nothing; I could not get the negative version to work -->
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="citation"/>
<xsl:apply-templates select="Comment"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


--------------------------------------------------
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Sent: Sunday, December 20, 2009 8:03 AM
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] filtering out one element

In listing 1, I have code that rejects duplicate <Article> elements in a sorted list made up of items similar to those in Listing 2. Right now, the filter considers the entirety of the immediately preceding sibling <Article>. I think this code seems to work as advertised.

However, I now want it to disregard the <Page> element during the comparison so that the two articles in Listing 2 would be considered identical and the "citation" template in Listing 1 would not be called.

I tried :

<xsl:if test="not(Title eq preceding-sibling::Article[1]/Title)
and not(Year eq preceding-sibling::Article[1]/Year)
and not(IssueNumber eq preceding-sibling::Article[1]/IssueNumber)"
but that code does not work at all.


What is the proper way to remove duplicates by comparing the Title, Year, and IssueNumber elements while ignoring the Page element in the immediately preceding Article??

Thanks,
Mark

Listing 1.
<!-- Each title will have one or more citations -->
<xsl:template match="Article" mode="format">
   <xsl:if test="not(. eq preceding-sibling::Article[1])">
       <xsl:call-template name="citation"/>
       <xsl:apply-templates select="Comment"/>
</xsl:if>
</xsl:template>

Listing 2.
<Article>
        <Title>Future Issues</Title>
        <IssueName>Apr</IssueName>
        <Year>1948</Year>
        <Page>38</Page>
        <IssueNumber>4</IssueNumber>
</Article>
<Article>
        <Title>Future Issues</Title>
        <IssueName>Apr</IssueName>
        <Year>1948</Year>
        <Page>39</Page>
        <IssueNumber>4</IssueNumber>
</Article>

Current Thread