Modify bom2groupedCsv.xsl to group on nodes in dynamic table

I’m using bom2groupedCsv.xsl in EESchema from KiCad 4. This groups components by reference and value, which are part of the exported static table. But I would also like to group on fields in the dynamic table (children of the <fields> node). The exported XML looks like:

<comp ref="C1003">
  <value>10n</value>
  <footprint>CAPCP2012N</footprint>
  <fields>
    <field name="Type">X7R 25V</field>
    <field name="Manufacturer">Kemet</field>
  </fields>
  <libsource lib="priv_IEC60617" part="CAPACITOR"/>
  <sheetpath names="/Front Board/" tstamps="/5CB636A0/"/>
  <tstamp>5CB68E52</tstamp>
</comp>

I’m out of my depth with XSL. Can anyone tell me please how I should modify bom2groupedCsv.xsl so it also groups on the value(s) of the dynamic table fields, eg “X7R 25V” from <field name="Type">X7R 25V</field>?

  • Robert

I’m not sure what that XSL stuff is, but it seems it’s not updated since 2015.

Python seems to be the default scripting language for KiCad, and there are libraries for reading schematic and pcb files.

There are also plenty of examples for working with it in the BOM scripts written in Python.

Huh, KiCad 4???
Is that the KiCad version you’re working with, or is it that just that old XSL thing has been written for KiCad V4?

Yes, KiCad 4, because it’s an ongoing project. The XSL script I’m using does what it was written to do so it doesn’t require updating by the original author. However, I was hoping for a simple tweak without giving myself a whole new pile of problems to deal with. I’m no more familiar with Python than I am with XSLT.

I eventually figured it out on my own, and as I suspected the answer is very simple. All that is needed is to change instances of:
concat(footprint, '-', value)

to:
concat(footprint, '-', value, '-', field[@name='Type'])

‘Type’ being the custom field name I defined in the Template Field Names that define the dynamic table in the EEschema options, and ‘field’ and ‘name’ being the name and attribute name of the XML node I wanted added to the group definition.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.