RE: [xsl] adding unique values to a drop-down list

Subject: RE: [xsl] adding unique values to a drop-down list
From: "Katie McNally" <kmcnally9@xxxxxxxxxxx>
Date: Fri, 18 Jan 2002 13:36:56 -0600
I am trying to display unique brokers in a drop-down for each loan with a channel of "WH".

My for-each statement which loops through the loans seems to work only when the first loan in the xml has a channel of "WH". If it does, all unique brokers are displayed in the drop-down. If the channel of the first loan in the xml is something other than "WH", no brokers are displayed.

Any suggestions?

My for-each statement and sample xml are listed below:

<xsl:for-each select= "Loan[not(Id=preceding::Id) and string(Name) and string(Id) and Channel='WH']">
<xsl:sort select="Name" order="ascending"/>
<xsl:sort select="Id"/>
<option value='{Id}'>
<xsl:call-template name="displayBroker">
<xsl:with-param name="name" select="Name"/>
<xsl:with-param name="id" select="Id"/>
</xsl:call-template>
</option>
</xsl:for-each>



<Loan> <LoanId>0000003071</LoanId> <Channel>RET</Channel> <Name>Broker 1</Name> <Id>432123</Id> </Loan> <Loan> <LoanId>0000003072</LoanId> <Channel>WH</Channel> <Name>Broker 1</Name> <Id>432123</Id> </Loan> <Loan> <LoanId>0000003073</LoanId> <Channel>WH</Channel> <Name>Broker 1</Name> <Id>432123</Id> </Loan>



From: "kfricovsky" <kfricovsky@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: [xsl] adding unique values to a drop-down list
Date: Tue, 4 Dec 2001 16:39:13 -0500

Katie,

Here's another way to remove duplicates.

<xsl:for-each select="Loan/BrokerSet/Broker[not(Name=preceding::Name)
and not(Id=preceding::Id) and
string(Name) and string(Id)]">
	<xsl:sort select="Name" order="ascending"/>
	<xsl:sort select="Name"/>
	<xsl:sort select="Id"/>
	<option value="{Id}">
		<xsl:value-of select="Name"/> - <xsl:value-of
select="Id"/>
	</option>
</xsl:for-each>



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Katie
McNally
Sent: Tuesday, December 04, 2001 3:51 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] adding unique values to a drop-down list


I have not been able to correctly fill the drop-down with brokers. The drop-down must contain the broker name/id combinations listed alphabetically with no duplicates.

The first time I followed your suggestion but the drop down did not
contain
any brokers.  My for-each statement:

<xsl:for-each select="Loan[not(.=preceding-sibling::*) and
string(BrokerSet/Broker/Name) and string(BrokerSet/Broker/Id)]">
	<option value="{BrokerSet/Broker/Id}"><xsl:value-of
select="BrokerSet/Broker/Name"/> - <xsl:value-of
select="BrokerSet/Broker/Id"/></option>
</xsl:for-each>

I modified the for-each.  The drop-down contained brokers, but they were
not
listed alphabetically, and duplicates were present.  My for-each:

<xsl:for-each select="Loan/BrokerSet/Broker[not(.=preceding-sibling::*)
and
string(Name) and string(Id)]">
	<option value="{Id}"><xsl:value-of select="Name"/> -
<xsl:value-of
select="Id"/></option>
</xsl:for-each>

I added sort statements.  The drop-down contained brokers, listed
alphabetically, but duplicates were present.  My for-each:

<xsl:for-each select="Loan/BrokerSet/Broker[not(.=preceding-sibling::*)
and
string(Name) and string(Id)]">
	<xsl:sort select="Name"/>
	<xsl:sort select="Id"/>
	<option value="{Id}"><xsl:value-of select="Name"/> -
<xsl:value-of
select="Id"/></option>
</xsl:for-each>

I cannot figure out how NOT to display duplicates. Any suggestions?

>From: "kfricovsky" <kfricovsky@xxxxxxxxxxx>
>Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>Subject: RE: [xsl] adding unique values to a drop-down list
>Date: Tue, 4 Dec 2001 12:18:19 -0500
>
>This will work for you. I used <funds> as my root element.
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>	<xsl:output method="html"/>
>	<xsl:template match="fund">
>	<form action="">
>		<select name="FOO">
>		<xsl:for-each select="Loan[not(.=preceding-sibling::*)
>and string(BrokerSet/Broker/Name) and string(BrokerSet/Broker/Name)]">
>			<option
>value="{BrokerSet/Broker/Id}"><xsl:value-of
>select="BrokerSet/Broker/Name" /> - <xsl:value-of
>select="BrokerSet/Broker/Id" /></option>
>		</xsl:for-each>
>		</select>
>	</form>
>	</xsl:template>
></xsl:stylesheet>
>
>-Kevin Fricovsky
>
>
>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Katie
>McNally
>Sent: Tuesday, December 04, 2001 11:45 AM
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: [xsl] adding unique values to a drop-down list
>
>
>I have xml that contains loans and their data (which includes broker
>name and id).
>
>I need to add a drop-down of brokers to my page.  Each selection in the

>list box needs to display "Broker Name - Broker Id" and the value of
>each selection must be set to the Broker Id.  These selections must be
>listed
>
>alphabetically, with only unique values displayed (no duplicates).
>
>For example:
>
>Example XML:
>
><Loan>
>   <BrokerSet>
>     <Broker>
>       <Name>ABC Broker</Name>
>       <Id>123456</Id>
>     </Broker>
>   </BrokerSet>
></Loan>
><Loan>
>   <BrokerSet>
>     <Broker>
>       <Name>LMN Broker</Name>
>       <Id>345678</Id>
>     </Broker>
>   </BrokerSet>
></Loan>
><Loan>
>   <BrokerSet>
>     <Broker>
>       <Name/>
>       <Id/>
>     </Broker>
>   </BrokerSet>
></Loan>
><Loan>
>   <BrokerSet>
>     <Broker>
>       <Name>LMN Broker</Name>
>       <Id>345678</Id>
>     </Broker>
>   </BrokerSet>
></Loan>
><Loan>
>   <BrokerSet>
>     <Broker>
>       <Name>ABC Broker</Name>
>       <Id>999999</Id>
>     </Broker>
>   </BrokerSet>
></Loan>
>
>For the xml listed above, the list box should contain the following
>values: All Brokers ABC Broker - 123456 ABC Broker - 999999 LMN Broker
>- 345678
>
>How do I fill the list box with only unique selections which consist of

>broker name/broker id combinations? How do I handle loans that do not
>have broker name or id data?
>
>Thanks,
>Katie
>
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


_________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list






_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread