---
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.*  

## <i class="fal fa-lightbulb" aria-hidden="true"></i> 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

<aside aria-label="Tip" class="nodinite-note nodinite-note--tip">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-lightbulb"></i> Tip</p>
<div class="nodinite-note__content"><p>This stylesheet applies to <strong>Log Events in Log Views</strong>, not alarm emails. If you're looking for alarm email customization, see <a href="https://docs.nodinite.com/administration/customize/stylesheets/examples/alarm-plugin-object/">Alarm Plugin Object</a> for XSLT examples that transform alarm data to HTML.</p></div>
</aside>

## <i class="fal fa-code" aria-hidden="true"></i> 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

## <i class="fal fa-shield-halved" aria-hidden="true"></i> 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

## <i class="fal fa-list-check" aria-hidden="true"></i> Configuration Steps

1. Create a new [Stylesheet][] in <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> (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

## <i class="fal fa-circle-exclamation" aria-hidden="true"></i> 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

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-file-lines" aria-hidden="true"></i> [Stylesheets][] - Learn about other stylesheet types and use cases  
* <i class="fal fa-file-plus" aria-hidden="true"></i> [Add or manage Stylesheet][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

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

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Customize/Stylesheets/Stylesheet_XmlToXml.gif

[Add or manage Stylesheet]:https://docs.nodinite.com/administration/customize/stylesheets/features/add-or-manage-stylesheet/
[Add or manage Stylesheet - Preview]:https://docs.nodinite.com/administration/customize/stylesheets/features/add-or-manage-stylesheet/#preview-with-a-test-message-body
[Alarm Plugin Object]:https://docs.nodinite.com/administration/customize/stylesheets/examples/alarm-plugin-object/
[Base64Decode XML from JSON]:https://docs.nodinite.com/administration/customize/stylesheets/examples/base64decode-xml-from-json/
[Log Event]:https://docs.nodinite.com/core-services/log-event/overview/
[Log Views]:https://docs.nodinite.com/administration/log-management/log-views/features/what-is-a-log-view/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Stylesheet]:https://docs.nodinite.com/administration/customize/stylesheets/features/what-is-a-stylesheet/
[Stylesheet Examples]:https://docs.nodinite.com/administration/customize/stylesheets/examples/overview/
[Stylesheets]:https://docs.nodinite.com/administration/customize/stylesheets/features/what-is-a-stylesheet/
[XML Passthrough]:https://docs.nodinite.com/administration/customize/stylesheets/examples/xml-passthrough/