class OptimizeChooseText 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

void
adjustTextNodes(string $childType, int $pos, int $len = PHP_INT_MAX)

Adjust length of the text nodes of current xsl:choose element's branches

int
getPrefixLength(array $strings)

Compute the number of leading characters common to all strings

string[]
getTextContent(string $childType)

Get the text content of the firstChild/lastChild of each branch if they are all text nodes

void
optimizeLeadingText()

Move common leading text outside of current choose

void
optimizeTrailingText()

Move common trailing text outside of current choose

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 87
protected void optimizeChoose()

Optimize the current xsl:choose element

Return Value

void

at line 23
protected void adjustTextNodes(string $childType, int $pos, int $len = PHP_INT_MAX)

Adjust length of the text nodes of current xsl:choose element's branches

Parameters

string $childType

Either firstChild or lastChild

int $pos
int $len

Return Value

void

at line 42
protected int getPrefixLength(array $strings)

Compute the number of leading characters common to all strings

Parameters

array $strings

Return Value

int

at line 69
protected string[] getTextContent(string $childType)

Get the text content of the firstChild/lastChild of each branch if they are all text nodes

Parameters

string $childType

Either firstChild or lastChild

Return Value

string[]

List of strings or an empty array

at line 103
protected void optimizeLeadingText()

Move common leading text outside of current choose

Return Value

void

at line 124
protected void optimizeTrailingText()

Move common trailing text outside of current choose

Return Value

void