You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example that might clarify what I mean. Suppose you want to change the date in a file to the current date; using xsltransform.net, how could you pass that date in as a parameter?
Here's some XSL to illustrate my example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
<xsl:outputmethod="xml"omit-xml-declaration="yes"/>
<!-- Here we declare the parameter that we expect to be passed in. -->
<xsl:paramname="currentDate"/>
<!-- This block copies the whole thing (the input) into the output. -->
<xsl:templatematch="node() | @*">
<xsl:copy>
<xsl:apply-templatesselect="node() | @*"/>
</xsl:copy>
</xsl:template>
<!-- This block replaces the `date_created` attribute of the Message element with the current date. -->
<xsl:templatematch="/Message/@date_created">
<!-- The name attribute is required, so we just specify the same name as before. `name()` uses the same name the attribute had previously; we don't want to change the attribute name, just its value. -->
<xsl:attributename="{name()}">
<xsl:value-ofselect="$currentDate"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Thank you for efforts in making your useful tool public.
The text was updated successfully, but these errors were encountered:
It's indeed not possible to set parameters when the template is called. You could just set the value attribute in the parameter, which will act as a default value. You could pass a value via the XML input, and select that as the default value.
Hello!
Is there a way to pass parameters to the engine?
Here's an example that might clarify what I mean. Suppose you want to change the date in a file to the current date; using xsltransform.net, how could you pass that date in as a parameter?
Here's some XSL to illustrate my example:
Thank you for efforts in making your useful tool public.
The text was updated successfully, but these errors were encountered: