XML.ApplyStylesheet
-------------------

Apply the stylesheet to the document (XSLT transform).

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XML](component_XML.md) | [8.4](newinversion84.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XML.ApplyStylesheet"; XML; StyleSheet { ; Parameters } ) 

**MBS**( **"XML.ApplyStylesheet";** /\* Apply the stylesheet to the document (XSLT transform). \*/  
**$XML**; /\* The XML to process.  
Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time.e.g. "&lt;test&gt;Hello&lt;/test&gt;" \*/   
**$StyleSheet**; /\* The XML of the style sheet.  
Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. \*/   
**$Parameters**) /\* Optional; The list of parameters to pass to the engine.  
Pass a list with key=value format.e.g. "id=123¶test=2" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| XML | The XML to process.   Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. | "&lt;test&gt;Hello&lt;/test&gt;" |  |
| StyleSheet | The XML of the style sheet.   Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. |  |  |
| Parameters | The list of parameters to pass to the engine.   Pass a list with key=value format. | "id=123¶test=2" | Optional |

### Result

Returns text or error.

### Description

Apply the stylesheet to the document (XSLT transform).  
Performs a XSLT transformation on the input document.  
The output may be a non-wellformed output XML wise!  
  
Returns various errors if XML is not well formed or style sheet is invalid.  
  
Based on LibXSLT, so it provides an implementation of XSLT 1.0, plus most of the EXSLT set of processor-portable extensions functions and some of Saxon's evaluate and expressions extensions.  
  
Added exsl functions for MBS Plugin in version 15.0.  
If you need XSLT 2.0/3.0, please check the [Saxon.XSLT](SaxonXSLT.md) function.  
  
### Examples

Apply a stylesheet:

 Set Variable \[ $InputXML ; Value:XSLT::InputXML \]  
Set Variable \[ $StyleSheet ; Value:XSLT::StyleSheet \]  
Set Variable \[ $Output ; Value:MBS ("XML.ApplyStylesheet"; $InputXML ; $StyleSheet ) \]  
Set Field \[ XSLT::OutputXML ; $Output \]  
### See also

- [Saxon.XSLT](SaxonXSLT.md)
- [XML.ApplyStylesheet2](XMLApplyStylesheet2.md)
- [XML.InsertRecords](XMLInsertRecords.md)
- [XML.Parse](XMLParse.md)

### Release notes

- **Version 15.1**
    - Enabled EXSLT extensions for [XML.ApplyStylesheet](https://www.mbsplugins.eu/XMLApplyStylesheet.shtml).
- **Version 14.5**
    - Improved error handling for [XML.ApplyStylesheet](https://www.mbsplugins.eu/XMLApplyStylesheet.shtml).
- **Version 11.5**
    - Added [XML.ApplyStylesheet2](https://www.mbsplugins.eu/XMLApplyStylesheet2.shtml) function.
    - Fixed error message reporting problem for [XML.ApplyStylesheet](https://www.mbsplugins.eu/XMLApplyStylesheet.shtml) function.
- **Version 10.0**
    - Fixed [XML.ApplyStylesheet](https://www.mbsplugins.eu/XMLApplyStylesheet.shtml) to return empty string if result should be empty.
- **Version 9.5**
    - Fixed a problem with [XML.ApplyStylesheet](http://www.mbsplugins.eu/XMLApplyStylesheet.shtml) only returned first block of text instead of full text.
- **Version 8.4**
    - Added [XML.ApplyStylesheet](http://www.mbsplugins.eu/XMLApplyStylesheet.shtml) function.

### Example Databases

- [XML/XSLT](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/XML/XSLT.shtml#1ScriptAnchor_)

### Blog Entries

- [Goodies 33: Custom context menu commands for FileMaker ScriptWorkspace](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/33-CustomcontextmenucommandsforFileMakerScriptWorkspace.shtml)
- [MBS Plugin 15.1 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-03-11/MBS_Plugin_151_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.1pr1](https://www.mbsplugins.de/archive/2025-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.5pr2](https://www.mbsplugins.de/archive/2024-10-07/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in version 11.5 of MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-11-30/New_in_version_115_of_MBS_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.5pr6](https://www.mbsplugins.de/archive/2021-11-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.6pr2](https://www.mbsplugins.de/archive/2019-12-10/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.5pr4](https://www.mbsplugins.de/archive/2019-10-21/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [Custom context menu commands for FileMaker ScriptWorkspace](https://www.mbsplugins.de/archive/2019-10-19/Custom_context_menu_commands_f/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.4 - More than 5400 Functions In One Plugin](https://www.mbsplugins.de/archive/2018-09-25/MBS_FileMaker_Plugin_84_-_More/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 22nd August 2018 , last changed 20th January 2025

  
[XL.Uninitialize](XLUninitialize.md) - [XML.ApplyStylesheet2](XMLApplyStylesheet2.md)

[HTML Version](XMLApplyStylesheet.shtml)