xsl-url chaining

Clicking on cdcatalog.xml results in two undef values, clicking on cdcatalog.1.xml or cdcatalog.2.xml demonstrates the passing of the variables.

Listings

cdcatalog.1.xml (click to see result of transformation) cdcatalog.2.xml (click to see result of transformation)
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl.xsl"?>
<xsl-url>cdcatalog.xml?query</xsl-url>
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl.xsl"?>
<xsl-url>cdcatalog.xml?answer=42</xsl-url>
cdcatalog.xsl.xsl (this passes $xsl-url to imported stylesheet)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="cdcatalog.xsl2.xsl" />
  <xsl:variable name="xsl-url" select="xsl-url" />
  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="/xsl-url">
        <xsl:for-each select="document(substring-before(concat($xsl-url,'?'),'?'))">
          <xsl:apply-templates select="." />
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-imports />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
cdcatalog.xsl2.xsl (this passes $xsl-url and $xsl-url2 to imported stylesheet)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="cdcatalog.xsl" />
  <xsl:variable name="xsl-url" select="'undef'" />
  <xsl:variable name="xsl-url2" select="'somethingelse'" />
  <xsl:template match="/">
    <xsl:apply-imports />
  </xsl:template>
</xsl:stylesheet>
cdcatalog.xml (click to see result of transformation) cdcatalog.xsl (see definition and output of $xsl-url and $xsl-url2)
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
  </cd>
  <cd>
    <title>The white album</title>
    <artist>Beatles</artist>
    <country>UK</country>
    <company>apple</company>
    <price>???</price>
    <year>196?</year>
  </cd>
</catalog>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:variable name="xsl-url" select="'undef'" />
  <xsl:variable name="xsl-url2" select="'undef'" />
  <xsl:template match="/">
    <html>
      <body>
        <h2>My CD Collection</h2>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th>Title</th>
            <th>Artist</th>
          </tr>
          <xsl:for-each select="catalog/cd">
            <tr>
              <td>
                <xsl:value-of select="title" />
              </td>
              <td>
                <xsl:value-of select="artist" />
              </td>
            </tr>
          </xsl:for-each>
        </table>
        <xsl:value-of select="$xsl-url" />
        :<xsl:value-of select="$xsl-url2" />
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>