[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: filtering out one element

Subject: Re: filtering out one element
From: "Mark Wilson" <mark@xxxxxxxxxxxx>
Date: Sun, 20 Dec 2009 08:30:33 -0800
Re:  filtering out one element
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.