Loop variable / parameter in XSLT variable

I have simple XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="form.xsl"?>
<x>
    <y>Hello</y>
</x>

and form.xsl:

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

<xsl:output encoding="UTF-8" method="xml" indent="yes"/>
<xsl:variable name="topLevel">
        <xsl:variable name="inner" select="'Hi'" />
        <xsl:value-of select="$inner"/>
</xsl:variable>

<xsl:template match="/" >
    <xsl:value-of select="$topLevel" />
</xsl:template>


</xsl:stylesheet>

I use JRE 1.8,, and when I convert the XML with javax.xml.transform.Transformer, I get a circular reference error in a variable topLevel.

Circular variable/parameter reference in '[variable(topLevel)]

I found out that the problem is related to this: JIRA , but I'm not sure if this is fixed,

There are various ways to work around the solution, but no solutions are provided.

Note . I have not included any third-party banks and use the standard Transformer implementation.

+4
source share
1 answer

What do you intend to write:

    <xsl:variable name="topLevel">
            <xsl:variable name="inner" select="'Hi'" />
            <xsl:value-of select="$inner"/>
    </xsl:variable>

This is not the same:

    <xsl:variable name="topLevel" select "'Hi'">
0
source

All Articles