[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

displaying only certain parts of an xml doc using xsl

Subject: displaying only certain parts of an xml doc using xsl
From: "Denis McCarthy" <dmccarthy@xxxxxxxxxxxxxxxx>
Date: Mon, 15 Apr 2002 13:02:52 +0100
parts of an xml doc
Hi there,
I'm trying to use server-side xsl in my jsp appliction for the first time
(using Xalan). I have an xml document (contact_details.xml) whch contains
several <institution> elements. I want to decide which institution element
to use dynamically on the jsp page by passing in a parameter to the xsl
document. However I am having trouble getting the xsl to process the element
I want. Here is the general layout of the xml file:
<?xml version="1.0"?>
<institutionList>
    <institution>
        <instId>00000002</instId>
        <pageHeading>blah blah</pageHeading>
        .
        .
    </institution>
    <institution>
        <instId>00000004</instId>
        .
        .
    </institution>
</institutionList>

In my xsl file, I want to only process the <institution> element whose
<instId> value is the same as a parameter that I pass in.
So at the moment, I am trying (in my xsl file)
    .
    .

    <xsl:param name="instId" select="'default'"/>

    <xsl:template match="/">
        <xsl:apply-templates
select="institutionList/institution[contains(instId,$instId)]"/>
     </xsl:template>

    followed by other generic formatting templates.
In the jsp page I have
<%
String paramValue = "00000002";
String xmlFile    = "http://dmccarthy/contact_details.xml";
String xslFile    =
"http://dmccarthy/ram/ramstatic/xsl/contactDetailsToHTML.xsl";
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer =
tFactory.newTransformer(new StreamSource(xslFile));
transformer.setParameter("instId", paramValue);
transformer.transform(
        new StreamSource(xmlFile), new StreamResult(out));
%>

I would think that this code should result in the displaying of the xml
<institution> element that has '00000002' as its <instId> value, but all I
get is a blank page. Could someone tell me where I'm going wrong?
Thanks very much



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.