View Single Post
 
Old September 26th, 2006, 10:09 AM
asearle asearle is offline
Authorized User
 
Join Date: Sep 2006
Location: Cologne, , Germany.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Document() ... parameterized ?

Dear All,

I have been experimenting with switching the data sources (i.e. switching between XMLs) and have managed to get my XSL to incorporate more than one XML file. That's great :-)

Now I want to parameterize the whole thing but am not sure weather I am attempting an illegal operation. Maybe somone can check my code. This is a snippet of the problem section ...

<xsl:choose>
 <xsl:when test="$source">
      <table>
      <xsl:value-of select="$source" />
      <xsl:apply-templates select="document($source)" mode="disp">
      </xsl:apply-templates>
     </table>
 </xsl:when>
</xsl:choose>

Here, I use a little block of JavaScript to rewrite the page. This code works fine with many other filtering and sort operations and seems to also be working OK here because my debugging line ...

<xsl:value-of select="$source" />

... successfully displays the item selected.

The variable that I have declared ...

<xsl:param name="source" select="'file2.xml'" />

... also seems to work fine because when I hope up the whole thing, the correct data is displayed.

So therefore I am a bit confused: my debug shows that my javascript has successfully changed the content of $source and the data is displayed when the form is opened (i.e. displayed according to the default value of $source) but when I switch the value, the data refuses to change.

Maybe I have a syntax error? Or maybe it is just not possible to change a Document() declaration 'on-the-fly'? I'm not sure.

Anyway, I hope that someone can help me out with this one because it would be great if I could get the XML sources to switch on command :-)

Many thanks,
Alan Searle