
xsl = etree.XML(dedent( """<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp">
<xsl:template match="node()|@*"> xsl:copy <xsl:apply-templates select="node()|@*"/> </xsl:copy>
<xsl:variable name="destination_url"> <xsl:value-of
select="'https://my.domain.example.com/'" />
</xsl:variable>
<!--Set the destination URL in the context variable--> <dp:set-variable name="'var://context/mpgw/Destination'" value="$destination_url" />
I don't think I've ever tried this myself in lxml. I guess I would have expected value="{$destination_url}" rather than the plain variable reference here. Can't say how XSLT is meant to deal with this.
Just for the record: Like Stefan suspected the way to dereference a variable in XSLT here is value="{$destination_url}".
I.e. such stylesheet
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="my_var" select="'my value'"/> <xsl:template match="@*|node()"> <foo attr="$my_var">bar</foo> </xsl:template> </xsl:stylesheet>
yields
<?xml version="1.0" encoding="UTF-8"?><foo attr="$my_var">bar</foo>
whereas
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="my_var" select="'my value'"/> <xsl:template match="@*|node()"> <foo attr="{$my_var}">bar</foo> </xsl:template> </xsl:stylesheet>
yields
<?xml version="1.0" encoding="UTF-8"?><foo attr="my value">bar</foo>
Boy, am I getting rusty :-)
Holger
Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart HRA 4356, HRA 104 440 Amtsgericht Mannheim HRA 40687 Amtsgericht Mainz
Die LBBW verarbeitet gemaess Erfordernissen der DSGVO Ihre personenbezogenen Daten. Informationen finden Sie unter https://www.lbbw.de/datenschutz.