1

I am trying to link our Magento website with Sage 50 with a piece of software.

We would like the customers first name and last name to go into the company field.

Below are the 3 lines I assume I have to tweak:

   <Forename><xsl:value-of select="billing_address/firstname"/></Forename>
    <Surname><xsl:value-of select="billing_address/lastname"/></Surname>
    <Company><xsl:value-of select="billing_address/company"/></Company>

How do I combine first name and last name in 1 line? looking for something like:

    <Company><xsl:value-of select="billing_address/firstname, billing_address/lastname"/></Company>
kcrisman
  • 4,374
  • 20
  • 41

3 Answers3

1

You really need to tell us which version of XSLT you are using. Your proposed code

<xsl:value-of select="billing_address/firstname, billing_address/lastname"/>

is fine in 2.0, and you can get the comma by adding the attribute separator=", "/>. But this won't work in 1.0, where xsl:value-of will only output the first item if you give it a sequence.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

You can give

    <Company><xsl:value-of select="concat(billing_address/firstname,', ', billing_address/lastname)"/></Company>

a try...

leu
  • 2,051
  • 2
  • 12
  • 25
0

First of all, whitespace-only text nodes are ignored by the XSLT engine, so what you tried above can be rewritten like the following:

<Company>
   <xsl:value-of select="billing_address/firstname, billing_address/lastname"/>
</Company>

Second, you have to understand that xsl:value-of generates a text node. The following will generate 2 text nodes, with resp. the first and last names:

<Company>
   <xsl:value-of select="billing_address/firstname"/>
   <xsl:value-of select="billing_address/lastname"/>
</Company>

Then if I understand correctly, you want to seperate both with the string ", ". You can use xsl:text to generate a fixed-content text node:

<Company>
   <xsl:value-of select="billing_address/firstname"/>
   <xsl:text>, </xsl:text>
   <xsl:value-of select="billing_address/lastname"/>
</Company>

In the above, you can put the ", " directly between both value-of, but then you can't control the indentation. Usuaully, when I generate fixed text, I always use xsl:text.

Florent Georges
  • 2,190
  • 1
  • 15
  • 24