Skip to content

XsltRenderer

Renders .xsl stylesheets against an “inner” XML document (from $moreAssigns['inner']) via ext-xsl.

With the envelope parameter (on by default) it wraps the inner document plus each rendered slot into a single synthetic document under the XsltRenderer::ENVELOPE_NAMESPACE namespace, so a stylesheet can pull slot content via XPath instead of relying on XSLT string parameters (which can’t carry markup).

final class XsltRenderer extends Renderer implements IReusableRenderer

ExtendsRenderer
ImplementsIReusableRenderer
SourceXsltRenderer.php
ConstantValueDescription
ENVELOPE_NAMESPACE'http://quiote.org/quiote/renderer/xslt/envelope/1.0'
MethodDescription
getStarterTemplate(): stringReturns the skeleton .xsl stylesheet written for a newly scaffolded view.
render(TemplateLayer $layer, array &$attributes = [], array &$slots = [], array &$moreAssigns = []): mixedTransforms the input document with the layer’s .xsl stylesheet and returns the serialised result.

public function getStarterTemplate(): string

Returns the skeleton .xsl stylesheet written for a newly scaffolded view.

The stylesheet declares a title parameter and prints it, matching the scalar attributes this renderer forwards as XSLT parameters.

Returns string

public function render(TemplateLayer $layer, array &$attributes = [], array &$slots = [], array &$moreAssigns = []): mixed

Transforms the input document with the layer’s .xsl stylesheet and returns the serialised result.

Only scalar and Stringable attributes are passed on as XSLT parameters, since XSLT parameters cannot carry markup; everything else reaches the stylesheet through the document. The document is either the envelope built from the inner assign plus the flattened slots (the default) or the inner assign on its own when the envelope parameter is off. The processor runs with every security preference set, so document() cannot read files or the network and php:function is unavailable.

ParameterTypeDescription
$layerTemplateLayer
$attributesarray
$slotsarray
$moreAssignsarray

Returns mixed

ThrowsWhen
RenderExceptionif the layer carries no stylesheet, the stylesheet or a document cannot be parsed, the inner assign is not a DOMDocument, string or null, or the transformation itself fails.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
appendParameter()ParameterHolderAppend a parameter.
appendParameterByRef()ParameterHolderAppend a parameter by reference.
clearParameters()ParameterHolderClear all parameters associated with this request.
getContext()RendererRetrieve the current application context.
getDefaultExtension()RendererGet the template file extension
getFlatParameterNames()ParameterHolderRetrieve an array of flattened parameter names.
getParameter()ParameterHolderRetrieve a parameter.
getParameterNames()ParameterHolderRetrieve an array of parameter names.
getParameters()ParameterHolderRetrieve an array of parameters.
hasParameter()ParameterHolderIndicates whether or not a parameter exists.
initialize()RendererInitialize this Renderer.
removeParameter()ParameterHolderRemove a parameter.
reset()RendererReturns the renderer to its post-construction state so the instance can be reused for another rendering.
setParameter()ParameterHolderSet a parameter.
setParameterByRef()ParameterHolderSet a parameter by reference.
setParameters()ParameterHolderSet an array of parameters.
setParametersByRef()ParameterHolderSet an array of parameters by reference.