title: Applying Muenchian grouping to XSLT
body: <p>completely new to xlst, I've tried to follow numerous links to apply Muenchian grouping but to no avail, most likely because I'm not putting the extra lines in the right places probably, and have no idea how to convert to xlst2 in order to use for-each-group instead. Anyway the csv file I'm trying to convert is very simple:</p>
  <pre><code>123456789,2021-08-05T00:00:00+00:00,GBP,2099-12-31T00:00:00+00:00,23.00
  123456789,2021-07-22T00:00:00+00:00,GBP,2099-07-22T00:00:00+00:00,35.00
  123456789,2021-07-06T00:00:00+00:00,GBP,2099-07-13T00:00:00+00:00,39.50
  987654321,2021-08-05T00:00:00+00:00,EUR,2099-12-31T00:00:00+00:00,25.95
  987654321,2021-07-22T00:00:00+00:00,EUR,2099-07-22T00:00:00+00:00,39.95
  987654321,2021-07-06T00:00:00+00:00,EUR,2099-07-13T00:00:00+00:00,44.95
  </code></pre>
  <p>Or in XML format:</p>
  <pre><code>&lt;DEMarkdown xmlns=&quot;http://F.FlatFileSchema1&quot;&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;123456789&lt;/sku&gt;
          &lt;valid-from&gt;2021-08-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;GBP&lt;/currency&gt;
          &lt;valid-to&gt;2099-12-31T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;23.00&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;123456789&lt;/sku&gt;
          &lt;valid-from&gt;2021-07-22T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;GBP&lt;/currency&gt;
          &lt;valid-to&gt;2099-07-22T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;35.00&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;123456789&lt;/sku&gt;
          &lt;valid-from&gt;2021-07-06T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;GBP&lt;/currency&gt;
          &lt;valid-to&gt;2099-07-13T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;39.50&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;987654321&lt;/sku&gt;
          &lt;valid-from&gt;2021-08-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;EUR&lt;/currency&gt;
          &lt;valid-to&gt;2099-12-31T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;25.95&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;987654321&lt;/sku&gt;
          &lt;valid-from&gt;2021-07-22T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;EUR&lt;/currency&gt;
          &lt;valid-to&gt;2099-07-22T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;39.95&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
      &lt;DEMarkdowns xmlns=&quot;&quot;&gt;
          &lt;sku&gt;987654321&lt;/sku&gt;
          &lt;valid-from&gt;2021-07-06T00:00:00+00:00&lt;/valid-from&gt;
          &lt;currency&gt;EUR&lt;/currency&gt;
          &lt;valid-to&gt;2099-07-13T00:00:00+00:00&lt;/valid-to&gt;
          &lt;value&gt;44.95&lt;/value&gt;
      &lt;/DEMarkdowns&gt;
  &lt;/DEMarkdown&gt;
  </code></pre>
  <p>I've used BizTalk to generate my Flat File Source Schema:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
  &lt;xs:schema xmlns=&quot;http://F.FlatFileSchema1&quot; xmlns:b=&quot;http://schemas.microsoft.com/BizTalk/2003&quot; targetNamespace=&quot;http://F.FlatFileSchema1&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
    &lt;xs:annotation&gt;
      &lt;xs:appinfo&gt;
        &lt;schemaEditorExtension:schemaInfo namespaceAlias=&quot;b&quot; extensionClass=&quot;Microsoft.BizTalk.FlatFileExtension.FlatFileExtension&quot; standardName=&quot;Flat File&quot; xmlns:schemaEditorExtension=&quot;http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions&quot; /&gt;
        &lt;b:schemaInfo standard=&quot;Flat File&quot; codepage=&quot;65001&quot; default_pad_char=&quot; &quot; pad_char_type=&quot;char&quot; count_positions_by_byte=&quot;false&quot; parser_optimization=&quot;speed&quot; lookahead_depth=&quot;3&quot; suppress_empty_nodes=&quot;false&quot; generate_empty_nodes=&quot;true&quot; allow_early_termination=&quot;false&quot; early_terminate_optional_fields=&quot;false&quot; allow_message_breakup_of_infix_root=&quot;false&quot; compile_parse_tables=&quot;false&quot; root_reference=&quot;DEMarkdown&quot; /&gt;
      &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
    &lt;xs:element name=&quot;DEMarkdown&quot;&gt;
      &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
          &lt;b:recordInfo structure=&quot;delimited&quot; child_delimiter_type=&quot;hex&quot; child_delimiter=&quot;0xD 0xA&quot; child_order=&quot;postfix&quot; sequence_number=&quot;1&quot; preserve_delimiter_for_empty_data=&quot;true&quot; suppress_trailing_delimiters=&quot;false&quot; /&gt;
        &lt;/xs:appinfo&gt;
      &lt;/xs:annotation&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
              &lt;groupInfo sequence_number=&quot;0&quot; xmlns=&quot;http://schemas.microsoft.com/BizTalk/2003&quot; /&gt;
            &lt;/xs:appinfo&gt;
          &lt;/xs:annotation&gt;
          &lt;xs:element maxOccurs=&quot;unbounded&quot; name=&quot;DEMarkdowns&quot;&gt;
            &lt;xs:annotation&gt;
              &lt;xs:appinfo&gt;
                &lt;b:recordInfo structure=&quot;delimited&quot; child_delimiter_type=&quot;char&quot; child_delimiter=&quot;,&quot; child_order=&quot;infix&quot; sequence_number=&quot;1&quot; preserve_delimiter_for_empty_data=&quot;true&quot; suppress_trailing_delimiters=&quot;false&quot; /&gt;
              &lt;/xs:appinfo&gt;
            &lt;/xs:annotation&gt;
            &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                &lt;xs:annotation&gt;
                  &lt;xs:appinfo&gt;
                    &lt;groupInfo sequence_number=&quot;0&quot; xmlns=&quot;http://schemas.microsoft.com/BizTalk/2003&quot; /&gt;
                  &lt;/xs:appinfo&gt;
                &lt;/xs:annotation&gt;
                &lt;xs:element name=&quot;sku&quot; type=&quot;xs:string&quot;&gt;
                  &lt;xs:annotation&gt;
                    &lt;xs:appinfo&gt;
                      &lt;b:fieldInfo justification=&quot;left&quot; sequence_number=&quot;1&quot; /&gt;
                    &lt;/xs:appinfo&gt;
                  &lt;/xs:annotation&gt;
                &lt;/xs:element&gt;
                &lt;xs:element name=&quot;valid-from&quot; type=&quot;xs:dateTime&quot;&gt;
                  &lt;xs:annotation&gt;
                    &lt;xs:appinfo&gt;
                      &lt;b:fieldInfo justification=&quot;left&quot; sequence_number=&quot;2&quot; /&gt;
                    &lt;/xs:appinfo&gt;
                  &lt;/xs:annotation&gt;
                &lt;/xs:element&gt;
                &lt;xs:element name=&quot;currency&quot; type=&quot;xs:string&quot;&gt;
                  &lt;xs:annotation&gt;
                    &lt;xs:appinfo&gt;
                      &lt;b:fieldInfo justification=&quot;left&quot; sequence_number=&quot;3&quot; /&gt;
                    &lt;/xs:appinfo&gt;
                  &lt;/xs:annotation&gt;
                &lt;/xs:element&gt;
                &lt;xs:element name=&quot;valid-to&quot; type=&quot;xs:dateTime&quot;&gt;
                  &lt;xs:annotation&gt;
                    &lt;xs:appinfo&gt;
                      &lt;b:fieldInfo justification=&quot;left&quot; sequence_number=&quot;4&quot; /&gt;
                    &lt;/xs:appinfo&gt;
                  &lt;/xs:annotation&gt;
                &lt;/xs:element&gt;
                &lt;xs:element name=&quot;value&quot; type=&quot;xs:decimal&quot;&gt;
                  &lt;xs:annotation&gt;
                    &lt;xs:appinfo&gt;
                      &lt;b:fieldInfo justification=&quot;left&quot; sequence_number=&quot;5&quot; /&gt;
                    &lt;/xs:appinfo&gt;
                  &lt;/xs:annotation&gt;
                &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
          &lt;/xs:element&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  <p>The XML destination schema is this:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;xs:schema xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:dt=&quot;http://www.fakewebsite.com/xml/ns/enfinity/6.5/core/impex-dt&quot; attributeFormDefault=&quot;unqualified&quot; elementFormDefault=&quot;qualified&quot; targetNamespace=&quot;http://www.fakewebsite.com/7.1/bc_pricing/impex&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
      &lt;xs:element name=&quot;enfinity&quot;&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element name=&quot;product-price-list&quot;&gt;
                      &lt;xs:complexType&gt;
                          &lt;xs:sequence&gt;
                              &lt;xs:element name=&quot;display-name&quot; type=&quot;xs:string&quot; /&gt;
                              &lt;xs:element name=&quot;description&quot; type=&quot;xs:string&quot; /&gt;
                              &lt;xs:element name=&quot;enabled&quot; type=&quot;xs:boolean&quot; /&gt;
                              &lt;xs:element name=&quot;priority&quot; type=&quot;xs:unsignedByte&quot; /&gt;
                              &lt;xs:element name=&quot;target-groups&quot;&gt;
                                  &lt;xs:complexType&gt;
                                      &lt;xs:sequence&gt;
                                          &lt;xs:element name=&quot;customer-segments&quot;&gt;
                                              &lt;xs:complexType&gt;
                                                  &lt;xs:sequence&gt;
                                                      &lt;xs:element maxOccurs=&quot;unbounded&quot; name=&quot;customer-segment&quot;&gt;
                                                          &lt;xs:complexType&gt;
                                                              &lt;xs:attribute name=&quot;id&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                                                              &lt;xs:attribute name=&quot;repository-id&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                                                          &lt;/xs:complexType&gt;
                                                      &lt;/xs:element&gt;
                                                  &lt;/xs:sequence&gt;
                                              &lt;/xs:complexType&gt;
                                          &lt;/xs:element&gt;
                                      &lt;/xs:sequence&gt;
                                  &lt;/xs:complexType&gt;
                              &lt;/xs:element&gt;
                              &lt;xs:element maxOccurs=&quot;unbounded&quot; name=&quot;product-price-list-entry&quot;&gt;
                                  &lt;xs:complexType&gt;
                                      &lt;xs:sequence&gt;
                                          &lt;xs:element maxOccurs=&quot;unbounded&quot; name=&quot;price-scale-table&quot;&gt;
                                              &lt;xs:complexType&gt;
                                                  &lt;xs:sequence&gt;
                                                      &lt;xs:element name=&quot;valid-from&quot; type=&quot;xs:dateTime&quot; /&gt;
                                                      &lt;xs:element name=&quot;valid-to&quot; type=&quot;xs:dateTime&quot; /&gt;
                                                      &lt;xs:element name=&quot;price-scale-entries&quot;&gt;
                                                          &lt;xs:complexType&gt;
                                                              &lt;xs:sequence&gt;
                                                                  &lt;xs:element name=&quot;fixed-price-entry&quot;&gt;
                                                                      &lt;xs:complexType&gt;
                                                                          &lt;xs:sequence&gt;
                                                                              &lt;xs:element name=&quot;value&quot; type=&quot;xs:decimal&quot; /&gt;
                                                                          &lt;/xs:sequence&gt;
                                                                          &lt;xs:attribute name=&quot;quantity&quot; type=&quot;xs:unsignedByte&quot; use=&quot;required&quot; /&gt;
                                                                          &lt;xs:attribute name=&quot;unit&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                                                                      &lt;/xs:complexType&gt;
                                                                  &lt;/xs:element&gt;
                                                              &lt;/xs:sequence&gt;
                                                          &lt;/xs:complexType&gt;
                                                      &lt;/xs:element&gt;
                                                  &lt;/xs:sequence&gt;
                                                  &lt;xs:attribute name=&quot;type-code&quot; type=&quot;xs:unsignedByte&quot; use=&quot;required&quot; /&gt;
                                                  &lt;xs:attribute name=&quot;currency&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                                              &lt;/xs:complexType&gt;
                                          &lt;/xs:element&gt;
                                      &lt;/xs:sequence&gt;
                                      &lt;xs:attribute name=&quot;sku&quot; type=&quot;xs:unsignedInt&quot; use=&quot;required&quot; /&gt;
                                      &lt;xs:attribute name=&quot;import-mode&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                                  &lt;/xs:complexType&gt;
                              &lt;/xs:element&gt;
                          &lt;/xs:sequence&gt;
                          &lt;xs:attribute name=&quot;id&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                          &lt;xs:attribute name=&quot;priceType&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                          &lt;xs:attribute name=&quot;import-mode&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
                      &lt;/xs:complexType&gt;
                  &lt;/xs:element&gt;
              &lt;/xs:sequence&gt;
              &lt;xs:attribute name=&quot;major&quot; type=&quot;xs:unsignedByte&quot; use=&quot;required&quot; /&gt;
              &lt;xs:attribute name=&quot;minor&quot; type=&quot;xs:unsignedByte&quot; use=&quot;required&quot; /&gt;
              &lt;xs:attribute name=&quot;family&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
              &lt;xs:attribute name=&quot;branch&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
              &lt;xs:attribute name=&quot;build&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  <p>The current output of my XML looks like this at the moment:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;ns0:enfinity major=&quot;6&quot; minor=&quot;1&quot; family=&quot;enfinity&quot; branch=&quot;enterprise&quot; build=&quot;build&quot; xmlns:ns0=&quot;http://www.fakewebsite.com/7.1/bc_pricing/impex&quot; xmlns:s0=&quot;http://F.FlatFileSchema1&quot;&gt;
      &lt;ns0:product-price-list id=&quot;DEMarkdown&quot; priceType=&quot;ES_SalePrice&quot; import-mode=&quot;UPDATE&quot;&gt;
          &lt;ns0:display-name&gt;DE Markdown&lt;/ns0:display-name&gt;
          &lt;ns0:description/&gt;
          &lt;ns0:enabled&gt;true&lt;/ns0:enabled&gt;
          &lt;ns0:priority&gt;1&lt;/ns0:priority&gt;
          &lt;ns0:target-groups&gt;
              &lt;ns0:customer-segments&gt;
                  &lt;ns0:customer-segment id=&quot;Everyone&quot; repository-id=&quot;WhiteStuff-DE-Anonymous&quot;/&gt;
                  &lt;ns0:customer-segment id=&quot;IG_RegisteredUsers&quot; repository-id=&quot;WhiteStuff-DE-Anonymous&quot;/&gt;
              &lt;/ns0:customer-segments&gt;
          &lt;/ns0:target-groups&gt;
          &lt;ns0:product-price-list-entry sku=&quot;123456789&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-08-05T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-12-31T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;23.00&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
          &lt;ns0:product-price-list-entry sku=&quot;123456789&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-07-22T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-07-22T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;35.00&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
          &lt;ns0:product-price-list-entry sku=&quot;123456789&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-07-06T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-07-13T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;39.50&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
          &lt;ns0:product-price-list-entry sku=&quot;987654321&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-08-05T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-12-31T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;25.95&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
          &lt;ns0:product-price-list-entry sku=&quot;987654321&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-07-22T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-07-22T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;39.95&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
          &lt;ns0:product-price-list-entry sku=&quot;987654321&quot; import-mode=&quot;REPLACE&quot;&gt;
              &lt;ns0:price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
                  &lt;ns0:valid-from&gt;2021-07-06T00:00:00+00:00&lt;/ns0:valid-from&gt;
                  &lt;ns0:valid-to&gt;2099-07-13T00:00:00+00:00&lt;/ns0:valid-to&gt;
                  &lt;ns0:price-scale-entries&gt;
                      &lt;ns0:fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
                          &lt;ns0:value&gt;44.95&lt;/ns0:value&gt;
                      &lt;/ns0:fixed-price-entry&gt;
                  &lt;/ns0:price-scale-entries&gt;
              &lt;/ns0:price-scale-table&gt;
          &lt;/ns0:product-price-list-entry&gt;
      &lt;/ns0:product-price-list&gt;
  &lt;/ns0:enfinity&gt;
  </code></pre>
  <p>But I want to group by sku so each sku only appears once within product-price-list-entry, so that it looks like this instead:</p>
  <pre><code>&lt;enfinity xsi:schemaLocation=&quot;http://www.fakewebsite.com/7.1/bc_pricing/impex bc_pricing.xsd&quot; xmlns=&quot;http://www.fakewebsite.com/7.1/bc_pricing/impex&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:dt=&quot;http://www.fakewebsite.com/6.5/core/impex-dt&quot; major=&quot;6&quot; minor=&quot;1&quot; family=&quot;enfinity&quot; branch=&quot;enterprise&quot; build=&quot;build&quot;&gt;
    &lt;product-price-list id=&quot;DEMarkdown&quot; priceType=&quot;ES_SalePrice&quot; import-mode=&quot;UPDATE&quot;&gt;
      &lt;display-name&gt;DE Markdown&lt;/display-name&gt;
      &lt;description&gt;&lt;/description&gt;
      &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;priority&gt;1&lt;/priority&gt;
      &lt;target-groups&gt;
        &lt;customer-segments&gt;
          &lt;customer-segment id=&quot;Everyone&quot; repository-id=&quot;WhiteStuff-DE-Anonymous&quot;/&gt;
          &lt;customer-segment id=&quot;IG_RegisteredUsers&quot; repository-id=&quot;WhiteStuff-DE-Anonymous&quot;/&gt;
        &lt;/customer-segments&gt;
      &lt;/target-groups&gt;
      &lt;product-price-list-entry sku=&quot;123456789&quot; import-mode=&quot;REPLACE&quot;&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
          &lt;valid-from&gt;2021-08-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-12-31T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;23.00&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
          &lt;valid-from&gt;2021-07-22T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-07-22T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;35.00&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
          &lt;valid-from&gt;2021-07-22T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-07-22T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;39.95&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
      &lt;/product-price-list-entry&gt;
      &lt;product-price-list-entry sku=&quot;987654321&quot; import-mode=&quot;REPLACE&quot;&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
          &lt;valid-from&gt;2021-08-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-12-31T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;25.95&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;GBP&quot;&gt;
          &lt;valid-from&gt;2021-07-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-07-13T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;39.50&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
        &lt;price-scale-table type-code=&quot;1&quot; currency=&quot;EUR&quot;&gt;
          &lt;valid-from&gt;2021-07-05T00:00:00+00:00&lt;/valid-from&gt;
          &lt;valid-to&gt;2099-07-13T00:00:00+00:00&lt;/valid-to&gt;
          &lt;price-scale-entries&gt;
            &lt;fixed-price-entry quantity=&quot;1&quot; unit=&quot;&quot;&gt;
              &lt;value&gt;44.95&lt;/value&gt;
            &lt;/fixed-price-entry&gt;
          &lt;/price-scale-entries&gt;
        &lt;/price-scale-table&gt;
      &lt;/product-price-list-entry&gt;
    &lt;/product-price-list&gt;
  &lt;/enfinity&gt;
  </code></pre>
  <p>The xlst which currently converts csv to xml is this, which is what I'm trying to modify.  I've taken out what I tried to add myself as it didn't work :(</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;
  &lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot; xmlns:ns0=&quot;http://www.fakewebsite.com/7.1/bc_pricing/impex&quot; xmlns:s0=&quot;http://F.FlatFileSchema1&quot;&gt;
      &lt;xsl:output method=&quot;xml&quot; indent=&quot;no&quot;/&gt;
      &lt;xsl:template match=&quot;/&quot;&gt;
          &lt;xsl:apply-templates select=&quot;/s0:DEMarkdown&quot;/&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match=&quot;/s0:DEMarkdown&quot;&gt;
          &lt;ns0:enfinity&gt;
              &lt;xsl:attribute name=&quot;major&quot;&gt;
                  &lt;xsl:text&gt;6&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name=&quot;minor&quot;&gt;
                  &lt;xsl:text&gt;1&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name=&quot;family&quot;&gt;
                  &lt;xsl:text&gt;enfinity&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name=&quot;branch&quot;&gt;
                  &lt;xsl:text&gt;enterprise&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name=&quot;build&quot;&gt;
                  &lt;xsl:text&gt;build&lt;/xsl:text&gt;
              &lt;/xsl:attribute&gt;
              &lt;ns0:product-price-list&gt;
                  &lt;xsl:attribute name=&quot;id&quot;&gt;
                      &lt;xsl:text&gt;DEMarkdown&lt;/xsl:text&gt;
                  &lt;/xsl:attribute&gt;
                  &lt;xsl:attribute name=&quot;priceType&quot;&gt;
                      &lt;xsl:text&gt;ES_SalePrice&lt;/xsl:text&gt;
                  &lt;/xsl:attribute&gt;
                  &lt;xsl:attribute name=&quot;import-mode&quot;&gt;
                      &lt;xsl:text&gt;UPDATE&lt;/xsl:text&gt;
                  &lt;/xsl:attribute&gt;
                  &lt;ns0:display-name&gt;
                      &lt;xsl:text&gt;DE Markdown&lt;/xsl:text&gt;
                  &lt;/ns0:display-name&gt;
                  &lt;ns0:description&gt;
                      &lt;xsl:text/&gt;
                  &lt;/ns0:description&gt;
                  &lt;ns0:enabled&gt;
                      &lt;xsl:text&gt;true&lt;/xsl:text&gt;
                  &lt;/ns0:enabled&gt;
                  &lt;ns0:priority&gt;
                      &lt;xsl:text&gt;1&lt;/xsl:text&gt;
                  &lt;/ns0:priority&gt;
                  &lt;ns0:target-groups&gt;
                      &lt;ns0:customer-segments&gt;
                          &lt;ns0:customer-segment&gt;
                              &lt;xsl:attribute name=&quot;id&quot;&gt;
                                  &lt;xsl:text&gt;Everyone&lt;/xsl:text&gt;
                              &lt;/xsl:attribute&gt;
                              &lt;xsl:attribute name=&quot;repository-id&quot;&gt;
                                  &lt;xsl:text&gt;WhiteStuff-DE-Anonymous&lt;/xsl:text&gt;
                              &lt;/xsl:attribute&gt;
                          &lt;/ns0:customer-segment&gt;
                          &lt;ns0:customer-segment&gt;
                              &lt;xsl:attribute name=&quot;id&quot;&gt;
                                  &lt;xsl:text&gt;IG_RegisteredUsers&lt;/xsl:text&gt;
                              &lt;/xsl:attribute&gt;
                              &lt;xsl:attribute name=&quot;repository-id&quot;&gt;
                                  &lt;xsl:text&gt;WhiteStuff-DE-Anonymous&lt;/xsl:text&gt;
                              &lt;/xsl:attribute&gt;
                          &lt;/ns0:customer-segment&gt;
                      &lt;/ns0:customer-segments&gt;
                  &lt;/ns0:target-groups&gt;
                  &lt;xsl:for-each select=&quot;DEMarkdowns&quot;&gt;
                      &lt;ns0:product-price-list-entry&gt;
                          &lt;xsl:attribute name=&quot;sku&quot;&gt;
                              &lt;xsl:value-of select=&quot;sku/text()&quot;/&gt;
                          &lt;/xsl:attribute&gt;
                          &lt;xsl:attribute name=&quot;import-mode&quot;&gt;
                              &lt;xsl:text&gt;REPLACE&lt;/xsl:text&gt;
                          &lt;/xsl:attribute&gt;
                          &lt;ns0:price-scale-table&gt;
                              &lt;xsl:attribute name=&quot;type-code&quot;&gt;
                                  &lt;xsl:text&gt;1&lt;/xsl:text&gt;
                              &lt;/xsl:attribute&gt;
                              &lt;xsl:attribute name=&quot;currency&quot;&gt;
                                  &lt;xsl:value-of select=&quot;currency/text()&quot;/&gt;
                              &lt;/xsl:attribute&gt;
                              &lt;ns0:valid-from&gt;
                                  &lt;xsl:value-of select=&quot;valid-from/text()&quot;/&gt;
                              &lt;/ns0:valid-from&gt;
                              &lt;ns0:valid-to&gt;
                                  &lt;xsl:value-of select=&quot;valid-to/text()&quot;/&gt;
                              &lt;/ns0:valid-to&gt;
                              &lt;ns0:price-scale-entries&gt;
                                  &lt;ns0:fixed-price-entry&gt;
                                      &lt;xsl:attribute name=&quot;quantity&quot;&gt;
                                          &lt;xsl:text&gt;1&lt;/xsl:text&gt;
                                      &lt;/xsl:attribute&gt;
                                      &lt;xsl:attribute name=&quot;unit&quot;&gt;
                                          &lt;xsl:text/&gt;
                                      &lt;/xsl:attribute&gt;
                                      &lt;ns0:value&gt;
                                          &lt;xsl:value-of select=&quot;value/text()&quot;/&gt;
                                      &lt;/ns0:value&gt;
                                  &lt;/ns0:fixed-price-entry&gt;
                              &lt;/ns0:price-scale-entries&gt;
                          &lt;/ns0:price-scale-table&gt;
                      &lt;/ns0:product-price-list-entry&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/ns0:product-price-list&gt;
          &lt;/ns0:enfinity&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>