Link to home
Start Free TrialLog in
Avatar of Mani Pazhana
Mani PazhanaFlag for United States of America

asked on

XSLT - Attributes not getting data

XSLT - Attributes not getting data...

Here is my Input XML:

<Remittance xmlns="http://integration.cbre.com/schemas/gcs/remittance/v1">
  <ClientId>HTZ</ClientId>
  <PaymentId>157376</PaymentId>
  <PayeeId>100296</PayeeId>
  <PayeeDescription>"A&amp;A MAINTENANCE ENTERPRISE INC"</PayeeDescription>
  <PaymentDate>2006-01-04T00:00:00</PaymentDate>
  <PaymentNumber>35653</PaymentNumber>
  <PaymentMethodCode>PK</PaymentMethodCode>
  <PaymentMethodDescription>C</PaymentMethodDescription>
  <TotalPaymentAmount>-10705.35</TotalPaymentAmount>
  <CurrencyCode>USD</CurrencyCode>
  <IsVoid>0</IsVoid>
  <PaymentDetails>
    <PaymentDetail>
      <PaymentLineNumber>1</PaymentLineNumber>
      <OriginatingInvoiceNumber>43538</OriginatingInvoiceNumber>
      <OriginatingInvoiceLineNumber>001</OriginatingInvoiceLineNumber>
      <InvoiceDate>2005-12-01T00:00:00</InvoiceDate>
      <PONumber></PONumber>
      <POLineNumber>0.0</POLineNumber>
      <DocumentType>PV</DocumentType>
      <DocumentCompany>00100</DocumentCompany>
      <DocumentNumber>138181</DocumentNumber>
      <PaymentAmount>-10705.35</PaymentAmount>
      <Remark>"DECEMBER JANITORIAL CONTRACT "</Remark>
      <GLAccount>
        <CompanyId>00100</CompanyId>
        <GLAccountCode>50200 </GLAccountCode>
        <Subsidiary></Subsidiary>
        <SubLedger>1056</SubLedger>
        <SubLedgerType>C</SubLedgerType>
        <CostCenter>560090-06</CostCenter>
        <AccountBlock>.50200</AccountBlock>
        <GLAccountDescription>"Contract Cleaning Service"</GLAccountDescription>
        <ClientAccountCode>6628</ClientAccountCode>
      </GLAccount>
      <AdditionalCoding>
        <WBSCode></WBSCode>
        <OriginatingProjectNumber></OriginatingProjectNumber>
        <OriginatingProjectSystem></OriginatingProjectSystem>
        <ClientPONumber></ClientPONumber>
        <WorkOrderNumber>444343</WorkOrderNumber>
        <WorkOrderCompletedDate></WorkOrderCompletedDate>
        <WorkOrderCreatedDate></WorkOrderCreatedDate>
        <CodingBlock1></CodingBlock1>
        <CodingBlock2></CodingBlock2>
        <CodingBlock3></CodingBlock3>
        <CodingBlock4></CodingBlock4>
        <CodingBlock5></CodingBlock5>
        <CodingBlock6></CodingBlock6>
        <CodingDate1></CodingDate1>
        <CodingDate2></CodingDate2>
      </AdditionalCoding>
    </PaymentDetail>
  </PaymentDetails>
</Remittance>

-------------------------------------

XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://corrigo.com/wonpay.xsd">

            
      <xsl:output method="xml" indent="yes" />
      
      <!-- ITP is expecting multiple rows to be wrapped with batch -->
      <xsl:template match="/">
 
            <!-- Create new root -->
            <root>
                  <!-- Copy all children of the root node. -->
                  <WONPAY>
                        
                        <xsl:attribute name="WorkOrderNumber">
                              <xsl:value-of select="Remittance/PaymentDetails/PaymentDetail/AdditionalCoding/WorkOrderNumber" />
                        </xsl:attribute>

        <xsl:attribute name="AmountPaid">
          <xsl:value-of select="Remittance/PaymentDetails/PaymentDetail/PaymentAmount" />
        </xsl:attribute>

        <xsl:attribute name="CheckNumber">
          <xsl:value-of select="Remittance/PaymentNumber" />
        </xsl:attribute>

        <xsl:attribute name="PaidDate">
          <xsl:value-of select="Remittance/PaymentDate" />
        </xsl:attribute>      
       
                  </WONPAY>
            </root>
      </xsl:template>
 
</xsl:stylesheet>


-------------------------------

My output:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://corrigo.com/wonpay.xsd">
  <WONPAY WorkOrderNumber="" AmountPaid="" CheckNumber="" PaidDate="" />
</root>

-----------------------------

in my ouptu i am not seeing data in the attributes...


any idea?

Thanks
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

you need to bind the default namespace of the input to a prefix
xmlns:won="http://corrigo.com/wonpay.xsd"
in the xsl:stylesheet element

and use that prefix in all of the XPath expressions

<xsl:value-of select="won:Remittance/won:PaymentDetails/won:PaymentDetail/won:AdditionalCoding/won:WorkOrderNumber" />
Avatar of Mani Pazhana

ASKER

Thanks...still missing something..data is not showing up..

---------------------------------

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                        xmlns:won="http://corrigo.com/wonpay.xsd">
      
      
      <xsl:output method="xml" indent="yes" />
      
      <!-- ITP is expecting multiple rows to be wrapped with batch -->
      <xsl:template match="/">
 
            <!-- Create new root -->
            <root>
                  <!-- Copy all children of the root node. -->
                  <WONPAY>
                        
                        <xsl:attribute name="WorkOrderNumber">
                              <xsl:value-of select="won:PaymentDetails/won:PaymentDetail/won:AdditionalCoding/won:WorkOrderNumber" />
                        </xsl:attribute>

        <xsl:attribute name="AmountPaid">
          <xsl:value-of select="won:Remittance/won:PaymentDetails/won:PaymentDetail/won:PaymentAmount" />
        </xsl:attribute>

        <xsl:attribute name="CheckNumber">
          <xsl:value-of select="won:Remittance/won:PaymentNumber" />
        </xsl:attribute>

        <xsl:attribute name="PaidDate">
          <xsl:value-of select="won:Remittance/won:PaymentDate" />
        </xsl:attribute>      
       
                  </WONPAY>
            </root>
      </xsl:template>
 
</xsl:stylesheet>
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It worked. Thanks
https://www.experts-exchange.com/questions/28214261/XSLT-Generate-CSV-file-with-CSV-extension.html

Although i accepted the answer... i want your feedback to this question...

Thanks
If there is a problem with z2c's advise, you need to post there.
I do not interfere in closed questions, it just confuses the database and it seems as if I want to unnecessarily correct a different expert... that is a policy issue.
I see things in the XSLT I don't necessarily like. But the advice about renaming seems correct
Thanks