Subject: RE: Concat values
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 12 Apr 2004 18:31:51 +0200
|
> -----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
|