• 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

JEditorPane HTML parsing problem with about CSS

 
Greenhorn
Posts: 28
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello my friends,

I have a problem about JEditorPane html source. When I read html source to my editor it changes html source. How can make it unchangable or what is the reason of problem?
There is parsing problem style='font-size:11.0pt;font-family:"Palatino Linotype"' changes to font face="Palatino Linotype" size="11.0pt".

My input HTML:


But output source after reading to JEditorPane:


My simple source code:


Simple netbeans test application:
http://j.mp/dPSF5w

Thanks in advance
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTMLParser creates appropriate Document structure from the html source string. It measn kind of Tree of Elements. Some attributes are handled on leaves of the tree (e.g. the text attributes). But when html is written back HTMLWriter uses the structure of Elements and provides representation of the structure. I guess if you reopen the getText() result html the view will be the same.

Why they do this.

HTMLEditorKit supports editing so the initial structure can be changed. Storing source text of structure and reflecting changes in the source text is not possible (or let's better say complicated). So they just ignore the original text.

The same happens when you add some extra "\n" between tags. Extra "\n" after the paragraph end has no visual representation in the result view so it's skipped.

Hope this helps.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic