class Serializer

Properties

XPathConvertor $convertor
protected array $isVoid
protected DOMXPath $xpath

Methods

__construct()

Constructor

string
convertCondition(string $expr)

Convert an XPath expression (used in a condition) into PHP code

string
convertXPath(string $expr)

Convert an XPath expression (used as value) into PHP code

string
serialize(DOMElement $ir)

Serialize the internal representation of a template into PHP

string
convertAttributeValueTemplate(string $attrValue)

Convert an attribute value template into PHP

string
convertDynamicNodeName(string $attrValue)

Convert a dynamic xsl:attribute/xsl:element name into PHP

string
escapeLiteral(string $text, string $context)

Escape given literal

string
escapePHPOutput(string $php, string $context)

Escape the output of given PHP expression

bool
hasMultipleCases(DOMElement $switch)

Test whether given switch has more than one non-default case

bool
isBooleanAttribute(DOMElement $attribute, string $php)

Test whether given attribute declaration is a minimizable boolean attribute

string
serializeApplyTemplates(DOMElement $applyTemplates)

Serialize an node

string
serializeAttribute(DOMElement $attribute)

Serialize an node

string
serializeChildren(DOMElement $ir)

Serialize all the children of given node into PHP

string
serializeCloseTag(DOMElement $closeTag)

Serialize a node

string
serializeComment(DOMElement $comment)

Serialize a node

string
serializeCopyOfAttributes(DOMElement $copyOfAttributes)

Serialize a node

string
serializeElement(DOMElement $element)

Serialize an node

string
serializeHash(DOMElement $switch)

Serialize a node that has a branch-key attribute

string
serializeOutput(DOMElement $output)

Serialize an node

string
serializeSwitch(DOMElement $switch)

Serialize a node

Details

at line 36
__construct()

Constructor

at line 50
string convertCondition(string $expr)

Convert an XPath expression (used in a condition) into PHP code

This method is similar to convertXPath() but it selectively replaces some simple conditions with the corresponding DOM method for performance reasons

Parameters

string $expr

XPath expression

Return Value

string

PHP code

at line 61
string convertXPath(string $expr)

Convert an XPath expression (used as value) into PHP code

Parameters

string $expr

XPath expression

Return Value

string

PHP code

at line 78
string serialize(DOMElement $ir)

Serialize the internal representation of a template into PHP

Parameters

DOMElement $ir

Internal representation

Return Value

string

at line 100
protected string convertAttributeValueTemplate(string $attrValue)

Convert an attribute value template into PHP

NOTE: escaping must be performed by the caller

Parameters

string $attrValue

Attribute value template

Return Value

string

at line 124
protected string convertDynamicNodeName(string $attrValue)

Convert a dynamic xsl:attribute/xsl:element name into PHP

Parameters

string $attrValue

Attribute value template

Return Value

string

at line 141
protected string escapeLiteral(string $text, string $context)

Escape given literal

Parameters

string $text Literal
string $context

Either "raw", "text" or "attribute"

Return Value

string

Escaped literal

at line 160
protected string escapePHPOutput(string $php, string $context)

Escape the output of given PHP expression

Parameters

string $php

PHP expression

string $context

Either "raw", "text" or "attribute"

Return Value

string

PHP expression, including escaping mechanism

at line 178
protected bool hasMultipleCases(DOMElement $switch)

Test whether given switch has more than one non-default case

Parameters

DOMElement $switch

node

Return Value

bool

at line 190
protected bool isBooleanAttribute(DOMElement $attribute, string $php)

Test whether given attribute declaration is a minimizable boolean attribute

Parameters

DOMElement $attribute

node

string $php

Attribute content, in PHP

Return Value

bool

at line 206
protected string serializeApplyTemplates(DOMElement $applyTemplates)

Serialize an node

Parameters

DOMElement $applyTemplates

node

Return Value

string

at line 224
protected string serializeAttribute(DOMElement $attribute)

Serialize an node

Parameters

DOMElement $attribute

node

Return Value

string

at line 248
protected string serializeChildren(DOMElement $ir)

Serialize all the children of given node into PHP

Parameters

DOMElement $ir

Internal representation

Return Value

string

at line 269
protected string serializeCloseTag(DOMElement $closeTag)

Serialize a node

Parameters

DOMElement $closeTag

node

Return Value

string

at line 299
protected string serializeComment(DOMElement $comment)

Serialize a node

Parameters

DOMElement $comment

node

Return Value

string

at line 312
protected string serializeCopyOfAttributes(DOMElement $copyOfAttributes)

Serialize a node

Parameters

DOMElement $copyOfAttributes

node

Return Value

string

at line 330
protected string serializeElement(DOMElement $element)

Serialize an node

Parameters

DOMElement $element

node

Return Value

string

at line 389
protected string serializeHash(DOMElement $switch)

Serialize a node that has a branch-key attribute

Parameters

DOMElement $switch

node

Return Value

string

at line 417
protected string serializeOutput(DOMElement $output)

Serialize an node

Parameters

DOMElement $output

node

Return Value

string

at line 441
protected string serializeSwitch(DOMElement $switch)

Serialize a node

Parameters

DOMElement $switch

node

Return Value

string