• 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

ERROR: 'The declaration for the entity "ContentType" must end with '>'.'

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

I am using "Flying Saucer" to generate PDF document from my servlet. Here is my code:



If I am writing before <html> tag:

then following error appears:



If I am not writing before <html> tag:

then following error appears:

Thanks in anticipation
 
Marshal
Posts: 28257
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
So is that "setDocumentFromString" expecting a string containing XML? If so, then the error message is telling you that the XML you used is not well-formed. Or is it expecting HTML? From the names of the classes in the stack trace, it looks like it's expecting XHTML. In which case using a DTD which isn't for XHTML would be the wrong thing to do.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:So is that "setDocumentFromString" expecting a string containing XML? If so, then the error message is telling you that the XML you used is not well-formed. Or is it expecting HTML? From the names of the classes in the stack trace, it looks like it's expecting XHTML. In which case using a DTD which isn't for XHTML would be the wrong thing to do.



Please advise me what API I use to generate pdf by formating a String with simple HTML. I assume setDocumentFromString is used to generate pdf from String but it seems its generate from XHTML or XML

Thanks for favorable reply
 
Paul Clapham
Marshal
Posts: 28257
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
Why don't you just generate XHTML, then, since the API you have found works with that?

If your input comes from something which generates HTML which isn't well-formed XML, and you don't have any control over that, then why don't you just convert it to XHTML using something like JTidy?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Why don't you just generate XHTML, then, since the API you have found works with that?



I am formatting as HTML with my following method:


main method gets data from database and format as html


my nullCheck method:



If your input comes from something which generates HTML which isn't well-formed XML, and you don't have any control over that, then why don't you just convert it to XHTML using something like JTidy?


Please check my above code and let me know still I need JTidy because I am formatting data explicitly

Thanks again
 
Paul Clapham
Marshal
Posts: 28257
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
Are you suggesting that somebody could look at code like this:



and tell you for certain whether it is generating well-formed XML?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My public String nullCheck(String str, String title){ is converting it to HTML not XML

 
Paul Clapham
Marshal
Posts: 28257
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
I also don't understand why you have variables content10 and content11 which you don't use anywhere.

But this is rather pointless. You already have a competent authority (an XML parser) which tells you you aren't generating well-formed XML. Asking other people to tell you that you are actually generating well-formed XML isn't going to get you anywhere, since clearly you aren't. I suggest you consider some debugging. Consider looking at the XML which you generate and see what your eyes tell you.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I also don't understand why you have variables content10 and content11 which you don't use anywhere.



ohhs! you fixed my problem Paul Clapham by indicating content 10 and content11. Sometime the error is in front of our eyes but not seeing.

Thanks Paul from the bottom of my heart

Best regards
 
Paul Clapham
Marshal
Posts: 28257
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
Well, that's good. But I suggest that if you had taken the time to display the HTML you were producing, and to look at it with your own eyes, you would surely have noticed that the part at the end was missing.
 
reply
    Bookmark Topic Watch Topic
  • New Topic