XSLT - Concat fields

i am getting some error when i do concat:

 <common:AddressLine1>
                  <xsl:apply-templates select="concat(inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName, '  ' ,  inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName)" />
                </common:AddressLine1>


Error:

error: Expression must evaluate to a node-set.
 -->concat(inv:Invoi.../cbc:StreetName)<--

any idea?

Thanks
LVL 8
mani_saiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mani_saiAuthor Commented:
Here is my full XSLT:

<?xml version="1.0" encoding="utf-8"?>
     
      <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:tdp="http://tradeshift.com/api/public/1.0"
          xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
          xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
          xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
          xmlns:td="http://tradeshift.com/api/1.0"
          xmlns:appresp="urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"
          xmlns:ordchg="urn:oasis:names:specification:ubl:schema:xsd:OrderChange-2"
          xmlns:inv="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
          xmlns:quo="urn:oasis:names:specification:ubl:schema:xsd:Quotation-2"
          xmlns:crdnte="urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
          xmlns:ord="urn:oasis:names:specification:ubl:schema:xsd:Order-2"
          xmlns:remind="urn:oasis:names:specification:ubl:schema:xsd:Reminder-2"
          xmlns:rmtadv="urn:oasis:names:specification:ubl:schema:xsd:RemittanceAdvice-2"
          xmlns:rcptadv="urn:oasis:names:specification:ubl:schema:xsd:ReceiptAdvice-2"
          xmlns:ordcan="urn:oasis:names:specification:ubl:schema:xsd:OrderCancellation-2"
          xmlns:reqforquot="urn:oasis:names:specification:ubl:schema:xsd:RequestForQuotation-2"
          xmlns:ordrespsim="urn:oasis:names:specification:ubl:schema:xsd:OrderResponseSimple-2"          
          xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0" >

        <xsl:output method="xml" indent="yes"/>

        <xsl:template match="/">
          <Invoice>
           
            <ClientId>CEC01</ClientId>                        
                       
            <OriginatingInvoiceId>???</OriginatingInvoiceId>

            <BuyerCustomerParty>
              <BuyerId>
                <xsl:apply-templates select="inv:Invoice/cbc:ID"/>
              </BuyerId>
              <BuyerCustomerExternalId>
                <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID"/>
              </BuyerCustomerExternalId>
              <BuyerCustomerExternalReferenceType>
                <xsl:apply-templates select="Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID/@schemeID"/>
              </BuyerCustomerExternalReferenceType>
              <BuyerName>
                <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name"/>
              </BuyerName>
              <BuyerCustomerAddress>
                <common:AddressType>
                  <xsl:apply-templates select="inv:Invoice/cbc:ID"/>
                </common:AddressType>
                <common:AddressLine1>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:StreetName"/>
                </common:AddressLine1>
                <common:City>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:CityName"/>
                </common:City>
                <common:StateProvince>
                  <common:Code>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:CountrySubentity"/>
                  </common:Code>
                  <common:Description>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:CountrySubentity"/>
                  </common:Description>
                </common:StateProvince>
                <common:ZipPostalCode>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:PostalZone"/>
                </common:ZipPostalCode>
                <common:Country>
                  <common:Code>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode"/>
                  </common:Code>
                  <common:Description>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode"/>
                  </common:Description>
                </common:Country>
              </BuyerCustomerAddress>
              <BuyerCustomerContact>
                <common:ContactName>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingCustomerParty/cac:Party/cac:Contact/cbc:Name"/>
                </common:ContactName>
              </BuyerCustomerContact>
            </BuyerCustomerParty>


            <SellerSupplierParty>
              <SellerID>
                <xsl:apply-templates select="inv:Invoice/cbc:ID"/>
              </SellerID>
              <SellerSupplierExternalId>
                <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID"/>
              </SellerSupplierExternalId>
              <SellerSupplierExternalReferenceType>
                <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID/@schemeID"/>
              </SellerSupplierExternalReferenceType>
              <SellerSupplierName>
                <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name"/>
              </SellerSupplierName>
              <SellerSupplierAddress>
                <common:AddressType>
                  <xsl:apply-templates select="inv:Invoice/cbc:ID"/>
                </common:AddressType>
                <common:AddressLine1>
                  <xsl:apply-templates select="concat(inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:BuildingNumber, '  ' ,inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName)" />
                </common:AddressLine1>
                <common:City>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:CityName"/>
                </common:City>
                <common:StateProvince>
                  <common:ZipPostalCode>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:PostalZone"/>
                  </common:ZipPostalCode>
                  <common:Code>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:CountrySubentity"/>
                  </common:Code>
                  <common:Description>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:CountrySubentity"/>
                  </common:Description>
                </common:StateProvince>
                <common:Country>
                  <common:Code>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode"/>
                  </common:Code>
                  <common:Description>
                    <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cac:Country/cbc:IdentificationCode"/>
                  </common:Description>
                </common:Country>
              </SellerSupplierAddress>
              <SellerSupplierContact>
                <common:ContactName>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:Contact/cbc:Name"/>
                </common:ContactName>
              </SellerSupplierContact>
            </SellerSupplierParty>
           
                       
            <VendorInvoiceNumber><xsl:apply-templates select="inv:Invoice/cbc:ID"/></VendorInvoiceNumber>

            <InvoiceDate><xsl:apply-templates select="inv:Invoice/cbc:IssueDate"/></InvoiceDate>

            <InvoiceReceiveDate>1900-01-01T01:01:01-06:00</InvoiceReceiveDate>

            <GLDate>1900-01-01T01:01:01-06:00</GLDate>

            <Remark><xsl:apply-templates select="inv:Invoice/cbc:Note"/></Remark>

            <TotalInvoiceAmount>
              <xsl:apply-templates select="inv:Invoice/cac:LegalMonetaryTotal/cbc:TaxInclusiveAmount"/>              
            </TotalInvoiceAmount>

            <CurrencyCode><xsl:apply-templates select="inv:Invoice/cbc:DocumentCurrencyCode"/></CurrencyCode>          

            <StatusCode>
              <common:Code>String</common:Code>
              <common:Description>String</common:Description>
            </StatusCode>

            <ClientApprovalNumber></ClientApprovalNumber>

            <AuthorizedBy></AuthorizedBy>

            <BatchReferenceNumber></BatchReferenceNumber>

            <InvoiceSource></InvoiceSource>

            <NumberOfLines>1</NumberOfLines>

            <InvoiceLineItems>

              <InvoiceLineItem>
                <OriginatingInvoiceLineID>1</OriginatingInvoiceLineID>
                <POLineNumber>1</POLineNumber>
                <LineItemDescription > <xsl:apply-templates select="inv:Invoice/cac:InvoiceLine/cac:Item/cbc:Description"/>  </LineItemDescription >
                <LocationId > <xsl:apply-templates select="inv:Invoice/cbc:AccountingCost"/> </LocationId>
                <BuildingName></BuildingName >
                <LineItemAmount>1</LineItemAmount>
                <TaxableLineItemAmount><xsl:apply-templates select="inv:Invoice/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount"/></TaxableLineItemAmount>
                <TaxAmountLineItem><xsl:apply-templates select="inv:Invoice/cac:InvoiceLine/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmoun"/></TaxAmountLineItem>
                <GLAccountCode  ></GLAccountCode  >
                <AdditionalCoding></AdditionalCoding >
              </InvoiceLineItem>            

            </InvoiceLineItems>

          </Invoice>
        </xsl:template>    

       
      </xsl:stylesheet>
0
zc2Commented:
It makes no sense to pass a string as a parameter of the select="" attribute. concat() returns a string, but the select="" expects a nodeset to apply the templates on its nodes.
0
Geert BormansInformation ArchitectCommented:
the select attribute of an apply-templates needs to be a node-set
(you have to pass nodes to the templates)
the type of a concat() is a string
you can't have strings as the select in an apply-templates...

what do you want to achieve?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Geert BormansInformation ArchitectCommented:
I actualy suspect that you want to do this

<xsl:value-of select="concat(....)"/>

value-of puts the string resulting from the XPath expression in the select attribute in the result tree
0
mani_saiAuthor Commented:
Thanks guys.

Yes Gertone.
0
mani_saiAuthor Commented:
i want to concat 2 fields and show it on one line in my output....

My input:

 <ns5:PostalAddress>
                <ns3:AddressFormatCode listID="UN/ECE 3477" listAgencyID="6" listVersionID="D08B">5</ns3:AddressFormatCode>
                <ns3:StreetName>West Street</ns3:StreetName>
                <ns3:AdditionalStreetName></ns3:AdditionalStreetName>
                <ns3:BuildingNumber>76</ns3:BuildingNumber>
                <ns3:MarkAttention></ns3:MarkAttention>
                <ns3:CityName>New York</ns3:CityName>
                <ns3:PostalZone>87873</ns3:PostalZone>
                <ns3:CountrySubentity>NY</ns3:CountrySubentity>
                <ns5:Country>
                    <ns3:IdentificationCode>US</ns3:IdentificationCode>
                </ns5:Country>
            </ns5:PostalAddress>

My output should concat both Building number and Street 1 on same line :
0
Geert BormansInformation ArchitectCommented:
<xsl:value-of select="concat(ns5:PostalAddress/ns3:BuildingNumber, ' ', ns5:PostalAddress/ns3:StreetName)"/>
0
Geert BormansInformation ArchitectCommented:
if you add a normalize-space, you would loose unnecessary spaces in case one of the two fields is empty

<xsl:value-of select="normalize-space(concat(ns5:PostalAddress/ns3:BuildingNumber, ' ', ns5:PostalAddress/ns3:StreetName))"/>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mani_saiAuthor Commented:
Thanks.

i renamed the namespaces in my XSLT...

without concat...my xpath works for single field like shown below...


   <common:AddressLine1>
                  <xsl:apply-templates select="inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:BuildingNumber" />
   </common:AddressLine1>



only when i use concat, it is not working shown below....


 <common:AddressLine1>
                  <xsl:apply-templates select="concat(inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:BuildingNumber, '  ' ,inv:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName)" />
                </common:AddressLine1>

any idea?

thanks
0
mani_saiAuthor Commented:
Got it...

Thanks.
0
Geert BormansInformation ArchitectCommented:
welcome,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.