1

I have a question regarding the XSLT, basically I have some transformation to do, but at the end i would like to have all the transformations i've done inside one xslt:variable.

Basically what i mean is something like this, of course the xslt will be more complex, but just to illustrate what i mean is following:

<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="html" indent="no"/>
    <xsl:decimal-format NaN=""/>
    <xsl:template match="/">
        <xsl:call-template name="base_template"/>
    </xsl:template>

    <xsl:template name="base_template">
            <!-- This is what i mean -->
            <xsl:variable name="general_variale">

                <xsl:call-template name="template_three" />

                <br />

                <xsl:call-template name="template_two" />

                <br />

                <xsl:call-template name="template_one" />               

            </xsl:variable>
        </xsl:template>

            <xsl:template name="template_three">
            <xsl:for-each select="$Rows">   

                <xsl:variable name="id" select="@ID" />

                <xsl:for-each select="$filteredRows_Releases">
                    <process name="$id">
                        ....
                    </process>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:template>

        <xsl:template name="template_two">
            <xsl:for-each select="$Rows">   

                <xsl:variable name="id" select="@ID" />

                <xsl:for-each select="$filteredRows_Releases">
                    <task name="$id">
                        ....
                    </task>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:template>
</xsl:stylesheet>

With this xslt i would like to have a general_variable look somethink like this:

<process name="somename">
</process>
...
<task name="somename">
</task>
...

Will this work or it isn't possible?

6
  • "...but at the end i would like to have all the transformations i've done inside one <xsl:variable>." Why would you want that? Please explain, because as it stands this intent does not make a lot of sense. Commented Sep 12, 2013 at 6:31
  • because I have xml which i have to parse to a correct form of another xml and then pass this as an variable (by parameter) to some flash programm Commented Sep 12, 2013 at 6:42
  • Still does not make sense. XSLT variables and Flash variables have nothing in common. Use XSLT to transform your XML, use your host language to pass the transformation result to Flash. That's two separate steps, you cannot do this from within XSLT. Commented Sep 12, 2013 at 6:44
  • I have to have the variable with the correct format, then i create again by xslt some tags which initialize this on the page and in this tags i should set attribute data to the xslt variable Commented Sep 12, 2013 at 7:05
  • but it doesn't really matter what to do, i just would like to know for sure if it will work or not this thing with creating on this way the variable Commented Sep 12, 2013 at 7:10

1 Answer 1

1

Yes, you can capture the result of any processing in a variable in this way.

However, in XSLT 1.0 there are restrictions on how you can use the resulting variable: it's known as a result tree fragment. If you want to process it in any interesting ways, you will need the exslt:node-set() extension to convert it to a regular document tree. In XSLT 2.0 this restriction is removed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.