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

RE: Concat values

Subject: RE: Concat values
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 12 Apr 2004 18:31:51 +0200
xsl concat
> -----Original Message-----
> From: James Paul [mailto:jpaul@xxxxxxxxxxx]
>
> What I am trying to do is based on a value $attrName I need to check
> every line item to see if this value exist in that Line Item.  If it
> does exist for a particular line item I need to get the value of the
> line item and pass it back and concatenate it with a | under a
> particular attribute.
>

Hi,

The reason why it's not working (I guess) is this:
>             <xsl:variable name="LineItem">
<snip />
>                 <xsl:apply-templates
> select="RequestQuoteItemDetail/BaseItemDetail/ListOfItemReferences/ListO
> fReferenceCoded/ReferenceCoded" mode="BidLineItems">
<snip />
>             </xsl:variable>
>

This will make the LineItem variable of type Result Tree Fragment, instead
of nodeset.
On top of that, even if it were a nodeset, the following expression
> select="concat($LineItem,'|')" />

will return you the string value of the first node in the set followed by a
'|', not repeat the steps for all nodes in the LineItem nodeset.

So, to get you closer to a solution, be sure to convert the variable into a
nodeset if you're going to apply-templates to it (or perform other
operations on it than simply copying it to your result tree). Use the
node-set() extension function for that (either the processor-specific or
EXSLT's).

Shorthand pseudocode:

<xsl:stylesheet ..
  xmlns:ext="http://exslt.org/common"
  exclude-result-prefixes="ext">
..
<xsl:variable name="LineItem">
  <xsl:apply-templates select="/{full-path}/ReferenceCoded"
                       mode="BidLineItem" />
</xsl:variable>
..
<!-- LineItem is of type RTREEFRAG, so convert first -->
<xsl:variable name="nsLineItem" select="ext:node-set($LineItem)" />

I would also change the BidLineItem-moded template to construct a temporary
tree like:

<xsl:template match="ReferenceCoded" mode="BidLineItems">
  <xsl:param name="fieldName"/>
  <xsl:if test="ReferenceTypeCodedOther='QuestBidExtendedAttribute'">
    <xsl:if test="PrimaryReference/Reference/RefNum=$fieldName">
      <val>
        <xsl:value-of select="SupportingReference/Reference/RefNum"/>
      </val>
    </xsl:if>
  </xsl:if>
</xsl:template>

Then you can do something like the following to construct your attribute:

<xsl:attribute name="ExtAttDefObjLink">
  <xsl:for-each select="$nsLineItem/val">
    <xsl:choose>
      <xsl:when test="not( position() = last() )">
        <xsl:value-of select="concat(.,'|')" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="." />
      </xsl:otherwise>
  </xsl:for-each>
</xsl:attribute>


Hope this helps!

Cheers,

Andreas

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.