Friday, 15 March 2013

java - How to set parameters in XSL stylesheet with the help of Transformer object when i have my xml generated dynamically in jsp -


I'm retrieving all the values ​​in a list to set parameters for your XSL stylesheet.I and that Need to create dynamic XML using jsp? Therefore no external XML file has been created in this process .. But now I need to set variables in XSLT stylesheet. But as no XML file has been made, I am finding it difficult to change the object. Here is my code

  & lt;% @ page contentType = "text / xml"%> & LT;% @ page import = "java.util.ArrayList, aj.model.BriefBoardDetail, javax.xml.transform.Transformer, javax.xml.transform.TransformerFactory, javax.xml.transform.stream.StreamSource"% & gt ; & Lt;% ArrayList & lt; BriefBoardDetail & gt; List = (ArrayList) request.getAttribute ("Board list"); Int countofPages = (integer) request.getAttribute ("countOfPages"); Int paynumber = (integer) request.getAttribute ("current page number"); Transformer transformer = Tronsfarmrfaccrknuinstens () Knveen Tronsformr (new Strymsors ( "/ XSLT / Indekspejastail. XSL")); Transformer. Sitemapator ("current page", page number); Transformer .setParameter ("last page", countof page); Transformer.transform (???, ???); // What do I need to set up here? & Gt%; & Lt; ?? Xml- stylesheet type = "text / XSL" href = "xslt / indexPageStyle.xsl" version = "1.0" encoding = "UTF-8" & gt; & Lt; AlgorithmHome & gt; & Lt;% (short bourdat bbs: list) {%> & Lt; Subject id = '& lt;% = bbs.getBoardId ()% & gt; & Gt; & Lt; Name & gt; & Lt;% = bbs.getBoardName ()% & gt; & Lt; / Name & gt; & Lt; Description & gt; & Lt;% = bbs.getDescription ()% & gt; & Lt; / Description & gt; & Lt; / Subject & gt; & Lt;%}% & gt; & Lt; / Algorithm Home & gt;  

Then I need to set countOfPages and PAGENUMBER in indexPageStyle.xsl.But as XML is generated dynamically in this, then JSP I XMLSource and Need to determine what outputTarget transformer.transform (XMLSource, outputTarget) if I need to display it in the browser.

After

I made some changes to the above code and this ..

  & Lt worked fine;% @ page contentType = "text / html; charset = ISO-8859-1"%> & Lt;% @ Page Import = "java.util.ArrayList, aj.model.BriefBoardDetail"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> & Lt;% @ taglib uri = "http://java.sun.com/jsp/jstl/xml" prefix = "x"%> & Lt;% ArrayList & lt; BriefBoardDetail & gt; List = (ArrayList) request.getAttribute ("Board list"); Integer countofPages = (integer) request.getAttribute ("countOfPages"); Integer page number = (integer) request.getAttribute ("current page number"); & Gt%; & Lt; C: set var = "xmldata" & gt; & Lt; AlgorithmHome & gt; & Lt;% (short bourdat bbs: list) {%> & Lt; Subject id = '& lt;% = bbs.getBoardId ()% & gt; & Gt; & Lt; Name & gt; & Lt;% = bbs.getBoardName ()% & gt; & Lt; / Name & gt; & Lt; Description & gt; & Lt;% = bbs.getDescription ()% & gt; & Lt; / Description & gt; & Lt; / Subject & gt; & Lt;%}% & gt; & Lt; / Algorithm Home & gt; & Lt; / C: Set & gt; & Lt; C: import url = "/ xslt / indexPageStyle.xsl" var = "xslt" /> & Lt; X: Change xml = "$ {xmldata}" xslt = "$ {xslt}" & gt; & Lt; X: Ultimate name = "current page" value = "$ {paragraph: page number}" /> & Lt; X: Ultimate name = "last page" value = "$ {param: count page}" /> & Lt; / X: Conviction & gt;  

All this is working fine but now I have to pass both the counting pages and pagnambar for my xsl stylesheet. But I can not pass it. I was able to get all the google and strings string inside for the price tag. I am very confused ... please tell me a value


No comments:

Post a Comment