2015-02-09 07:39:06 +00:00
|
|
|
<!--
|
|
|
|
EESCHEMA BOM plugin. Creates BOM CSV files from the project net file.
|
|
|
|
Based on Stefan Helmert bom2csv.xsl
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
Note:
|
2016-06-03 06:32:24 +00:00
|
|
|
The project infomation (i.e title, company and revision) is taken from the root sheet.
|
2015-02-28 14:21:49 +00:00
|
|
|
|
|
|
|
Arthur:
|
2015-02-10 08:35:37 +00:00
|
|
|
Ronald Sousa HashDefineElectronics.com
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-09 07:39:06 +00:00
|
|
|
Ouput Example:
|
2015-02-10 08:35:37 +00:00
|
|
|
Source,
|
|
|
|
Kicad Rev, working director and file source
|
|
|
|
Generated Date, date this file was generated
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2016-06-03 06:32:24 +00:00
|
|
|
Title, the project's title
|
2015-02-10 08:35:37 +00:00
|
|
|
Company, the project's company
|
2015-02-15 10:45:43 +00:00
|
|
|
Rev, the project's revision
|
2015-02-10 08:35:37 +00:00
|
|
|
Date Source, project's issue date
|
|
|
|
Comment, This is comment 1
|
|
|
|
Comment, This is comment 2
|
|
|
|
Comment, This is comment 3
|
|
|
|
Comment, This is comment 4
|
2016-06-03 06:32:24 +00:00
|
|
|
-->
|
|
|
|
<!--
|
|
|
|
@package
|
|
|
|
Command line:
|
|
|
|
xsltproc -o "%O.csv" "pathToFile/bom2csv.xsl" "%I"
|
2015-02-09 07:39:06 +00:00
|
|
|
|
2016-06-03 06:32:24 +00:00
|
|
|
Output format
|
2015-02-09 07:39:06 +00:00
|
|
|
Reference, Value, Fields[n], Library, Library Ref
|
|
|
|
U1, PIC32MX, Fields[n], KicadLib, PIC
|
|
|
|
-->
|
|
|
|
|
|
|
|
<!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">
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:text>Source,</xsl:text><xsl:value-of select="design/source"/><xsl:text>&nl;</xsl:text>
|
|
|
|
<xsl:text>Kicad Rev,</xsl:text><xsl:value-of select="design/tool"/><xsl:text>&nl;</xsl:text>
|
|
|
|
<xsl:text>Generated Date,</xsl:text><xsl:value-of select="design/date"/><xsl:text>&nl;</xsl:text>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:text>&nl;</xsl:text>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<!-- Ouput Root sheet project information -->
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:apply-templates select="/export/design/sheet[1]"/>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:text>&nl;</xsl:text>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
|
|
|
<!-- Output table header -->
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:text>Reference,Value,</xsl:text>
|
|
|
|
<xsl:for-each select="components/comp/fields/field[generate-id(.) = generate-id(key('headentr',@name)[1])]">
|
|
|
|
<xsl:value-of select="@name"/>
|
|
|
|
<xsl:text>,</xsl:text>
|
|
|
|
</xsl:for-each>
|
|
|
|
<xsl:text>Library,Library Ref</xsl:text>
|
2015-02-09 07:39:06 +00:00
|
|
|
<xsl:text>&nl;</xsl:text>
|
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<!-- all table entries -->
|
|
|
|
<xsl:apply-templates select="components/comp"/>
|
|
|
|
</xsl:template>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<!-- generate the Root sheet project information -->
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:template match="/export/design/sheet[1]">
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-09 07:39:06 +00:00
|
|
|
<xsl:choose>
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:when test="title_block/title !=''">
|
|
|
|
<xsl:text>Title,</xsl:text><xsl:value-of select="title_block/title"/><xsl:text>&nl;</xsl:text>
|
2015-02-09 07:39:06 +00:00
|
|
|
</xsl:when>
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>Title,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:otherwise>
|
2015-02-09 07:39:06 +00:00
|
|
|
</xsl:choose>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:choose>
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:when test="title_block/company !=''">
|
|
|
|
<xsl:text>Company,</xsl:text><xsl:value-of select="title_block/company"/><xsl:text>&nl;</xsl:text>
|
2015-02-10 08:35:37 +00:00
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>Company,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:choose>
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:when test="title_block/rev !=''">
|
|
|
|
<xsl:text>Revision,</xsl:text><xsl:value-of select="title_block/rev"/><xsl:text>&nl;</xsl:text>
|
2015-02-10 08:35:37 +00:00
|
|
|
</xsl:when>
|
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>Revision,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:otherwise>
|
|
|
|
</xsl:choose>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-09 07:39:06 +00:00
|
|
|
<xsl:choose>
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:when test="title_block/date !=''">
|
|
|
|
<xsl:text>Date Issue,</xsl:text><xsl:value-of select="title_block/date"/><xsl:text>&nl;</xsl:text>
|
2015-02-09 07:39:06 +00:00
|
|
|
</xsl:when>
|
2015-02-10 08:35:37 +00:00
|
|
|
<xsl:otherwise>
|
|
|
|
<xsl:text>Date Issue,Not Set</xsl:text><xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:otherwise>
|
2015-02-09 07:39:06 +00:00
|
|
|
</xsl:choose>
|
|
|
|
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:apply-templates select="title_block/comment"/>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-11 11:11:05 +00:00
|
|
|
</xsl:template>
|
2015-02-28 14:21:49 +00:00
|
|
|
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:template match="title_block/comment">
|
2015-02-09 07:39:06 +00:00
|
|
|
<xsl:choose>
|
2015-02-15 10:45:43 +00:00
|
|
|
<xsl:when test="@value !=''">
|
|
|
|
<xsl:text>Comment,</xsl:text><xsl:value-of select="@value"/><xsl:text>&nl;</xsl:text>
|
2015-02-10 08:35:37 +00:00
|
|
|
</xsl:when>
|
|
|
|
</xsl:choose>
|
2015-02-09 07:39:06 +00:00
|
|
|
</xsl:template>
|
2015-02-11 11:11:05 +00:00
|
|
|
|
2015-02-28 14:21:49 +00:00
|
|
|
|
|
|
|
|
2015-02-09 07:39:06 +00:00
|
|
|
<!-- 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:apply-templates select="fields"/>
|
|
|
|
<xsl:apply-templates select="libsource"/>
|
|
|
|
<xsl:text>&nl;</xsl:text>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
<!-- the library selection -->
|
|
|
|
<xsl:template match="libsource">
|
|
|
|
<xsl:value-of select="@lib"/><xsl:text>,</xsl:text>
|
|
|
|
<xsl:value-of select="@part"/>
|
|
|
|
</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"/>
|
|
|
|
|
|
|
|
<!-- 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:text>,</xsl:text>
|
|
|
|
</xsl:for-each>
|
|
|
|
</xsl:template>
|
|
|
|
|
|
|
|
</xsl:stylesheet>
|