[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|