# New $services.rendering.transform() API

**URL:** <https://forum.xwiki.org/t/new-services-rendering-transform-api/18175>\
**Category:** Development\
**Tags:** proposal\
**Created:** [January 29, 2026, 1:07pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175 "2026-01-29T13:07:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mflorea](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mflorea/32/49_2.png) [@mflorea](https://forum.xwiki.org/u/mflorea)\
**Post date:** [January 29, 2026, 1:07pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/1 "2026-01-29T13:07:15Z")

</div>

Hi everyone,

I need to convert the content of a wiki page from its storage XWiki 2.1 syntax to the [new UniAst syntax](https://forum.xwiki.org/t/new-uniast-syntax/18174/1) used by the BlockNote editor. I would like to perform this conversion from a Velocity script because the BlockNote integration relies on the [Edit Module](https://extensions.xwiki.org/xwiki/bin/view/Extension/Edit%20Module). Technically, I could do it from Java, but this means moving some HTML generating code from a template to Java. Moreover, I can’t rely on `Document#getRenderedContent()` API because the Edit Module decouples the edited content from the source document, and there’s no safe `Document#getRenderedContent()` signature to cover my case.

The rendering script service already has APIs to **parse** and **render** the content. It’s missing an API to execute the rendering **transformations**. Note that executing rendering transformations means executing script macros which is an important attack vector so it needs to be properly secured. The means using the right “transformation context”. In order to create this context we need to know:

- the target syntax
- whether to enable restricted mode or not
- the lists of transformations
- the context document (to evaluate script rights on)

In order to accept these parameters and possibly others in the future I suggest we use the builder pattern. The new API could be used like this:

```auto
#set ($targetSyntax = 'uniast/1.0')
#set ($xdom = $services.rendering.parse($content, $contentSyntax))
#set ($discard = $services.rendering.transform($xdom)
  .withTransformations(['macro'])
  .withTargetSyntax($targetSyntax)
  .withRestricted(true)
  .withContextDocument($editedDocument)
  .perform())
#set ($renderedContent = $services.rendering.render($xdom, $targetSyntax))

```

The script macros will be executed with the rights of the **current context user** , evaluated against the specified context document.

WDYT?

Thanks,  
Marius

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [January 29, 2026, 1:17pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/2 "2026-01-29T13:17:55Z")

</div>

+1 thanks.

Small note: the javadoc should specify what is the order of the transformations executed (the order of the passed list or the transformation order).

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [January 29, 2026, 1:36pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/3 "2026-01-29T13:36:16Z")

</div>

> [@mflorea](#):
>
> the context document (to evaluate script rights on)

That’s no fully accurate. The rights are evaluated on the content (secure) document, you just happen to also use it as context document by default.

+1 for the general idea, just need to refine a bit the naming (and there might be surprises requiring adding more stuff to the builder while implementing this)

---

<div class="post-metadata">

**Author:** ![mflorea](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mflorea/32/49_2.png) [@mflorea](https://forum.xwiki.org/u/mflorea)\
**Post date:** [February 12, 2026, 10:45am UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/4 "2026-02-12T10:45:20Z")

</div>

While implementing this I realized that I need to introduce a new API to control the list of rendering transformations to execute per execution. We currently support customizing the list of transformations at the level of rendering configuration and at the level of HTTP request (through a request parameter). I think it makes sense to be able to set the list of transformations in the transformation context as well. This will lead to the following fallback chain:

```
TransformationContext > HTTP request > RenderingConfiguration

```

This means:

- adding `TransformationContext#get/setTransformationNames`; I propose we use the same naming as in the existing `RenderingConfiguration#getTransformationNames()`
- modify `DefaultTransformationManager` to check the list from the transformation context first

You can review these changes at [XRENDERING-803: Add support for overwriting the list of transformations to execute from the transformation context by mflorea · Pull Request #370 · xwiki/xwiki-rendering · GitHub](https://github.com/xwiki/xwiki-rendering/pull/370) .

The rest of the changes, for the `xwiki-platform` side, can be seen at [XWIKI-24003: Add a script service to execute rendering transformations by mflorea · Pull Request #5170 · xwiki/xwiki-platform · GitHub](https://github.com/xwiki/xwiki-platform/pull/5170) . I received two interesting comments so far, to which I add my own observation at the end:

- the naming of `$services.rendering.transform()` is misleading because it doesn’t perform the transformation right away, but it rather creates the transformation context
- we’re adding a new way / API to perform rendering transformations; there should be a single way ideally
- the Velocity syntax I pasted above doesn’t work; we actually need to use something like:

```auto
#set ($xdom = $services.rendering.parse($source.content, $source.syntax))
#set ($discard = $services.rendering.transform($xdom
  ).withId("BlockNote:${source.documentReference}"
  ).withSyntax($source.syntax
  ).withTargetSyntax($targetSyntax
  ).withRestricted($restricted
  ).withTransformations(['macro']
  ).withContentDocument($source.documentReference
  ).execute())
#set ($renderedContent = $services.rendering.render($xdom, $targetSyntax))

```

which is not that nice…

Given this, I’d like to propose something else:

- we keep a single API to perform rendering transformations, which is `TransformationManager`
- we make the platform implementation, `XWikiTransformationManager`, safer by using `AuthorExecutor`
- but `AuthorExecutor` needs the content / source document reference, so we extend `TransformationContext` with `XWikiTransformationContext`, adding `get/setContentDocumentReference`
- `XWikiTransformationManager` can then check if the passed `TransformationContext` can be cast to `XWikiTransformationManager` and use the `AuthorExecutor` in that case
- on the script service side we add two APIs:

```auto
$services.rendering.createTransformationContext()
$services.rendering.transform($xdom, $transformationContext)

```

- if we need more information in the future (e.g. for security reasons) we can add that to the `XWikiTransformationContext`, and the script service doesn’t need any change.

Do you see any problem with this?

Thanks,  
Marius

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [February 12, 2026, 1:37pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/5 "2026-02-12T13:37:15Z")

</div>

> [@mflorea](#):
>
> This means:
> 
> - adding `TransformationContext#get/setTransformationNames`; I propose we use the same naming as in the existing `RenderingConfiguration#getTransformationNames()`
> - modify `DefaultTransformationManager` to check the list from the transformation context first

Sounds good.

I also commented at [Loading...](https://jira.xwiki.org/browse/XRENDERING-803?focusedId=121615&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-121615) that this should be compatible with the need of [Loading...](https://jira.xwiki.org/browse/XWIKI-17808).

> [@mflorea](#):
>
> Given this, I’d like to propose something else:
> 
> - we keep a single API to perform rendering transformations, which is `TransformationManager`
> - we make the platform implementation, `XWikiTransformationManager`, safer by using `AuthorExecutor`
> - but `AuthorExecutor` needs the content / source document reference, so we extend `TransformationContext` with `XWikiTransformationContext`, adding `get/setContentDocumentReference`
> - `XWikiTransformationManager` can then check if the passed `TransformationContext` can be cast to `XWikiTransformationManager` and use the `AuthorExecutor` in that case
> - on the script service side we add two APIs:
> 
> ```auto
> $services.rendering.createTransformationContext()
> $services.rendering.transform($xdom, $transformationContext)
> 
> ```
> 
> - if we need more information in the future (e.g. for security reasons) we can add that to the `XWikiTransformationContext`, and the script service doesn’t need any change.

I’m not an expert on the security implications but from an API and consistency POV I like it. Thx for taking care of this.

Thanks

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [February 12, 2026, 1:44pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/6 "2026-02-12T13:44:19Z")

</div>

Fine with me. Just note that calling `$services.rendering.transform` should require programming right.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [February 12, 2026, 1:50pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/7 "2026-02-12T13:50:09Z")

</div>

> [@tmortagne](#):
>
> Fine with me. Just note that calling `$services.rendering.transform` should require programming right.

I guess that’s ok if @mflorea planned to use that in a template. It’s less nice if it was planned to be used in a wiki page since it would mean that a XAR extension would require the admin to have PR to install it or it’ll fail to work.

PS: I guess we still don’t have the feature in EM to prevent installing an extension that requires PR if the current user doesn’t have PR (based on Required Rights).

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [February 12, 2026, 1:58pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/8 "2026-02-12T13:58:34Z")

</div>

> [@vmassol](#):
>
> I guess that’s ok if @mflorea planned to use that in a template. It’s less nice if it was planned to be used in a wiki page since it would mean that a XAR extension would require the admin to have PR to install it or it’ll fail to work.

There is no way around it. The point of that use case (whatever the API used) is to execute arbitrary content with the right of the current user. We cannot let someone who does not have programming right do that.

---

<div class="post-metadata">

**Author:** ![mflorea](https://forum.xwiki.org/user_avatar/forum.xwiki.org/mflorea/32/49_2.png) [@mflorea](https://forum.xwiki.org/u/mflorea)\
**Post date:** [February 23, 2026, 2:50pm UTC](https://forum.xwiki.org/t/new-services-rendering-transform-api/18175/9 "2026-02-23T14:50:49Z")

</div>

This has been released in 18.1.0RC1.
