hasAttribute('mode')) { throw new RuntimeException('xsl:apply-templates elements do not support the mode attribute'); } } protected function checkXslCopyOfElement(DOMElement $copyOf): void { $this->requireAttribute($copyOf, 'select'); } protected function checkXslAttributeElement(DOMElement $attribute): void { $this->requireAttribute($attribute, 'name'); $attrName = $attribute->getAttribute('name'); if (!preg_match('(^(?:\\{[^\\}]++\\}|[-.\\pL])++$)Du', $attrName)) { throw new RuntimeException("Unsupported xsl:attribute name '" . $attrName . "'"); } } protected function checkXslElementElement(DOMElement $element): void { $this->requireAttribute($element, 'name'); $elName = $element->getAttribute('name'); if (!preg_match('(^(?:\\{[^\\}]++\\}|[-.\\pL])++(?::(?:\\{[^\\}]++\\}|[-.\\pL])++)?$)Du', $elName)) { throw new RuntimeException("Unsupported xsl:element name '" . $elName . "'"); } } protected function checkXslIfElement(DOMElement $if): void { $this->requireAttribute($if, 'test'); } protected function checkXslValueOfElement(DOMElement $valueOf): void { $this->requireAttribute($valueOf, 'select'); } protected function checkXslVariableElement(DOMElement $variable): void { $this->requireAttribute($variable, 'name'); } protected function checkXslWhenElement(DOMElement $when): void { $this->requireAttribute($when, 'test'); } protected function requireAttribute(DOMElement $element, string $attrName) { if (!$element->hasAttribute($attrName)) { throw new RuntimeException('xsl:' . $element->localName . ' elements require a ' . $attrName . ' attribute'); } } }