This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: displaying only certain parts of an xml doc using xsl
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 15 Apr 2002 14:01:25 +0100
- Subject: RE: [xsl] displaying only certain parts of an xml doc using xsl
- Reply-to: xsl-list at lists dot mulberrytech dot com
Your code looks OK to me at first sight. Which means that the error is
somewhere in a part that you didn't show us.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Denis
> McCarthy
> Sent: 15 April 2002 13:03
> To: XSL-List@lists.mulberrytech.com
> Subject: [xsl] displaying only certain parts of an xml doc using xsl
>
>
> 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
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list