class MergeIdenticalConditionalBranches extends AbstractNormalization

Merge xsl:when branches if they have identical content

NOTE: may fail if branches have identical equality expressions, e.g. "@a=1" and "@a=1"

Constants

XMLNS_XSL

XSL namespace

Properties

protected Document $ownerDocument from  AbstractNormalization
protected array $queries {@inheritdoc}

Methods

void
normalize(Element $template)

Apply this normalization rule to given template

Text
createPolymorphicText(string $textContent)

Create an xsl:text element or a text node in current template

array
getNodes()

Query and return a list of nodes of interest

bool
isXsl(DOMNode $node, string $localName = null)

Test whether given node is an XSL element

string
lowercase(string $str)

Make an ASCII string lowercase

void
normalizeAttribute(Attr $attribute)

No description

void
normalizeCdataSection(CdataSection $comment)

No description

void
normalizeComment(Comment $comment)

No description

void
normalizeElement(Element $element)

No description

void
normalizeNode(DOMNode $node)

No description

void
normalizeText(Text $node)

No description

void
reset()

Reset this instance's properties after usage

Element[]
collectCompatibleBranches(DOMNode $node)

Collect consecutive xsl:when elements that share the same kind of equality tests

void
mergeBranches(array $nodes)

Merge identical xsl:when elements from a list

void
mergeCompatibleBranches(Element $choose)

Inspect the branches of an xsl:choose element and merge branches if their content is identical and their order does not matter

void
mergeConsecutiveBranches(Element $choose)

Inspect the branches of an xsl:choose element and merge consecutive branches if their content is identical

Details

void normalize(Element $template)

Apply this normalization rule to given template

Parameters

Element $template

node

Return Value

void

protected Text createPolymorphicText(string $textContent)

Create an xsl:text element or a text node in current template

Parameters

string $textContent

Return Value

Text

protected array getNodes()

Query and return a list of nodes of interest

Return Value

array

protected bool isXsl(DOMNode $node, string $localName = null)

Test whether given node is an XSL element

Parameters

DOMNode $node
string $localName

Return Value

bool

protected string lowercase(string $str)

Make an ASCII string lowercase

Parameters

string $str

Original string

Return Value

string

Lowercased string

protected void normalizeAttribute(Attr $attribute)

No description

Parameters

Attr $attribute

Return Value

void

protected void normalizeCdataSection(CdataSection $comment)

No description

Parameters

CdataSection $comment

Return Value

void

protected void normalizeComment(Comment $comment)

No description

Parameters

Comment $comment

Return Value

void

at line 172
protected void normalizeElement(Element $element)

No description

Parameters

Element $element

Return Value

void

protected void normalizeNode(DOMNode $node)

No description

Parameters

DOMNode $node

Return Value

void

protected void normalizeText(Text $node)

No description

Parameters

Text $node

Return Value

void

protected void reset()

Reset this instance's properties after usage

Return Value

void

at line 35
protected Element[] collectCompatibleBranches(DOMNode $node)

Collect consecutive xsl:when elements that share the same kind of equality tests

Will return xsl:when elements that test a constant part (e.g. a literal) against the same variable part (e.g. the same attribute)

Parameters

DOMNode $node

First node to inspect

Return Value

Element[]

at line 81
protected void mergeBranches(array $nodes)

Merge identical xsl:when elements from a list

Parameters

array $nodes

Return Value

void

at line 121
protected void mergeCompatibleBranches(Element $choose)

Inspect the branches of an xsl:choose element and merge branches if their content is identical and their order does not matter

Parameters

Element $choose

xsl:choose element

Return Value

void

at line 149
protected void mergeConsecutiveBranches(Element $choose)

Inspect the branches of an xsl:choose element and merge consecutive branches if their content is identical

Parameters

Element $choose

xsl:choose element

Return Value

void