---
title: XML to XML Transformation - Strip SOAP Envelopes & Mask Sensitive Data
description: Transform Log Event XML into business-friendly formats using XSLT. Strip SOAP envelopes, remove sensitive data (PII), mask credit cards and SSNs, and create cleansed XML views for GDPR/HIPAA/PCI-DSS compliance in Log Views.
---

# XML to XML Transformation

Transform [Log Event][] XML into cleansed, business-friendly formats for end-user viewing in [Log Views][], using an XSLT [Stylesheet][].

![Install the XML to XML example as an XSLT Stylesheet and strip the SOAP envelope from an order status in a Log View, animated walkthrough (7.12)][1]  
*Animated walkthrough: **Add Stylesheet**, Type **XSLT**, paste the example, bind the [Message Type][Message Types], and **Save and close**. In the Log View, **View message body** shows the SOAP envelope; **View message formatted as** the Stylesheet shows only `<Orders>`, without the envelope or its prefixes.*  

## :fa-lightbulb: Why Transform XML to XML?

Most stylesheets transform XML to **HTML** for visual presentation in Log Views. But there are compelling business reasons to keep the output as **XML**:

### Security & Compliance

* **Remove sensitive data** - Strip PII (Personally Identifiable Information), credentials, or confidential business data before displaying to end users in Log Views
* **Meet compliance requirements** - GDPR, HIPAA, PCI-DSS often prohibit showing certain fields to operations teams or auditors
* **Audit trail safety** - Log Views are accessible to multiple users; cleansed XML reduces exposure risk

### Business User Friendliness

* **Strip technical noise** - Remove verbose SOAP envelopes, namespaces, or wrapper elements to show only the business payload
* **Simplify structure** - Transform complex nested XML into flat, readable format for operations teams who aren't XML experts
* **Focus on business data** - End users see just the order details, customer information, or transaction data—not SOAP protocol overhead

### Technical Integration

* **Enable copy-paste** - Users can copy the cleansed XML from Log Views and paste into other tools, testing systems, or support tickets
* **Support downstream analysis** - Analysts can export and parse clean XML for reporting or data investigation
* **Standardize formats** - Convert various message formats into a consistent structure for easier troubleshooting

### Common Use Cases

1. **Strip SOAP envelope** - Remove web service wrappers to expose just the business message in Log Views
2. **Mask customer data** - Replace credit card numbers, SSNs, or emails with `***` before displaying in Log Views
3. **Remove credentials** - Strip username/password fields from authentication messages visible to support staff
4. **Simplify structure** - Transform complex nested XML into flat format for operations teams viewing Log Events

>[!TIP]
>This stylesheet applies to **Log Events in Log Views**, not alarm emails. If you're looking for alarm email customization, see [Alarm Plugin Object][] for XSLT examples that transform alarm data to HTML.

## :fa-code: Example: Strip SOAP Envelope

This example demonstrates the most common XML-to-XML transformation: extracting the business payload from a SOAP web service envelope for display in Log Views.

### Visual Overview

<div class="mermaid">
graph LR
    A["fa:fa-envelope SOAP Envelope<br/>with Business Payload"] --> B["fa:fa-magic XSLT<br/>Transformation"]
    B --> C["fa:fa-file-code Clean Business<br/>XML Only"]
    style A fill:#FFD525,color:#000
    style B fill:#2678BD,color:#fff
    style C fill:#93d16d,color:#000
</div>

*XSLT transformation flow: the SOAP envelope (yellow, protocol noise) passes the XSLT step (blue) and leaves clean business XML (green) for Log Views.*  

### Understanding the Transformation

#### What it does

* Removes the outer SOAP `<Envelope>` wrapper
* Extracts content from `<Body>` element
* Strips all namespace prefixes (`soap:`, `soapenv:`)
* Preserves the business message structure and data

#### When to use it

* Operations teams viewing Log Events need to see just the business data, not SOAP protocol overhead
* End users aren't familiar with SOAP structure and find envelopes confusing
* You want cleaner, more readable Log Views focused on business content

### XSLT Code

The stylesheet uses XSLT templates to navigate the SOAP structure and extract only the business content:

``` xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" exclude-result-prefixes="soap">
  <xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" indent ="yes"/>
  <xsl:template match="/">
    <xsl:apply-templates select="soapenv:Envelope/soapenv:Body/*"/>
  </xsl:template>
  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>
```

#### How it works

1. **Root template** (`match="/"`) - Selects only the content inside `<Body>`, ignoring the `<Envelope>` wrapper
2. **Element template** (`match="*"`) - Recreates each element using `local-name()` to strip namespace prefixes
3. **Attribute template** (`match="@*"`) - Preserves all attributes while removing namespace prefixes
4. **Output formatting** - Indents the result for readability with `indent="yes"`

### Input XML

A typical SOAP message with envelope wrapper and business payload:

``` xml
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
  <soap:Body>
    <Orders>
      <Order state="OK">
        <Id>1337</Id>
      </Order>      
    </Orders> 
  </soap:Body>
</soap:Envelope>
```

#### Notice

* `<soap:Envelope>` wrapper - Protocol overhead, not business data
* `<soap:Body>` container - Holds the actual business message
* `<Orders>` element - The business payload operations teams care about

### Output XML

After applying the XSLT transformation, only the clean business payload remains:

``` xml
<Orders>
  <Order state="OK">
    <Id>1337</Id>
  </Order>
</Orders>
```

#### Result

* SOAP envelope completely removed
* Namespace prefixes stripped
* Business message preserved exactly
* Clean, readable XML for operations teams viewing Log Events

## :fa-shield-halved: Advanced: Remove Sensitive Data

Beyond stripping envelopes, you can mask or remove sensitive fields for compliance and security before displaying in Log Views.

### Data Masking Flow

<div class="mermaid">
graph TD
    A["fa:fa-file-code Original XML<br/>with PII"] --> B{"fa:fa-shield-halved XSLT<br/>Data Masking"}
    B --> C["fa:fa-credit-card Credit Card<br/>****-****-****-****"]
    B --> D["fa:fa-id-card SSN<br/>***-**-****"]
    B --> E["fa:fa-key Passwords<br/>(removed)"]
    C --> F["fa:fa-check-circle Compliant XML<br/>for Log Views"]
    D --> F
    E --> F
    style A fill:#FFD525,color:#000
    style B fill:#2678BD,color:#fff
    style C fill:#93d16d,color:#000
    style D fill:#93d16d,color:#000
    style E fill:#93d16d,color:#000
    style F fill:#93d16d,color:#000
</div>

*XSLT data masking flow: original XML with personal data (yellow, at risk) passes the masking step (blue) and leaves masked, compliant output (green) for display in Log Views under GDPR, HIPAA, or PCI-DSS.*  

### Example: Mask Credit Card Numbers

```xslt
<!-- Add to your stylesheet templates -->
<xsl:template match="CreditCardNumber">
  <CreditCardNumber>****-****-****-****</CreditCardNumber>
</xsl:template>

<xsl:template match="SSN">
  <SSN>***-**-****</SSN>
</xsl:template>
```

### Example: Remove Elements Entirely

```xslt
<!-- Completely remove password fields -->
<xsl:template match="Password"/>
<xsl:template match="ApiKey"/>
```

### Business value

* **Compliance** - Meet GDPR, HIPAA, PCI-DSS requirements by not displaying sensitive data in Log Views accessible to multiple users
* **Security** - Log Views may be viewed by support staff, auditors, or operations teams who shouldn't see customer PII
* **Access control** - Operations teams can troubleshoot messages without seeing customer confidential data

## :fa-list-check: Configuration Steps

1. Create a new [Stylesheet][] in :Nodinite: (see [Add or manage Stylesheet][])
2. Paste the XSLT code and customize for your XML structure
3. Test the transformation against a logged Log Event: click **Message Body**, choose **Message Id**, and click **Preview** (see [Preview with a test message body][Add or manage Stylesheet - Preview])
4. Associate the stylesheet with the [Message Types][] of the Log Events; every [Log View][Log Views] that shows those events can then use it
5. Click **Save**
6. In a [Log View][Log Views], open the **Action** menu of a matching Log Event and choose **View message formatted as** the Stylesheet

## :fa-circle-exclamation: Important Considerations

### Browser rendering

* XML will display in Log Views as plain text or formatted XML depending on browser capabilities
* Most modern browsers provide collapsible XML tree views for better readability
* Users can copy-paste the XML output for use in other tools

### Performance

* XSLT transformations run when users view Log Events in Log Views
* For Log Views with thousands of events, keep transformations simple and efficient
* Complex XPath expressions or recursive templates may slow down Log View rendering

### Validation

* Test your transformation with various message samples to ensure proper handling of edge cases
* Verify that masked/removed fields don't break XML structure
* Ensure output is well-formed XML that browsers can display correctly

## :fa-hand-point-right: Next Steps

* :fa-file-lines: [Stylesheets][] - Learn about other stylesheet types and use cases  
* :fa-file-plus: [Add or manage Stylesheet][]  

## :fa-link-horizontal: Related Topics

:fa-code: [Alarm Plugin Object][] - Transform alarm object XML with XSLT for emails  
:fa-bug: [XML Passthrough][] - Debug stylesheet for raw XML output in emails  
:fa-file-lines: [Stylesheets][] - Understanding stylesheet types and capabilities  
:fa-shield-halved: [Base64Decode XML from JSON][] - Another XML transformation example  
:fa-code: [Stylesheet Examples][] - All XSLT and Liquid examples  
:fa-search: [Log Views][] - Where the transformed XML is shown  
:fa-tags: [Message Types][] - Decide which Stylesheet formats a Log Event  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Customize/Stylesheets/Stylesheet_XmlToXml.gif

[Add or manage Stylesheet]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/Add%20or%20manage%20Stylesheet.md
[Add or manage Stylesheet - Preview]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/Add%20or%20manage%20Stylesheet.md#preview-with-a-test-message-body
[Alarm Plugin Object]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/Alarm%20Plugin%20Object.md
[Base64Decode XML from JSON]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/Base64Decode%20XML%20from%20JSON.md
[Log Event]:{ndr}/Core%20Services/Log%20Event/Overview.md
[Log Views]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/What%20is%20a%20Log%20View.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.md
[Stylesheet]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/What%20is%20a%20Stylesheet.md
[Stylesheet Examples]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/Overview.md
[Stylesheets]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Features/What%20is%20a%20Stylesheet.md
[XML Passthrough]:{ndr}/Administration/4.%20Customize/2.%20Stylesheets/Examples/XML%20Passthrough.md