class OptimizeChoose extends AbstractChooseOptimization

Constants

XMLNS_XSL

XSL namespace

Properties

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

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

array
getAttributes(Element $element)

Retrieve a list of attributes from given element

array
getBranches()

Return a list the xsl:when and xsl:otherwise children of current xsl:choose element

bool
hasOtherwise()

Test whether current xsl:choose element has an xsl:otherwise child

bool
isEmpty()

Test whether current xsl:choose element has no content besides xsl:when and xsl:otherwise

bool
isEqualTag(Element $el1, Element $el2)

Test whether two elements have the same start tag

void
optimizeChoose()

Optimize the current xsl:choose element

bool
matchBranches(string $childType)

Test whether all branches of current xsl:choose element share a common firstChild/lastChild

bool
matchOnlyChild()

Test whether all branches of current xsl:choose element have a single child with the same start tag

void
moveFirstChildBefore()

Move the firstChild of each branch before current xsl:choose

void
moveLastChildAfter()

Move the lastChild of each branch after current xsl:choose

void
optimizeCommonFirstChild()

Optimize current xsl:choose by moving out the first child of each branch if they match

void
optimizeCommonLastChild()

Optimize current xsl:choose by moving out the last child of each branch if they match

void
optimizeCommonOnlyChild()

Optimize current xsl:choose by moving out only child of each branch if they match

void
optimizeEmptyBranch()

Switch the logic of an xsl:otherwise if the only other branch is empty

void
optimizeEmptyOtherwise()

Optimize away the xsl:otherwise child of current xsl:choose if it's empty

void
optimizeSingleBranch()

Replace current xsl:choose with xsl:if if it has only one branch

void
reparentChild()

Reorder the current xsl:choose tree to make it a child of the first child of its first branch

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

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

protected array getAttributes(Element $element)

Retrieve a list of attributes from given element

Parameters

Element $element

Return Value

array

NamespaceURI#nodeName as keys, attribute values as values

protected array getBranches()

Return a list the xsl:when and xsl:otherwise children of current xsl:choose element

Return Value

array

protected bool hasOtherwise()

Test whether current xsl:choose element has an xsl:otherwise child

Return Value

bool

protected bool isEmpty()

Test whether current xsl:choose element has no content besides xsl:when and xsl:otherwise

Return Value

bool

protected bool isEqualTag(Element $el1, Element $el2)

Test whether two elements have the same start tag

Parameters

Element $el1
Element $el2

Return Value

bool

at line 108
protected void optimizeChoose()

Optimize the current xsl:choose element

Return Value

void

at line 20
protected bool matchBranches(string $childType)

Test whether all branches of current xsl:choose element share a common firstChild/lastChild

Parameters

string $childType

Either firstChild or lastChild

Return Value

bool

at line 45
protected bool matchOnlyChild()

Test whether all branches of current xsl:choose element have a single child with the same start tag

Return Value

bool

at line 80
protected void moveFirstChildBefore()

Move the firstChild of each branch before current xsl:choose

Return Value

void

at line 95
protected void moveLastChildAfter()

Move the lastChild of each branch after current xsl:choose

Return Value

void

at line 133
protected void optimizeCommonFirstChild()

Optimize current xsl:choose by moving out the first child of each branch if they match

Return Value

void

at line 146
protected void optimizeCommonLastChild()

Optimize current xsl:choose by moving out the last child of each branch if they match

Return Value

void

at line 162
protected void optimizeCommonOnlyChild()

Optimize current xsl:choose by moving out only child of each branch if they match

This will reorder xsl:choose/xsl:when/div into div/xsl:choose/xsl:when if every branch has the same only child (excluding the child's own descendants)

Return Value

void

at line 175
protected void optimizeEmptyBranch()

Switch the logic of an xsl:otherwise if the only other branch is empty

Return Value

void

at line 196
protected void optimizeEmptyOtherwise()

Optimize away the xsl:otherwise child of current xsl:choose if it's empty

Return Value

void

at line 210
protected void optimizeSingleBranch()

Replace current xsl:choose with xsl:if if it has only one branch

Return Value

void

at line 229
protected void reparentChild()

Reorder the current xsl:choose tree to make it a child of the first child of its first branch

This will reorder xsl:choose/xsl:when/div into div/xsl:choose/xsl:when

Return Value

void