How can I get the value of Header
main element, "AMEX,AMEX"?
Below is my xml which contains header and the value AMEX,AMEX. I want to fetch the "AMEX,AMEX" value to display it in xsl:fo table cell.
xml
<Documents>
<Document>
<PackingNote>
<Header>AMEX, AMEX<CustomerDetail>Adeel/000004</CustomerDetail><Despatchdate>09/05/2019</Despatchdate><OrderNumber>000534</OrderNumber><OrderNumberBatch>000534-1</OrderNumberBatch></Header>
<Header>AMEX, AMEX<CustomerDetail>Adeel/000004</CustomerDetail><Despatchdate>09/05/2019</Despatchdate><OrderNumber>000534</OrderNumber><OrderNumberBatch>000534-2</OrderNumberBatch></Header>
<Lines>
<Line>
<ProductName>Kid-Sweater-Winter Aqua</ProductName>
<Quantity>1.00</Quantity>
<Price>£15.00</Price>
<Size>Small/Slim Fit</Size>
<ReasonCode />
<ReturnQty />
<Fit>Fit </Fit>
</Line>
</Lines>
<PackedBy>
<SubTotal>£30</SubTotal>
<Shipping>£2.00</Shipping>
<Total>£32</Total>
</PackedBy>
</PackingNote>
</Document>
</Documents>
xslt
<xsl:template match="Header">
<!-- Title -->
<fo:table table-width="27.5cm" table-height="2cm">
<fo:table-column column-width="5.5cm" />
<fo:table-column column-width="3.5cm" />
<fo:table-column column-width="14.5cm" />
<fo:table-column column-width="4cm" />
<fo:table-body>
<fo:table-row border-width="0mm">
<fo:table-cell>
<fo:table table-layout="fixed">
<fo:table-column column-width="5cm" />
<fo:table-body>
<fo:table-row />
</fo:table-body>
</fo:table>
</fo:table-cell>
<fo:table-cell>
<fo:table table-layout="fixed" padding-top="1.2cm">
<fo:table-column column-width="3.5cm" />
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="center" padding-top="0.3cm">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="0mm">
<fo:table table-layout="auto" font-family="Calibri" table-width="14.5cm">
<fo:table-column column-width="5.1cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.5cm" />
<fo:table-column column-width="2.8cm" />
<fo:table-header text-align="left" border-width="0mm">
<fo:table-row height="2em" border="inherit" background-color="#D9D9D9" font-family="Arial">
<fo:table-cell padding="1mm" padding-left="0.2cm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="left" >
<fo:inline>Customer Name/No</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="left" >
<fo:inline>Payment Method</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="center" >
<fo:inline>Despatch Date</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="1mm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="center" >
<fo:inline>Order No.</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row border-width="4px" border-style="solid" height="2em" font-family="Segoe UI">
<fo:table-cell padding-bottom="0.5mm" padding-left="0.2cm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="left">
<xsl:value-of select="CustomerDetail" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding-left="0.1cm" padding-bottom="0.5mm" padding-right="0.5cm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="left">
<xsl:value-of select="Header" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding-left="0.8mm" padding-bottom="0.5mm" padding-right="0.5cm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="center">
<xsl:value-of select="Despatchdate" />
</fo:block>
</fo:table-cell>
<fo:table-cell padding-left="0.1cm" padding-bottom="0.5mm" padding-right="0.5cm" border-width="1px" border-style="solid">
<fo:block font-size="11pt" text-align="center">
<xsl:value-of select="OrderNumber" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
<fo:table-cell padding="1mm">
<fo:table table-layout="fixed">
<fo:table-column column-width="4cm" />
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="center" padding-top="0.3cm">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
desired output
first header value 'AMEX,AMEX'
i want to fetch the value of AMEX,AMEX using xslt
XSLT is a transformation language. It takes one XML document and produces another. It uses XPath to select values and Michael posted the snippet that will select the values you want. What do you want as the output though? – Panagiotis Kanavosdesired output
you posted is what Michael's answer provides. And yet you said there that you want<Payment>AMEX, AMEX</Payment>
, not justAMEX, AMEX
– Panagiotis Kanavos