XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Posttop
Alan SearleSubject: Parameterized 'Document()' ... is this possible ?
Author: Alan Searle
Date: 27 Sep 2006 07:44 AM
Hallo Everyone

I have a quirky issue that I hope you can help me with:

I have been using javascript to apply filters/sorts to a simple combination of one XSL file based directly on one XML file. This works fine. However, now I would like to switch the underlying XML file dynamically and find that, although Document() will accept an initialised parameter (declared in the code) and will display data from external XML correctly, when I try to 'flip' the source (i.e. from file1.xml to file2.xml) my javascript seems to be 'neutralized'. Is this because it can only operate on the data loaded initially and cannot post-load other XML files?

Below is a more detailed explanation and I do hope that someone can help me out.

Regards and thanks,
Alan Searle

Explanation:

Here are excerpts from my code. The A:, B:, C: labels indicate the variations which I have tried.

A: and B: work but C: only partly. Here is the code ...

<form name="formfilt" id="formfilt">
<label for="selsrce">Source</label><br />
<select size="5" name="selsrce" id="selsrce">
<!-- internal/base XML -->
A: <xsl:apply-templates select="person" mode="fl" />
<!-- hard-coded list -->
B: <option value="Pete">Pete</option>
<option value="Bob">Bob</option>
<!-- external XML -->
C: <xsl:apply-templates select="document('people.xml')" mode="fl" />
</select>
<input type="button" value="ausführen" onclick_="proc(document.formfilt.selsrce.value)"/>
</form>

[...]

<xsl:template match="people/person" mode="fl">
<option value="{.}"><xsl:value-of select="."/></option>
</xsl:template>

Here is the explanation ...

I want to use this picklist (<select>) to provide a selectable list to the users and find that ...

A: I can generate a selectable list of people from the base XML (i.e. the XML from where the XSL is called):

<?xml-stylesheet href="data.xsl" type="text/xsl"?>
<?xml version="1.0"?>
<people>
<person>Pete</person>
<person>Bob</person>
</people>

B: I can select from a list hard-coded into the XSL.

Both of these options (A: and B are selectable and my javascript can process (and display) the result OK.

However, with version C:, where the list is stored in an external XML (i.e. people.xml), I find that I can display the list in the <select> box but, aarrrggghhh, this is not selectable (i.e. my javascript doesn't react).

I have changed nothing in my code except switch the source to the external file (file is named differently).

I am really confused about this: Why should it be that the contents of the external file can be displayed but that this stops the selection? Indeed, I even tried running it with the external file declared but the contents of the list hard-coded ...

<xsl:template match="people/person" mode="fl">
<option value="Pete">Pete</option>
</xsl:template>

... and this also didn't work.

This makes me think that the fact that I cam connecting external files is messing up my ability to allow the user to select the alternative file.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.