1

I am a noob, this is my first programming project. I aim to convert an XML feed to a filtered HTML table. The criteria for the filter needs to be provided by the user.

I have successfully managed to use XSLT to take XML data and display it as an HTML table.. My XML references an xsl file containg the XSLT. Now onto the next step – the filter.

For my explanation please refer to the following example data:

<teams>
    <team>
        Red Sox
    </team>
    <sport>
        Baseball
    </sport>
    <location>
        Boston
    </location>
    <team>
        White Sox
    </team>
    <sport>
        Baseball
    </sport>
    <location>
        Chicago
    </location>
    <team>
        Giants
    </team>
    <sport>
        Baseball
    </sport>
    <location>
        San Francisco
    </location>
</teams>

What I now want is to be able to select a value for via a drop down on the webpage and then filter the XML which is displayed, based on that input. So if they selected ‘Boston' it would only show the teams in Boston.

Is it possible to do this using javascript or will it not work since the XSLT transformation only occurs on loading– prior to the user selecting from the dropdown.

If it is possible using javascript, then what are some options to achieve this? Could javascript write a filter value dynamically to the xsl file? Or could I have a range of xsl files and the javascript selects the correct one?

If it is not possible using javascript could anyone suggest a way this can be accomplished? Elegance or speed is not an issue. I want to do this on the client side.

I should also add that there will be a predetermined number of ‘locations’ in my XML – 20 in fact.

Thanks!

1 Answer 1

0

I guess you can do that by using xslt parameters. See that question or search for the usage of parameter usage on xslt processors. You could hand over the filter values from the dropdowns to the processor and display that result.

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.