8000 Passing parameters? · Issue #17 · joepjoosten/XSL-tester · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Passing parameters? #17
Open
Open
@UgmaDevelopment

Description

@UgmaDevelopment

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:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <!-- Here we declare the parameter that we expect to be passed in. -->
    <xsl:param name="currentDate"/>
    
    <!-- This block copies the whole thing (the input) into the output. -->
    <xsl:template match="node() | @*">
        <xsl:copy>
            <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
    </xsl:template>
  

    <!-- This block replaces the `date_created` attribute of the Message element with the current date. -->
    <xsl:template match="/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:attribute name="{name()}"> 
            <xsl:value-of select="$currentDate"/>
        </xsl:attribute>
    </xsl:template>
    
    
</xsl:stylesheet>

Thank you for efforts in making your useful tool public.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0