Peter,
Thanks for the reply. Sorry for the response to your personal e-mail, it was
a mistake. 8-{
> First of all, you should use <xsl:choose> instead of two <xsl:if>'s here
(not
> really a problem, but it looks prettier and is more efficient):
>
> <xsl:variable name="sa">
> <xsl:choose>
> <xsl:when test="not(string(sales_agent))">NULL</xsl:when>
> <xsl:otherwise><xsl:value-of select="sales_agent"/></xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
>
Hmm, does look cleaner. I do so.
> I'm not sure what the problem is. You just do:
>
> <xsl:value-of select="$sa"/>
>
> Or, if you want to use it as the value of an element's attribute, do
> something like
>
> <theElement someAttribute="{$sa}">...</theElement>
The ideia is not to use the variable as an attribute but as an elements'
text, for example
I wanted something like this
<A>"{$sa}"</A>
where $a="xpto"
to result in <A>xpto</A>
I finally solved this by using a template that uses a parameter, for
example:
<xsl:template name="text-block">
<xsl:param name="field"></xsl:param>
<xsl:if test="not(string($field))">NULL</xsl:if>
<xsl:if test="string($field)"><xsl:value-of select="$field"/></xsl:if>
</xsl:template>
called in the following manner
<xsl:call-template name="text-block"><xsl:with-param
name="field">"<xsl:value-of
select="segment"/>")</xsl:with-param></xsl:call-template>
which results in either NULL or "value of the node(segment)"
> >
> > BTW, can anyone point me to a mailing list were such questions may be
> > answered?
>
> xsl-list seems to be the most popular, and you can usually get your
questions
> answered within an hour or less. Lots of smart people hang out there,
> including a lot of the people who are actually responsible for XSLT. Go
to
> http://www.mulberrytech.com/xsl/xsl-list/subscribe-unsubscribe.html
>
Great. Thanks for the pointer.
Thanks
Hugo.