Hi,
I have a pricelist exported to XML which I now want to convert into a CSV file. Unfortunately, a few of my suppliers format their pricelists in a non-standard manner making a direct export to CSV non-feasible.
I am constructing an XSL file for each such supplier to pick the meaningful values I need and write to a CSV file. Here is what I have so far:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
SupplierProductId,CostPric
e,Summary
<xsl:template match="//Worksheet[normali
ze-space(@
ss:Name)='
AMD Boards']/Row">
****what goes here?****
</xsl:template>
</xsl:stylesheet>
As you can see I haven't got very far. This is my first encounter with xsl and xpath and it seems pretty nifty.
Here is the logic I want to encapsulate:
- find the worksheet with name "AMD Boards" and find all rows in which cells b, c and e are not equal to null or the empty string - if this is the case i also need to get cell e of the following row
here is a snippet of the xml just to put all of this into context (no pun intended):
<Worksheet ss:Name=" AMD Boards">
<Table ss:ExpandedColumnCount="15
" ss:ExpandedRowCount="61" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s331" ss:DefaultRowHeight="11.25
">
<Column ss:StyleID="s331" ss:AutoFitWidth="0" ss:Width="21"/>
<Column ss:StyleID="s331" ss:AutoFitWidth="0" ss:Width="68.25"/>
<Column ss:StyleID="s607" ss:AutoFitWidth="0"/>
<Column ss:Index="5" ss:StyleID="s331" ss:AutoFitWidth="0" ss:Width="459"/>
<Column ss:Index="7" ss:StyleID="s331" ss:AutoFitWidth="0" ss:Width="360"/>
<Row ss:StyleID="s302">
<Cell ss:StyleID="s379"><Data ss:Type="String">Gigabyte-
AMD Chipset</Data></Cell>
<Cell ss:StyleID="s332"><Data ss:Type="String">GIGABYTE MOTHERBOARDS - AMD CHIPSET - 3 YEAR FULL WARRANTY</Data></Cell>
<Cell ss:StyleID="s593"/>
<Cell ss:StyleID="s333"/>
<Cell ss:StyleID="s334"/>
<Cell ss:StyleID="s335"/>
<Cell ss:StyleID="s335"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s309"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
</Row>
<Row ss:StyleID="s302">
<Cell ss:StyleID="s336"/>
<Cell ss:StyleID="s337"/>
<Cell ss:StyleID="s594"/>
<Cell ss:StyleID="s338"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s309"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
</Row>
<Row ss:StyleID="s302">
<Cell ss:StyleID="s336"/>
<Cell ss:StyleID="s337"/>
<Cell ss:StyleID="s594"/>
<Cell ss:StyleID="s338"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s309"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="2.25" ss:StyleID="s302">
<Cell ss:StyleID="s336"/>
<Cell ss:StyleID="s337"/>
<Cell ss:StyleID="s594"/>
<Cell ss:StyleID="s338"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s328"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s309"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
</Row>
<Row ss:StyleID="s306">
<Cell ss:StyleID="s344"><ss:Data
ss:Type="String"
xmlns="
http://www.w3.org/TR/REC-html40"><B><I>
<U><Font html:Color="#800080">AMD </Font><Font
html:Color="#0000FF">Socke
t A</Font><Font html:Color="#800080"> Platform: Integrated and Discrete</Font></U></I></B
></ss:Data
></Cell>
<Cell ss:StyleID="s356"/>
<Cell ss:StyleID="s595"/>
<Cell ss:StyleID="s357"/>
<Cell ss:StyleID="s358"/>
<Cell ss:Index="7" ss:StyleID="s307"/>
<Cell ss:StyleID="s307"/>
<Cell ss:StyleID="s308"><Data ss:Type="String"> </Data></Cell>
</Row>
<Row ss:StyleID="s302"> ****This is the first row that needs to be checked for the above logic ****
<Cell ss:Index="2" ss:StyleID="s314"><Data ss:Type="String">7VT600P-R
Z</Data></
Cell>
<Cell ss:StyleID="s596"><Data ss:Type="Number">69</Data>
</Cell>
<Cell ss:StyleID="s339"><Data ss:Type="String">DDR400</D
ata></Cell
>
<Cell ss:StyleID="s319"><ss:Data
ss:Type="String"
xmlns="
http://www.w3.org/TR/REC-html40"><B><Fo
nt html:Color="#0000FF">GIGAB
YTE® </Font></B><Font>VIA-KT600
+8237 </Font><B><U><Font
html:Color="#FF0000">AMD K7 FSB400 integrated MB</Font></U></B><Font
html:Color="#FF0000"> </Font><Font>-,AC97-6CH sound, VIA6103L 10/100Lan </Font></ss:Data></Cell>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s304"/>
<Cell ss:StyleID="s304"/>
<Cell ss:StyleID="s313"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
<Cell ss:StyleID="s301"/>
</Row>
<Row ss:Height="12" ss:StyleID="s302">
<Cell ss:Index="2" ss:StyleID="s371"/>
<Cell ss:StyleID="s393"/>
<Cell ss:StyleID="s375"/>
<Cell ss:StyleID="s359"><Data ss:Type="String">1 x AGP(8x), 3 x DDR400,2x ATA133 + 2 x PATA,5 x PCI, 6 x USB 1.1 (4 by cables), Raid, ATC Form Factor</Data></Cell>
***The value in the preceding <cell> tag should really be in the corresponding cell in the preceding row****
<Cell ss:StyleID="s359"/>
<Cell ss:StyleID="s362"/>
<Cell ss:StyleID="s362"/>
<Cell ss:StyleID="s376"/>
<Cell ss:StyleID="s359"><Data ss:Type="String"> </Data></Cell>
<Cell ss:StyleID="s359"/>
<Cell ss:StyleID="s359"/>
<Cell ss:StyleID="s359"/>
<Cell ss:StyleID="s359"/>
<Cell ss:StyleID="s359"/>
</Row>
I have commented some sections so you can see what I am talking about...
In any case, if you can help with this problem I will be very grateful.