This commit is contained in:
parent
b3069f0ee3
commit
32fa698573
|
@ -0,0 +1,90 @@
|
||||||
|
<!--XSL style sheet to convert EESCHEMA XML Partlist Format to CSV BOM Format
|
||||||
|
Copyright (C) 2013, Stefan Helmert.
|
||||||
|
GPL v2.
|
||||||
|
Functionality:
|
||||||
|
Generation of csv table with table head of all existing field names
|
||||||
|
and correct assigned cell entries
|
||||||
|
How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the
|
||||||
|
netlist exporter using a new (custom) tab in the netlist export dialog. The command is
|
||||||
|
similar to
|
||||||
|
on Windows:
|
||||||
|
xsltproc -o "%O.csv" "C:\Program Files (x86)\KiCad\bin\plugins\bom2csv.xsl" "%I"
|
||||||
|
on Linux:
|
||||||
|
xsltproc -o "%O.csv" /usr/local/lib/kicad/plugins/bom2csv.xsl "%I"
|
||||||
|
Instead of "%O.csv" you can alternatively use "%O" if you will supply your own file extension when
|
||||||
|
prompted in the UI. The double quotes are there to account for the possibility of space(s)
|
||||||
|
in the filename.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
@package
|
||||||
|
Generate a Tab delimited list (csv file type).
|
||||||
|
One component per line
|
||||||
|
Fields are
|
||||||
|
Ref,Value, Footprint, Datasheet, Field5, Field4, price
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE xsl:stylesheet [
|
||||||
|
<!ENTITY nl "
"> <!--new line CR, LF, or LF, your choice -->
|
||||||
|
]>
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||||
|
<xsl:output method="text"/>
|
||||||
|
|
||||||
|
<!-- for table head and empty table fields-->
|
||||||
|
<xsl:key name="headentr" match="field" use="@name"/>
|
||||||
|
|
||||||
|
<!-- main part -->
|
||||||
|
<xsl:template match="/export">
|
||||||
|
<xsl:text>Reference, Value, Footprint, Datasheet</xsl:text>
|
||||||
|
|
||||||
|
<!-- find all existing table head entries and list each one once -->
|
||||||
|
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:text>, </xsl:text>
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
</xsl:for-each>
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
|
||||||
|
<!-- all table entries -->
|
||||||
|
<xsl:apply-templates select="components/comp"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- the table entries -->
|
||||||
|
<xsl:template match="components/comp">
|
||||||
|
<xsl:value-of select="@ref"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="footprint"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="datasheet"/>
|
||||||
|
<xsl:apply-templates select="fields"/>
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- table entries with dynamic table head -->
|
||||||
|
<xsl:template match="fields">
|
||||||
|
|
||||||
|
<!-- remember current fields section -->
|
||||||
|
<xsl:variable name="fieldvar" select="field"/>
|
||||||
|
|
||||||
|
<!-- for all existing head entries -->
|
||||||
|
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:variable name="allnames" select="@name"/>
|
||||||
|
<xsl:text>,</xsl:text>
|
||||||
|
|
||||||
|
<!-- for all field entries in the remembered fields section -->
|
||||||
|
<xsl:for-each select="$fieldvar">
|
||||||
|
|
||||||
|
<!-- only if this field entry exists in this fields section -->
|
||||||
|
<xsl:if test="@name=$allnames">
|
||||||
|
<!-- content of the field -->
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
</xsl:if>
|
||||||
|
<!--
|
||||||
|
If it does not exist, use an empty cell in output for this row.
|
||||||
|
Every non-blank entry is assigned to its proper column.
|
||||||
|
-->
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,91 @@
|
||||||
|
<!--XSL style sheet to convert EESCHEMA XML Partlist Format to grouped CSV BOM Format
|
||||||
|
Copyright (C) 2014, Wolf Walter.
|
||||||
|
Copyright (C) 2013, Stefan Helmert.
|
||||||
|
GPL v2.
|
||||||
|
|
||||||
|
Functionality:
|
||||||
|
Generation of Digi-Key ordering system compatible BOM
|
||||||
|
|
||||||
|
How to use this is explained in eeschema.pdf chapter 14. You enter a command line into the
|
||||||
|
netlist exporter using a new (custom) tab in the netlist export dialog. The command is
|
||||||
|
on Windows:
|
||||||
|
xsltproc -o "%O.csv" "pathToFile\bom2groupedCsv.xsl" "%I"
|
||||||
|
on Linux:
|
||||||
|
xsltproc -o %O.csv pathToFile/bom2groupedCsv.xsl %I
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!DOCTYPE xsl:stylesheet [
|
||||||
|
<!ENTITY nl "
"> <!--new line CR, LF, or LF, your choice -->
|
||||||
|
]>
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||||
|
<xsl:output method="text"/>
|
||||||
|
|
||||||
|
<!-- for Muenchian grouping of footprint and value combination -->
|
||||||
|
<xsl:key name="partTypeByValueAndFootprint" match="comp" use="concat(footprint, '-', value)" />
|
||||||
|
|
||||||
|
<!-- for table head and empty table fields-->
|
||||||
|
<xsl:key name="headentr" match="field" use="@name"/>
|
||||||
|
|
||||||
|
<!-- main part -->
|
||||||
|
<xsl:template match="/export">
|
||||||
|
<xsl:text>Reference, Quantity, Value, Footprint, Datasheet</xsl:text>
|
||||||
|
|
||||||
|
<!-- find all existing table head entries and list each one once -->
|
||||||
|
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:text>, </xsl:text>
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
<!-- all table entries -->
|
||||||
|
<xsl:apply-templates select="components"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="components">
|
||||||
|
<!-- for Muenchian grouping of footprint and value combination -->
|
||||||
|
<xsl:for-each select="comp[count(. | key('partTypeByValueAndFootprint', concat(footprint, '-', value))[1]) = 1]">
|
||||||
|
<xsl:sort select="@ref" />
|
||||||
|
<xsl:text>&nl;</xsl:text>
|
||||||
|
<!-- list of all references -->
|
||||||
|
<xsl:for-each select="key('partTypeByValueAndFootprint', concat(footprint, '-', value))">
|
||||||
|
<xsl:sort select="@ref" />
|
||||||
|
<xsl:value-of select="@ref"/><xsl:text> </xsl:text>
|
||||||
|
</xsl:for-each><xsl:text>,</xsl:text>
|
||||||
|
<!-- quantity of parts with same footprint and value -->
|
||||||
|
<xsl:value-of select="count(key('partTypeByValueAndFootprint', concat(footprint, '-', value)))"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="value"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="footprint"/><xsl:text>,</xsl:text>
|
||||||
|
<xsl:value-of select="datasheet"/>
|
||||||
|
<xsl:apply-templates select="fields"/>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- table entries with dynamic table head -->
|
||||||
|
<xsl:template match="fields">
|
||||||
|
|
||||||
|
<!-- remember current fields section -->
|
||||||
|
<xsl:variable name="fieldvar" select="field"/>
|
||||||
|
|
||||||
|
<!-- for all existing head entries -->
|
||||||
|
<xsl:for-each select="/export/components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
||||||
|
<xsl:variable name="allnames" select="@name"/>
|
||||||
|
<xsl:text>,</xsl:text>
|
||||||
|
|
||||||
|
<!-- for all field entries in the remembered fields section -->
|
||||||
|
<xsl:for-each select="$fieldvar">
|
||||||
|
|
||||||
|
<!-- only if this field entry exists in this fields section -->
|
||||||
|
<xsl:if test="@name=$allnames">
|
||||||
|
<!-- content of the field -->
|
||||||
|
<xsl:value-of select="."/>
|
||||||
|
</xsl:if>
|
||||||
|
<!--
|
||||||
|
If it does not exist, use an empty cell in output for this row.
|
||||||
|
Every non-blank entry is assigned to its proper column.
|
||||||
|
-->
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:for-each>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
bom2csv.xsl
|
||||||
|
bom2groupedCsv.xsl
|
||||||
|
Originally posted at https://kicad-info.s3.amazonaws.com/3929625ac5cd971344cc17cda0c3877a3981d489907.zip
|
||||||
|
See https://rusefi.com/forum/viewtopic.php?f=13&t=802&p=31415#p17519 for more information
|
Loading…
Reference in New Issue