Search for a function "getRenderedContent"

Search for a function "getRenderedContent

I am looking for a function that delivers the rendered content of an XWiki page to me, whereby specifications such as “xpage=plain, outputSyntax= …” would also be evaluated as with the standard URL.

The background to this is:
I am currently creating a series of macros for graphical visualisation using various Javascript frameworks (such as Mermaid, ECharts, graphViz …) (Yes - I know Kroki!)
The data is to be taken from tables or parts of tables in other Wiki documents.
The real problem is that some of these tables have dynamically created content that is first calculated by the wiki system (e.g. in an Excel-like implementation of Apache POI).

So I need the results after processing the embedded XWiki macros!

I have made 2 attempts to solve the problem:

(A) My attempts using services.rendering and xdom objects

(1) Create an XDOM object:

testinfo = xwiki.getDocument("some wiki file table").content
xdom= services.rendering.parse(testinfo, "xwiki/2.1")

(2) Selection of the table via a “targetID”.

import org.xwiki.rendering.block.*
import org.xwiki.rendering.block.match.*

def getTableBlockFromXdomById( theXdom,targetID ) {
  tableBlocks = []
  TableBlock resultBlock = null
  tableBlocks = theXdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT);
  while (i<tableBlocks.size) {
    if (tableBlocks[i].getParameter("id").equals(targetID)) {
      resultBlock = tableBlocks[i]
  return resultBlock

but resulted in the

(3) “Render back” using

htmlSyntax = services.rendering.render(result, "xhtml/1.0")

that all macro structures (“org.xwiki.rendering.block.MacroBlock”) are ignored.

(B) The simpler way at first is to use xwiki.getURLContent in a construction like

    theNewDoc=xwiki.getDocument("a wiki document")

But this fails because the wiki in question is not freely accessible and the server does not allow the request to itself due missing user rights. (Perhaps one could still try to determine the client’s cookies here and work with a modification of xwiki.GetURLContent, but I haven’t done that yet).

Very well - what have I missed ? Where am I wrong ?

Any help is welcome