• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

View several XSL documents in one HTML page

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

Suppose you want to print out several documents (Invoices) at once from a browser (HTML page). The invoice is generated in a servlet, where a XML document is translated into HTML using XSL transformation.

What I want is to call XMLOutputter in a servlet to print out several XML/XSL documents in a loop...

At this moment I have a JSP page calling a servlet. The servlet gets a XML document as Blob and translate in into HTML using a XSL file. This work fine, when I print one XML/XSL file only. Please see the code below:

JSP (PrintInvoice.jsp) code looks like this:


Servlet code (InvoiceResponse.java) looks like this:


What I want is to print out several XML/XSL and show it all in HTML.

When running a loop in my JSP code I get the error as follow:
Only one top level element is allowed in an XML document...

Please see the loop below:
JSP (PrintInvoice.jsp) code with loop looks like this:


Any idea how to loop and print several XML/XSL in HTML?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message is pretty clear, isn't it? You can only output one XML document. So continuing with the idea that you can output several XML documents is pointless. Don't waste your time fighting against the rules.

So, now your question is "How can I make several XML documents concatenated together look like a single XML document?" One solution would be to wrap the whole mess in a root element.
 
Jeppe Sommer
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:The error message is pretty clear, isn't it? You can only output one XML document. So continuing with the idea that you can output several XML documents is pointless. Don't waste your time fighting against the rules.

So, now your question is "How can I make several XML documents concatenated together look like a single XML document?" One solution would be to wrap the whole mess in a root element.



To wrap the whole mess in a root element gonna be pretty difficult right?! That´s how it works today:

Today:
1) For each loop we get a blob (XML file) from the database. Each file has it´s own root element.
2) Then we transform the XML file with a XSL file.
3) Then we output the the file.

The new solution:
1) For each loop we get a blob (XML file) from the database. Each file has it´s own root element that we will have to REMOVE.
2) For each loop we store the XML data in a StringBuffer.
3) Finnally we add ONE root element to the StringBuffer.
4) We change the current XSL to be able to transform the concatenated XML in the StringBuffer.
5) Then we output the the StringBuffer.

Is that the way? Is there any other ways? I guess we will have to output everything to a pdf file?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't have to be complicated. New solution:

(1) Output start tag of root element
(2) Output all of the documents
(3) Output end tag of root element

PDF!!!??? Where did that come from?
 
reply
    Bookmark Topic Watch Topic
  • New Topic