---
title: XDesignXElement
summary: API reference for XDesignXElement.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-24
library: SAIF.Services.Printing
reference_type: package
---

# XDesignXElement

`XDesignXElement` is the element-level XML wrapper used by xPression-oriented reports. It tracks primary and foreign key elements, propagates keys through nested structures, and renders the resulting element tree as escaped XML markup.

## Purpose
- Extend the base SAIF XML element type with key tracking for report structures.
- Serialize nested report elements into xPression-compatible markup.

## Context
- Namespace: `SAIF.Services.Printing.Reporting`
- Assembly/package: `SAIF.Services.Printing`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `Keys` | `Public ReadOnly Property Keys() As List(Of XDesignXElement)` | Returns the collection of key elements owned by the current element. |
| `ForeignKeys` | `Public ReadOnly Property ForeignKeys() As List(Of XDesignXElement)` | Returns the collection of foreign-key elements propagated from ancestors. |
| `New` | `Public Sub New(name As XName)` | Creates an element with a name only. |
| `New` | `Public Sub New(name As XName, content As Object)` | Creates an element with a name and content. |
| `New` | `Public Sub New(name As XName, ParamArray content() As Object)` | Creates an element with a name and multiple content items. |
| `New` | `Public Sub New(other As XDesignXElement)` | Creates a copy of another `XDesignXElement`. |
| `New` | `Public Sub New(other As XStreamingElement)` | Creates an element from a streaming element source. |
| `AddKey` | `Public Sub AddKey(child As XDesignXElement)` | Adds a child element and records it as a key element. |
| `Clone` | `Public Function Clone() As XDesignXElement` | Creates a detached copy of the current element tree. |
| `ToXpression` | `Public Function ToXpression(Optional tabIndex As Integer = 0) As String` | Propagates keys and renders the element tree as escaped XML text. |
| `DisplayKeys` | `Public Sub DisplayKeys(Optional tabIndex As Integer = 0)` | Writes the current element's key information to the console and recurses through child elements. |

## Behavioral notes
- `ToXpression` propagates the current element's keys into child foreign-key collections before it renders nested content.
- Leaf nodes render as single escaped elements, while non-leaf nodes emit propagated foreign keys before their child elements.
- `Clone` uses the `ToSAIFXElement` extension path to create a detached copy suitable for insertion into another document tree.

## Constraints and usage notes
- Only `XDesignXElement` children participate in key propagation; non-`XDesignXElement` children are converted through the extension method before rendering.
- `DisplayKeys` is diagnostic output written to the console rather than a structured return value.

## Sources
- `Services\SAIF.Services.Printing\Reporting\XDesignXElement.vb`
