Salami Slice Design Pattern in XML Schema

The Salami Slice design pattern is an XML Schema (XSD) modeling approach where every element is declared globally and then assembled using references. This article explains the fundamentals of the Salami Slice pattern, how it structures data, its primary advantages and disadvantages, and how it compares to alternative XML Schema design methodologies.

What is the Salami Slice Pattern?

In the Salami Slice pattern, an XML schema is dismantled into thin, independent pieces—much like slices of salami. Every element in the schema is defined at the root level as a top-level, global element using <xs:element>.

Complex elements are then composed by referencing these global elements using the ref attribute rather than defining child elements locally or using named complex types.

Schema Example

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <!-- Global Element Declarations (The Slices) -->
  <xs:element name="FirstName" type="xs:string"/>
  <xs:element name="LastName" type="xs:string"/>
  <xs:element name="Street" type="xs:string"/>
  <xs:element name="City" type="xs:string"/>

  <xs:element name="Address">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Street"/>
        <xs:element ref="City"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Customer">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="FirstName"/>
        <xs:element ref="LastName"/>
        <xs:element ref="Address"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

In this structure, FirstName, LastName, Street, City, Address, and Customer are all declared globally, regardless of where they appear in the final XML hierarchy.

Key Characteristics

Advantages of Salami Slice

Disadvantages of Salami Slice

Salami Slice vs. Other XSD Design Patterns

When to Use Salami Slice

The Salami Slice pattern is best suited for modular XML architectures, migration from legacy DTDs, or environments where distinct fragments of an XML document need to be transmitted and validated independently as valid root structures.