Formatting rows in XSLT
Posted: Tue Oct 02, 2012 11:53 am
I have the following XML and the intended out put is a pipe delimited file.
I'm trying to create a pipe delimited file using xslt.
I'had created the xslt with the following code
So far fine. I get the header records in pipe delimited format. Now when I put the reference for Employee_Data, all records gets displayed. I tried to create template reference and it still would not work. Either it displays all the records of all employees after the header is displayed and if I change it, I dont see any results but the header.
I'm new to writing xslt's. I know im making mistake on references. If anyone could help with sample code that would be great.
Here is the output I expect
1| 5
0001|John Smith
0002|John Carter
0003|Katie Smith
Thanks
Ash
Code: Select all
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<Header Record>
<page>1</page>
<records>5</records>
</Header Record>
<Employee_Data>
<Employee>
<Empl_Reference Descriptor="John Smith">
<ID type="Employee_ID">00001</ID>
</Empl_Reference>
<Employee_Details>
<Empl_ID>00001</Empl_ID>
<First_Name>John</First_Name>
<Last_Name>Smith</Last_Name>
</Employee_Details>
</Employee>
<Employee>
<Empl_Reference Descriptor="John Carter">
<ID type="Employee_ID">00002</ID>
</Empl_Reference>
<Employee_Details>
<Empl_ID>00002</Empl_ID>
<First_Name>John</First_Name>
<Last_Name>Carter</Last_Name>
</Employee_Details>
</Employee>
<Employee>
<Empl_Reference Descriptor="Katie Smith">
<ID type="Employee_ID">00003</ID>
</Empl_Reference>
<Employee_Details>
<Empl_ID>00003</Empl_ID>
<First_Name>Katie</First_Name>
<Last_Name>Smith</Last_Name>
</Employee_Details>
</Employee>
</Employee Data>
I'had created the xslt with the following code
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:ex="http://exslt.org/dates-and-times" extension-element-prefixes="ex"
xmlns:env=http://schemas.xmlsoap.org/soap/envelope/>
<xsl:template match="/">
<xsl:value-of select="/env:Envelope/env:Body/page"/> | <xsl:value-of
select="/env:Envelope/env:Body/records"/>
I'm new to writing xslt's. I know im making mistake on references. If anyone could help with sample code that would be great.
Here is the output I expect
1| 5
0001|John Smith
0002|John Carter
0003|Katie Smith
Thanks
Ash