aspose file tools*
The moose likes Other Open Source Projects and the fly likes ERROR:  'The declaration for the entity '.'" title="" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "ERROR:  Watch "ERROR:  New topic
Author

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

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
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
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Mar 22, 2008
Posts: 732
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Mar 22, 2008
Posts: 732
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Mar 22, 2008
Posts: 732
My public String nullCheck(String str, String title){ is converting it to HTML not XML

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Mar 22, 2008
Posts: 732
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ERROR: 'The declaration for the entity "ContentType" must end with '>'.'