> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Format to cXML

> Converts a data object or array into a cXML formatted string.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Turns your structured data into a cXML message, ready to send to a procurement partner or trading system. cXML is the XML-based format used for documents such as purchase orders, order confirmations, ship notices, and invoices. This mapper wraps your data in an XML root element and adds the document type line at the top of the message, so the receiving system knows which cXML specification and version the message follows. By default the message is wrapped in a `cXML` element and declared against the basic cXML document type for version `1.2.014`.

This documentation describes: [Schema](/schemas/mapper/serialize-cxml)

## Fields

<FormField property="rootNodeName" label="Root element name">
  The name of the outer element that wraps the whole message. Defaults to `cXML`, which is correct for standard cXML documents. Leave it as is unless your partner expects a different root element.
</FormField>

<FormField property="dtd" label="Document Type Definition (DTD)">
  Tells the receiving system which cXML document type the message follows. This sets the `<!DOCTYPE ...>` line at the top of the output. Choose the type that matches what you are sending:

  * Basic cXML document (the default)
  * Confirmation and Ship Notice
  * Invoice
  * Type Definition
  * Payment Remittance
  * Request for Quotations
  * Contracts
  * Logistics

  The DTD version you set below is filled into this line automatically. See the [cXML documentation](https://xml.cxml.org/current/cXMLGettingStarted.pdf) for the full list of document types.
</FormField>

<FormField property="version" label="DTD version">
  The cXML specification version referenced in the document type line, for example `1.2.014` (the default). Set this to the version your partner expects.
</FormField>

<FormField property="noCdataWrapping" label="Disable cData wrapping">
  An on/off toggle, off by default. When off, any value that contains markup characters such as `<`, `>` or `&` is wrapped in a `<![CDATA[ ... ]]>` block so it passes through untouched. Turn it on to escape those characters instead, so `<b>` is written as `&lt;b&gt;` and `&` as `&amp;`. Leave it off unless the receiving system cannot handle CDATA blocks.
</FormField>

## Sample data

This example formats one object using the default root element and document type, so the message is wrapped in `cXML` and declared against the basic cXML document type for version `1.2.014`.

| Field | Value |
| - | - |
| Root element name | `cXML` (default) |
| Document Type Definition (DTD) | Basic cXML document (default) |
| DTD version | `1.2.014` (default) |
| Disable cData wrapping | off (default) |

Input:

```json theme={null}
{
    "doc": {
        "Header": {
            "From": {
                "Credential": {
                    "Identity": "AcmeSupplier"
                }
            }
        }
    }
}
```

Output:

```json theme={null}
{
    "doc": "<?xml version=\"1.0\"?><!DOCTYPE cXML SYSTEM \"http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd\">\n<cXML><Header><From><Credential><Identity>AcmeSupplier</Identity></Credential></From></Header></cXML>\n"
}
```

If the input also held a comment of `Deliver <b>before 10:00</b> & call on arrival`, the default settings write it as `<Comments><![CDATA[Deliver <b>before 10:00</b> & call on arrival]]></Comments>`. With Disable cData wrapping on, it becomes `<Comments>Deliver &lt;b&gt;before 10:00&lt;/b&gt; &amp; call on arrival</Comments>` instead.

```json Configuration theme={null}
{
  "prototype": "serialize-cxml",
  "parameters": {}
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.