diff --git a/src/Xsl/Node/AttributeName.php b/src/Xsl/Node/AttributeName.php new file mode 100644 index 0000000..90ef875 --- /dev/null +++ b/src/Xsl/Node/AttributeName.php @@ -0,0 +1,47 @@ +xpathCompiler = $compiler; + } + + /** + * @param DOMElement $element + * @return bool + */ + public function supports(DOMElement $element): bool + { + return $element->hasAttribute('name'); + } + + /** + * @param DOMElement $element + */ + public function transform(DOMElement $element): void + { + $element->setAttribute( + 'name', + $this->xpathCompiler->compile( + $element->getAttribute('name'), + $element + ) + ); + } +} diff --git a/src/Xsl/Transformer.php b/src/Xsl/Transformer.php index 64851e2..20619d9 100644 --- a/src/Xsl/Transformer.php +++ b/src/Xsl/Transformer.php @@ -13,6 +13,7 @@ use Genkgo\Xsl\Util\FetchNamespacesFromNode; use Genkgo\Xsl\Xpath\Compiler; use Genkgo\Xsl\Xsl\Node\AttributeExpandText; +use Genkgo\Xsl\Xsl\Node\AttributeName; use Genkgo\Xsl\Xsl\Node\AttributeValueTemplates; use Genkgo\Xsl\Xsl\Node\AttributeMatch; use Genkgo\Xsl\Xsl\Node\AttributeSelect; @@ -147,6 +148,7 @@ public static function newDefaultTransformer( new AttributeExpandText($xpathCompiler), new AttributeMatch($xpathCompiler), new AttributeSelect($xpathCompiler), + new AttributeName($xpathCompiler), new AttributeTest($xpathCompiler), new ElementValueOf(), new ElementAttribute(), diff --git a/test/Stubs/Xsl/ElementAttribute/attribute.xsl b/test/Stubs/Xsl/ElementAttribute/attribute.xsl index 38c4370..31e7390 100644 --- a/test/Stubs/Xsl/ElementAttribute/attribute.xsl +++ b/test/Stubs/Xsl/ElementAttribute/attribute.xsl @@ -5,7 +5,7 @@ - +