Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 13th, 2008, 09:12 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to concatenate values in a loop

Once i get a sub-nodes count, i need to loop through the subnodes and concatenate the values of an attribute.

How can this be done?I was trying to use <xsl:choose> element for looping and then trying to concatenate.

Can anyone suggest me a method on how to assign different values to a variable

Reply With Quote
  #2 (permalink)  
Old February 13th, 2008, 09:19 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You can't do this kind of iterative concatenation in XSLT.

If you explain your input XML and your expected output a little then we can likely suggest a way around the problem using recursion.

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old February 13th, 2008, 09:36 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have put the xml file at the end of this mail.

The code that reads is
Code:
<xsl:template match="Invoice" mode="Leo">
    <xsl:variable name="invoice" select="."/>
    <table border="0" width="100%">
        <tr>
            <b>REMARKS:</b>
        </tr>
        <tr>
            <b>The Origin Conferring Process for These Goods were performed at the Following Manufacture(s):</b>
        </tr>

        <xsl:for-each select="./InvoiceHeader/InvoiceSiteSet/InvoiceSite[@SiteType='FACTORY_ADDRESS']">
        <tr>
            <td width="10%"><b>Name:</b></td>
            <td><xsl:value-of select="@SiteName"/></td>
        </tr>
        <tr>
            <td><b>Address:</b></td><td><xsl:value-of select="concat(./Address/@Line1,',',./Address/@City,',',./Address/@PostalCode,',',./Address/@Country)"/>
            </td>
        </tr>

        <tr>
            <td><b>Lot#(s):</b></td>
            <td>        
                <xsl:value-of select="count($invoice/InvoiceDetail/InvoiceLineSet/InvoiceLine[@Attribute11 = current()/@SiteId]/@Attribute1)"/>[Here for one of the subnodes i would be getting a count as 7.[b]Only when the number of records are more than 1,i need to concatenate all 7 records with comma seperated and show e.g:0309,0312,0330.The current code shows only the first record(0309) for SiteId="12502" but there are 7 values.    
            </td>
        </tr>
        </xsl:for-each>
    </table>
</xsl:template>

XML file
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Invoice.xsl"?>

<Invoice>
  <InvoiceHeader InvoiceId="10982" InvoiceNumber="700008-0010982" Revision="000" InvoiceType="COMMERCIAL INVOICE" ContractId="216126" ContractNumber="0701934" InvoiceDate="2007-12-07" InvoiceStatus="Generated" InvoiceStatusDate="2007-12-07" IsShipmentActive="True" CreationDate="2007-12-06" GenerateDate="2007-12-07" VesselName="VESSEL XML" VoyageNumber="VOYAGE XML" CountryOfOrigin="ITALY" PortOfEntry="CHARLOTTE" TermsOfSale="FOB - NYK LOGISTICS (HONG KONG) LTD. TORONTO CANADA" TermsOfPayment="OPEN ACCOUNT DOCUMENT INSTRUCTION" CurrencyCode="USD" Amount1="81813.6" Amount2="" Amount3="" TotalAmount="49424.14" Comments="FOLLOWING ITEM COULD NOT BE FOUND FROM CONTRACT PROVIDED:#xD;#xA;LOT# 0308 EYE SHADOW#xD;#xA;HTS#3304.20.0000#xD;#xA;FOB VALUE: 16.80#xD;#xA;UNIT PRICE: 16.80 X QTY: 160#xD;#xA;ENXTENDED $2688.00#xD;#xA;#xD;#xA;TOTAL AMOUNT DIFFERENCE FROM SAMPLE AND THIS INVOICE:#xD;#xA;$49424.14 + 2688.00#xD;#xA;=$52112.14 (Total Invoice AMount in Sample)" Case1Type="CARTON" Case1Count="11" Case2Type="" Case2Count="" Case3Type="" Case3Count="" CancelReason="" TermsTypeCode="" TermsDescription="" TermsBasisDateCode="" TermsDiscountPercent="" TermsDiscountDueDate="" TermsDiscountDaysDue="" TermsNetDueDate="" TermsDiscountAmount="" TermsNetDaysDue="" TermsDiscountBasisAmount="" TermsTotalDiscountAmount="" TermsNetAmountAfterDiscount="" AdjustedSacHeaderAmount="" AdjustedSacTotalAmount="" FreightTermsCode="" FobCode="" GroupKey="" VersionNumber="3.0" Attribute2="COSMETICS" Attribute3="453" Attribute4="RT" Attribute5="487821" Attribute6="15-MAR-2007" Attribute7="9484-7" Attribute8="DAJCPC" Attribute9="PLI THROUGH SELLER" Attribute10="ADA0000510, ADA0000511, ADA0000512, ADA0000513, ADING00101" Attribute11="32389.46" Attribute12="2.0" Attribute13="N" Attribute14="MVAN3" Attribute15="FOB" Attribute16="CHARLOTTE">
    <InvoiceSiteSet Count="7">
      <InvoiceSite SiteId="12499" SiteName="JCPENNY PURCHASING CORPORATION" CustomerSiteCode="JCP" SiteType="BUYER_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12499" Name="JCPENNY PURCHASING CORPORATION" Line1="5401 LEGACY DRIVE, " Line2="" Line3="" Line4="" City="PLANO" PostalCode="75024-3698" County="" State="TX" Province="" Country="USA" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12500" SiteName="CARGO COSMETICS" CustomerSiteCode="EXT-3471" SiteType="VENDOR_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12500" Name="CARGO COSMETICS" Line1="120-1440 DON MILLS ROAD" Line2="" Line3="" Line4="" City="TORONTO" PostalCode="M3B 3M1" County="" State="ON" Province="" Country="CANADA" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="508-555-4444" Fax="" Email="" Name=" XML DUMMY SUPPLIER" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12501" SiteName="INTERCOS SPA" CustomerSiteCode="EXT-20813" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12501" Name="INTERCOS SPA" Line1="VIA S TECLA" Line2="" Line3="" Line4="" City="MILANO ITALY" PostalCode="3-20122" County="" State="" Province="" Country="ITALY" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12502" SiteName="NK COSMETICS" CustomerSiteCode="EXT-20814" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12502" Name="NK COSMETICS" Line1="22 MELANIE DRIVE" Line2="UNITS 8 &amp; 9" Line3="BRAMPTON" Line4="" City="ONTARIO CANADA" PostalCode="L6T4K9" County="" State="" Province="" Country="CANADA" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12503" SiteName="CLAMAR COSMETICS INC" CustomerSiteCode="EXT-20815" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12503" Name="CLAMAR COSMETICS INC" Line1="1060 SALK ROAD UNIT 4 &amp; 5" Line2="" Line3="PICKERING" Line4="" City="ONTARIO CANADA" PostalCode="L1W3X9" County="" State="" Province="" Country="CANADA" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12504" SiteName="OXYGEN DEVELOPMENT" CustomerSiteCode="EXT-20816" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12504" Name="OXYGEN DEVELOPMENT" Line1="1441 WEST NEWPORT CENTER DRIVE" Line2="" Line3="" Line4="" City="DEERFIELD BEACH" PostalCode="33442" County="" State="FL" Province="" Country="U.S.A." />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
      <InvoiceSite SiteId="12505" SiteName="SCHWAN STABILO COSMETICS" CustomerSiteCode="EXT-20817" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
        <Address AddressId="12505" Name="SCHWAN STABILO COSMETICS" Line1="PRUMYSLOVA" Line2="SCHWANGWEG 1" Line3="CESKY PRUMLOV" Line4="" City="CZECH REPUBLIC" PostalCode="76-CZ38101" County="" State="" Province="" Country="CZECH REPUBLIC" />
        <InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
      </InvoiceSite>
    </InvoiceSiteSet>
    <SacSet Count="2">
      <Sac SacId="7315" DocumentId="10982" PoId="216126" LineId="" SacType="INV" Description="PLI from contract" RecordNumber="PLI" OrderSequence="1" Indicator="N" TypeCode="PLI" Amount="0" Percent="0" PercentQualifier="" Rate="" Quantity="" QuantityUOM="" HandlingCode="" CanRemove="False" CanEdit="False" />
      <Sac SacId="7355" DocumentId="10982" PoId="216126" LineId="" SacType="INV" Description="OTHER DEDUCTION" RecordNumber="" OrderSequence="" Indicator="N" TypeCode="OTHER" Amount="32389.46" Percent="" PercentQualifier="" Rate="" Quantity="" QuantityUOM="" HandlingCode="" CanRemove="True" CanEdit="True" />
    </SacSet>
  </InvoiceHeader>
  <InvoiceDetail>
    <InvoiceLineSet Count="11">
      <InvoiceLine InvoiceLineId="17725" ItemType="LINE" LineId="" OrderSequence="1" Key1="PICKPACK-0302.01.100000412708.03120731" ItemDescription="LIQUID FOUNDATION" Quantity="1428" QuantityUOM="EA" UnitPrice="16.8" Amount1="23990.4" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0302" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="IT" Attribute9="RT" Attribute11="12501" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIQUID FOUNDATION#xA;HTS #:3304.99.5000#xA;ORIGIN:ITALY#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17726" ItemType="LINE" LineId="" OrderSequence="2" Key1="PICKPACK-0309.01.100000412708.03120731" ItemDescription="EYE SHADOW" Quantity="480" QuantityUOM="EA" UnitPrice="9.6" Amount1="4608" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0309" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="9.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYE SHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17727" ItemType="LINE" LineId="" OrderSequence="3" Key1="PICKPACK-0311.01.100000412708.03120731" ItemDescription="GLITTER" Quantity="160" QuantityUOM="EA" UnitPrice="15" Amount1="2400" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0311" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12503" Attribute12="15" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="GLITTER#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17728" ItemType="LINE" LineId="" OrderSequence="4" Key1="PICKPACK-0312.01.100000412708.03120731" ItemDescription="LIPSTICK" Quantity="1521" QuantityUOM="EA" UnitPrice="12" Amount1="18252" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0312" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="12" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIPSTICK#xA;HTS #:3304.10.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17729" ItemType="LINE" LineId="" OrderSequence="5" Key1="PICKPACK-0314.01.100000412708.03120731" ItemDescription="BLUSH" Quantity="160" QuantityUOM="EA" UnitPrice="15.6" Amount1="2496" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0314" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="US" Attribute9="RT" Attribute11="12504" Attribute12="15.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="BLUSH#xA;HTS #:9801.00.1097#xA;ORIGIN:U.S.A.#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17730" ItemType="LINE" LineId="" OrderSequence="6" Key1="PICKPACK-0320.01.100000412708.03120731" ItemDescription="LIP PENCIL" Quantity="160" QuantityUOM="EA" UnitPrice="8.4" Amount1="1344" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0320" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CZ" Attribute9="RT" Attribute11="12505" Attribute12="8.4" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIP PENCIL#xA;HTS #:3304.10.0000#xA;ORIGIN:CZECH REPUBLIC#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17731" ItemType="LINE" LineId="" OrderSequence="7" Key1="PICKPACK-0330.01.100000412708.03120731" ItemDescription="LIP GLOSS" Quantity="840" QuantityUOM="EA" UnitPrice="9.6" Amount1="8064" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0330" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="9.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIP GLOSS#xA;HTS #:3304.10.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17732" ItemType="LINE" LineId="" OrderSequence="8" Key1="PICKPACK-0331.01.100000412708.03120731" ItemDescription="EYESHADOW" Quantity="320" QuantityUOM="EA" UnitPrice="16.8" Amount1="5376" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0331" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYESHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17733" ItemType="LINE" LineId="" OrderSequence="9" Key1="PICKPACK-0332.01.100000412708.03120731" ItemDescription="SUEDE BLUSH" Quantity="288" QuantityUOM="EA" UnitPrice="14.4" Amount1="4147.2" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0332" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="14.4" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="SUEDE BLUSH#xA;HTS #:3304.91.0010#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17734" ItemType="LINE" LineId="" OrderSequence="10" Key1="PICKPACK-0333.01.100000412708.03120731" ItemDescription="EYESHADOW" Quantity="480" QuantityUOM="EA" UnitPrice="16.8" Amount1="8064" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0333" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYESHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
      <InvoiceLine InvoiceLineId="17735" ItemType="LINE" LineId="" OrderSequence="11" Key1="PICKPACK-0335.01.100000412708.03120731" ItemDescription="BRONZING POWDER" Quantity="160" QuantityUOM="EA" UnitPrice="19.2" Amount1="3072" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0335" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="19.2" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="BRONZING POWDER#xA;HTS #:3304.91.0050#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
    </InvoiceLineSet>
  </InvoiceDetail>
</Invoice>
Reply With Quote
  #4 (permalink)  
Old February 13th, 2008, 09:54 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Please try not to include really long lines of XML inside code elements, it really screws with my window and I find entering replies a real pain in the neck.

Define the following template (or something similar):

Code:
<xsl:template name="recurse">
    <xsl:param name="elements"/>

    <xsl:variable name="first" select="$elements[1]"/>
    <xsl:variable name="rest" select="$elements[position()!=1]"/>

    <xsl:choose>
        <xsl:when test="empty($rest)">
            <xsl:value-of select="$first"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$first"/>
            <xsl:text>,</xsl:text>
            <xsl:call-template name="recurse">
                <xsl:with-param name="elements" select="$rest"/>
            </xsl:call-template>
        </xsl:otherwise>
    </xsl:choose>    
</xsl:template>
And then call it like this:

Code:
<xsl:call-template name="recurse">
  <xsl:with-param name="elements" select="$invoice/InvoiceDetail/InvoiceLineSet/InvoiceLine[@Attribute11 = current()/@SiteId]/@Attribute1"/>
</xsl:call-template>
/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #5 (permalink)  
Old February 13th, 2008, 10:43 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

Given a set of elements in $elements, in XSLT 2.0 you can do

<xsl:value-of select="$elements" separator=","/>

In 1.0 the usual solution is

<xsl:for-each select="$elements">
  <xsl:value-of select="."/>
  <xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old February 14th, 2008, 08:52 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much to you both.

Reply With Quote
  #7 (permalink)  
Old February 14th, 2008, 09:03 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Typical - I always pick the most complicated way of doing things... well at least now you've seen how to do recursion :)

/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to concatenate two values into one field haixia XSLT 3 November 7th, 2016 02:33 PM
for-each loop and blank values Navy1991_1 XSLT 3 June 6th, 2008 09:24 AM
How to loop for Select Values rohit_ghosh Excel VBA 3 May 8th, 2007 04:29 PM
Need help in retrieving values from a loop ! back2grave XSLT 0 June 27th, 2006 06:29 PM
loop values and text box values move mateenmohd Classic ASP Basics 2 April 6th, 2005 12:33 AM



All times are GMT -4. The time now is 07:49 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.