Java Forum / General / October 2007
chopping of string
gk - 04 Oct 2007 12:45 GMT i need a method which will take a string , if the string has more than 30 chars then it will chop that big string into chunk of 30 chars seperated by <br> tag in them.
how to do it ?
A_very_big_string will be midified into string_30_chars +"<br>"+string_30_chars+"<br>"+string_30_chars+"<br>"+remaining
and the final modified string should be returned
Roedy Green - 04 Oct 2007 13:16 GMT >i need a method which will take a string , if the string has more than >30 chars then it will chop that big string into chunk of 30 chars >seperated by <br> tag in them. You need a loop, a StringBuilder and the substring method.
Is this homework?
For a production system, you would want to insert your <BR> at word boundaries.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Chris Dollin - 04 Oct 2007 13:50 GMT > i need a method which will take a string , if the string has more than > 30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 6 lines] > > and the final modified string should be returned Are you /sure/ that's the spec you want?
Consider
(((( Software development is an exciting but messy business. ))))
where the thirty-character axe will [1] slice this into
(((( Software development is an exc<br>iting but messy business. ))))
which will display as something like
(((( Software development is an exc iting but messy business. ))))
I'd rather my words weren't ch opped around like that, but yo ur use-case may differ.
[1] If I can count.
 Signature Chris "careful with that axe, gk" Dollin
Hewlett-Packard Limited registered no: registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England
gk - 04 Oct 2007 14:00 GMT > > i need a method which will take a string , if the string has more than > > 30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 39 lines] > Hewlett-Packard Limited registered no: > registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England I have no other choice but to do that way .
because , my jsp table's column is getting stretched from the DB's long text.
so, i want to make it formatted before putting into the table. i would like to add <br> tags so that in the final html , it will wrapped and will give newlines.
so, i need that method.
do you know any other easy alternative ?
Thomas Kellerer - 04 Oct 2007 14:14 GMT gk, 04.10.2007 15:00:
> I have no other choice but to do that way . > [quoted text clipped - 8 lines] > > do you know any other easy alternative ? Why not simply tell the browser to wrap the content of the table cell? That would be the CSS attribute: white-space:normal. Usually the browsers do that be default unless there are no (white)spaces in the retrieved data.
Thomas
gk - 05 Oct 2007 03:58 GMT > gk, 04.10.2007 15:00: > [quoted text clipped - 17 lines] > > Thomas I dont think , this might work ....does it work in firefox too ? may be it will work in IE but not other browsers.
I surfed net and found the best thing is to do it in the server side ...from server side , it needs to be modified .
Thomas Kellerer - 05 Oct 2007 08:06 GMT gk, 05.10.2007 04:58:
>> Why not simply tell the browser to wrap the content of the table cell? >> That would be the CSS attribute: white-space:normal. Usually the [quoted text clipped - 8 lines] > I surfed net and found the best thing is to do it in the server > side ...from server side , it needs to be modified . This is standard HTML and works in Firefox and IE. But as I said, in order for the browser to be able to wrap the text it needs whitespaces. So if your data does not contain whitespaces (or some words are actually longer that the table cell) then it won't work.
Thomas
gk - 05 Oct 2007 14:35 GMT > gk, 05.10.2007 04:58: > >> Why not simply tell the browser to wrap the content of the table cell? [quoted text clipped - 14 lines] > So if your data does not contain whitespaces (or some words are actually > longer that the table cell) then it won't work. why do you mean by "...some words are actually longer that the table cell..." ???
I have a column of width 25% where as total table width=100%. Now, if i get a long word from DB say with 1500 chars , will it be wrapped ? or it will continue the long same line ?
In this case , i want it wrapped and i also dont like to use <textarea> with annoying scrollbar.
> Thomas Lew - 05 Oct 2007 14:42 GMT > In this case , i want it wrapped and i also dont like to use > <textarea> with annoying scrollbar. What's really annoying is when text is larger than the display area and there isn't a scroll bar.
 Signature Lew
Andrew Thompson - 05 Oct 2007 17:44 GMT >> gk, 05.10.2007 04:58: >> >> Why not simply tell the browser to wrap the content of the table cell? [quoted text clipped - 4 lines] >why do you mean by "...some words are actually longer that the table >cell..." ??? If 25% of the screen is this long ' ', that is the table cell width, but if the word is.. SuperCalaFragilisticExpyAladocious ..long, it will be a word that is 'longer that the table cell'.
Ultimately though, it sounds better not to set table width or cell widths as %, pixels, colspan or anything else, dump the text directly to the cells, and let the browser render it as it sees fit. After all, browser manufacturers put a lot of effort into getting marked-up content to display in a way that is both visually pleasing, and logical, to the end user.
Of course, I can almost guess that now you will jump in with how you want fixed /height/ rows..
 Signature Andrew Thompson http://www.athompson.info/andrew/
Thomas Kellerer - 05 Oct 2007 18:01 GMT Andrew Thompson wrote on 05.10.2007 18:44:
> Ultimately though, it sounds better not to set table > width or cell widths as %, pixels, colspan or anything > else, Unfortunately it seems that web designer seem to more and more see the browser (and thus HTML) as a kind of GUI tool where you can create layout that are optimized to the pixel (we want exactly 2 pixel border between each element, the table should start 53pixels off the left margin and 62 pixels down from the top, etc...)
Thomas
Andrew Thompson - 05 Oct 2007 19:58 GMT >Andrew Thompson wrote on 05.10.2007 18:44: >> Ultimately though, it sounds better not to set table [quoted text clipped - 5 lines] >table should start 53pixels off the left margin and 62 pixels down from the top, > etc...) I agree. HTML is not WYSIWYG, it is WUGIWUW*, and for good reason. It's all about the content - layout and styles be damned and be cast out - if they get between me and the information.
* What User Gets, Is What User Wants.
 Signature Andrew Thompson http://www.athompson.info/andrew/
gk - 06 Oct 2007 15:24 GMT > >> gk, 05.10.2007 04:58: > >> >> Why not simply tell the browser to wrap the content of the table cell? [quoted text clipped - 14 lines] > else, dump the text directly to the cells, and let the > browser render it as it sees fit. I cant do that .
because , i want my table should be the whole screen of the browser ...so table=100%
and i know , how many columns i would have ...9 columns.
so, i can distribute the above 100% into 9 columns . However , i would give more % to those column for which i know DB text records are longer , and finally i would like to adjust the whole width to 100%.
I have checked your solution . i have put white space normal as a style attribute in my columns (<td>) but unfortunately it did not work ...still i am getting stretched long words and scrollbar.
After all, browser
> manufacturers put a lot of effort into getting marked-up > content to display in a way that is both visually pleasing, [quoted text clipped - 7 lines] > > Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200710/1 Chris Dollin - 04 Oct 2007 15:25 GMT >> > i need a method which will take a string , if the string has more than >> > 30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 35 lines] > > I have no other choice but to do that way . You have /several/ other choices, starting ...
> because , my jsp table's column is getting stretched from the DB's > long text. ... with not worrying about it, and continuing with setting a width on the table column and leaving the chopping to the renderer.
> so, i want to make it formatted before putting into the table. > i would like to add <br> tags so that in the final html , it will > wrapped and will give newlines. > > so, i need that method. That method chops words into parts. I can't imagine [1] that this is a good thing, and it could produce misleading text.
> do you know any other easy alternative ? Chop the string at spaces (.split) and then reassemble lines from the components until they'd be too long. Remember to cater for word(-like thing)s that are 30+ characters long. Maybe a little more code, but less chance of mangling text.
 Signature Chris "carve thee not" Dollin
Hewlett-Packard Limited registered office: Cain Road, Bracknell, registered no: 690597 England Berks RG12 1HN
Piotr Kobzda - 04 Oct 2007 22:51 GMT >> do you know any other easy alternative ? > > Chop the string at spaces (.split) and then reassemble lines > from the components until they'd be too long. Remember to > cater for word(-like thing)s that are 30+ characters long. > Maybe a little more code, but less chance of mangling text. More advanced chopping algorithms may utilize locale dependent java.text.BreakIterator instead of String splitting. In the OP's scenario the line breaking iterator (i.e. created using BreakIterator.getLineInstance()), which will take care of proper handling of punctuation and hyphenated words, seems to be the right choice.
piotr
gk - 05 Oct 2007 04:00 GMT > >> > i need a method which will take a string , if the string has more than > >> > 30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 44 lines] > width on the table column and leaving the chopping to the > renderer. No , thats does not work.....browser cant render it. I have already tried with a fixed column width =25%.....this column is getting stretched automatically when big texts are coming up
> > so, i want to make it formatted before putting into the table. > > i would like to add <br> tags so that in the final html , it will [quoted text clipped - 17 lines] > Hewlett-Packard Limited registered office: Cain Road, Bracknell, > registered no: 690597 England Berks RG12 1HN Dag Sunde - 05 Oct 2007 08:52 GMT >> >> > i need a method which will take a string , if the string has more >> >> > than >> >> > 30 chars then it will chop that big string into chunk of 30 chars >> >> > seperated by <br> tag in them. <snipped/>
>> ... with not worrying about it, and continuing with setting a >> width on the table column and leaving the chopping to the [quoted text clipped - 3 lines] > tried with a fixed column width =25%.....this column is getting > stretched automatically when big texts are coming up Then either your HTML or CSS is wrong, because that is perfectly doable, and will work in "all" browsers when done right.
You might ask how to do it in a html and/or CSS group, or if it is a *very* short sample, post an URL, so we can take a look at your HTML/CSS...
 Signature Dag.
Brian - 04 Oct 2007 15:58 GMT >i need a method which will take a string , if the string has more than >30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 6 lines] > >and the final modified string should be returned A simple suggestion:
public String chopString(String s) { String tmp = ""; for (int i = 0; i < s.length() - 1; i++) { if (tmp.length() % 30 == 0) tmp += "<br>"; tmp += s.substring(i, i + 1); } return tmp; }
Hope it is usefull :)
/Brian
Chris ( Val ) - 04 Oct 2007 17:09 GMT > >i need a method which will take a string , if the string has more than > >30 chars then it will chop that big string into chunk of 30 chars [quoted text clipped - 12 lines] > String tmp = ""; > for (int i = 0; i < s.length() - 1; i++) { What is the reason for the '-1' placed after the length() call?
-- Chris
Brian - 04 Oct 2007 21:11 GMT >> public String chopString(String s) { >> String tmp = ""; >> for (int i = 0; i < s.length() - 1; i++) { > >What is the reason for the '-1' placed after >the length() call? The first char is placed at index(0) and the last char at index(length-1)
/Brian
Steve Wampler - 04 Oct 2007 21:35 GMT >>> public String chopString(String s) { >>> String tmp = ""; [quoted text clipped - 3 lines] > The first char is placed at index(0) and the last char at > index(length-1) I think Chris is pointing out that the test is "<", not "<=". (Consider the case where the length of the input string is 1.)
 Signature Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud.
Chris ( Val ) - 05 Oct 2007 12:05 GMT > >>> public String chopString(String s) { > >>> String tmp = ""; [quoted text clipped - 7 lines] > not "<=". (Consider the case where the length of > the input string is 1.) Yes, that is correct.
I have a good grounding in C++, and every time I see that kind of thing it raises alarm bells :-)
Given that arrays are zero based, there is almost never a need to use the '<=' operator for the conditional expression either :-)
Cheers, Chris
Patricia Shanahan - 04 Oct 2007 21:48 GMT >>> public String chopString(String s) { >>> String tmp = ""; [quoted text clipped - 5 lines] > > /Brian so there should be an iteration with i equal to length-1, but the combination of the "<" test and the "-1" ensures that the maximum value of i for any iteration is length-2.
Patricia
Steve Wampler - 04 Oct 2007 18:34 GMT > A simple suggestion: If splitting on word boundaries isn't an issue (and Chris Dollin's solution is a better approach for that problem) then there's no need to look at every character:
public String chopString(String s, int blkSize) { String ns = ""; while (s.length() > blkSize) { ns += s.substring(0,blkSize)+"<br>"; s = s.substring(blkSize); } ns += s; return ns }
 Signature Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud.
Brian - 04 Oct 2007 21:12 GMT >> A simple suggestion: > [quoted text clipped - 11 lines] > return ns > } Agree - this is a much better aproach than mine :)
/Brian
Joshua Cranmer - 04 Oct 2007 22:13 GMT >> A simple suggestion: > [quoted text clipped - 11 lines] > return ns > } Repeatedly appending Strings together can have a /huge/ performance hit. I managed to speed one of my programs up by 7x when the String concatenation was the limiting factor. Better code:
StringBuilder ns = new StringBuilder(); while (s.length() > blkSize) { ns.append(s.substring(0,blkSize)).append("<br>"); s = s.substring(blkSize); } ns.append(s); return ns;
 Signature Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Steve Wampler - 05 Oct 2007 01:17 GMT > Repeatedly appending Strings together can have a /huge/ performance hit. > I managed to speed one of my programs up by 7x when the String [quoted text clipped - 7 lines] > ns.append(s); > return ns; Very good point. My baby duck syndrome is showing.
 Signature Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud.
Roedy Green - 05 Oct 2007 02:37 GMT On Thu, 04 Oct 2007 21:13:29 GMT, Joshua Cranmer <Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who said :
> s = s.substring(blkSize); does thing copy the whole string each time?
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Lew - 05 Oct 2007 03:05 GMT > On Thu, 04 Oct 2007 21:13:29 GMT, Joshua Cranmer > <Pidgeot18@verizon.net> wrote, quoted or indirectly quoted someone who [quoted text clipped - 3 lines] > > does thing copy the whole string each time? Typical implementation is to point s to the new location in the already-allocated buffer, so not usually, no.
No guarantees.
 Signature Lew
Roedy Green - 05 Oct 2007 02:34 GMT >public String chopString(String s) { >String tmp = ""; [quoted text clipped - 5 lines] >return tmp; >} Here is another implementation:
public class BreakString {
/** * break up a String into lines, and separate them with <br>, * breaking into lineLength chunks, ignoring word boundaries. * This code is optimised for speed by attempting to keep the inner loop * as tight as possible, at the expense of some extra setup work. * @param s string to break * @param lineLength length of desired lines (not counting the <br>). * @return string with <br> separators inserted. */ public static String breakString(String s, int lineLength) { final int stringLength = s.length();
if ( stringLength <= lineLength ) { return s; }
// count of one or more lines, including partial lines. // Last line may be full or partial. final int lines = (stringLength + lineLength - 1 ) / lineLength;
// compute space needed for original string // plus a <br> on all but the last line. final StringBuilder sb = new StringBuilder(stringLength + ( "<br>\n".length() * ( lines-1 ) ) );
// do all but the last line, possibly 0 lines. final int startOfLastLine = (lines-1) * lineLength; for ( int i=0; i < startOfLastLine; i+= lineLength ) { // copy over one complete line. sb.append( s.substring( i, i+lineLength ) ); sb.append( "<br>\n" ); }
// copy over the last line, full or partial without <br> sb.append( s.substring( startOfLastLine, stringLength ) );
return sb.toString(); }
/** * main, test driver * @param args not used. */ public static void main ( String[] args ) { System.out.println(breakString("123456789012345678901234567", 3)); System.out.println(breakString("123456789012345678901234567890", 30)); System.out.println(breakString("1234567890123456789012345678901", 30 ));
System.out.println(breakString("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 30) ); } }
}
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Roedy Green - 05 Oct 2007 02:36 GMT >i need a method which will take a string , if the string has more than >30 chars then it will chop that big string into chunk of 30 chars >seperated by <br> tag in them. A word processor would consider two other things in the algorithm: 1. word breaks 2. hyphenation for long words.
For a production system, you might look for a hyphenation word-wrap package to do this properly.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 05 Oct 2007 04:33 GMT > i need a method .. 'No you don't'. What is important to remember here, is the *goal*. The goal might be stated as: "I need a way to present long strings to the user in HTML, in a way that makes sense to them."
For the latter, try this..
<html> <body> <form> <textarea cols=30 rows=5> I need a method which will take a string , if the string has more than 30 chars then it will chop that big string into chunk of 30 chars. </textarea> </form> </body> </html>
..validation and refinement, left to the OP.
Andrew T.
Roedy Green - 05 Oct 2007 06:58 GMT On Thu, 04 Oct 2007 20:33:46 -0700, Andrew Thompson <andrewthommo@gmail.com> wrote, quoted or indirectly quoted someone who said :
><textarea cols=30 rows=5> >I need a method which will take a string , if >the string has more than 30 chars then it will >chop that big string into chunk of 30 chars. ></textarea> Just what CSS and HTML is supported in Java's rendering engine?
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 05 Oct 2007 07:21 GMT >On Thu, 04 Oct 2007 20:33:46 -0700, Andrew Thompson ><andrewthommo@gmail.com> wrote, quoted or indirectly quoted someone [quoted text clipped - 7 lines] > >Just what CSS and HTML is supported in Java's rendering engine? That is not relevant to the OP's immediate question, since they were (ultimately) referring to delivering text to a JSP, or to my reading of it 'HTML in a browser'.
OTOH, Java built in support for HTML includes coverage of HTML 3.2 elements (everything shown above) as well as a surprising amount of CSS (more than understood by your average Java programmer).
To get a basic idea of how a page will look, though, I find it easiest to give the URL to a JEditorPane via the constructor, then toss the JEP into a JScrollPane and show it in a JOptionPane.
 Signature Andrew Thompson http://www.athompson.info/andrew/
Roedy Green - 05 Oct 2007 08:17 GMT >>Just what CSS and HTML is supported in Java's rendering engine? > >That is not relevant to the OP's immediate question, >since they were (ultimately) referring to delivering text >to a JSP, or to my reading of it 'HTML in a browser'. Right. I was conflating this question with another where the guy was trying to print HTML using Java's rendering engine.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 05 Oct 2007 08:27 GMT >>>Just what CSS and HTML is supported in Java's rendering engine? >> [quoted text clipped - 4 lines] >Right. I was conflating this question with another where the guy was >trying to print HTML using Java's rendering engine. Uh-huh. Must have missed that other (sub-?)thread.
Usenet is *complex*. ;-)
 Signature Andrew Thompson http://www.athompson.info/andrew/
Andrew Thompson - 05 Oct 2007 08:42 GMT >>>Just what CSS and HTML is supported in Java's rendering engine? ..
>..I was conflating this question with another where the guy was >trying to print HTML using Java's rendering engine. You might try experimenting with this JWS based example. <http://www.physci.org/jws/#prs> I have not been able to do any testing with it for lack of a printer.
Unfortunately it is File(Service) and JTextArea based rather than URL and JEditorPane, as I was suggesting earlier, but it should not take much to adapt the GUI.
The build files can be downloaded at the anchor, specifically <http://www.physci.org/jws/printservice.zip> ..and launched in a sandbox by.. <http://www.physci.org/jws/printtest.jnlp>
 Signature Andrew Thompson http://www.athompson.info/andrew/
Roedy Green - 05 Oct 2007 08:41 GMT >To get a basic idea of how a page will look, though, I >find it easiest to give the URL to a JEditorPane via the >constructor, then toss the JEP into a JScrollPane and >show it in a JOptionPane. I wrote a snippet to display an HTML URL in Java then pointed it to my home page. The rendering is hopeless. It was not even smart enough to ignore comments.
see http://mindprod.com/jgloss/htmlrendering.html
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 05 Oct 2007 08:58 GMT >>To get a basic idea of how a page will look, though, I >>find it easiest to give the URL to a JEditorPane via the [quoted text clipped - 3 lines] >I wrote a snippet to display an HTML URL in Java then pointed it to my >home page. .. This URL? <http://mindprod.com/jgloss/jgloss.html>
>..The rendering is hopeless. It was not even smart enough to >ignore comments. Yes, I note they are visible, but had you validated* the page recently? One thing Java HTML rendering is *extremely* bad at, is dealing with malformed or invalid mark-up.
* <http://validator.w3.org/check?uri=http://mindprod.com/jgloss/jgloss.html>
 Signature Andrew Thompson http://www.athompson.info/andrew/
Roedy Green - 06 Oct 2007 02:06 GMT >Yes, I note they are visible, but had you validated the >page recently? One thing Java HTML rendering is >*extremely* bad at, is dealing with malformed or invalid >mark-up. Yes. I am quite fanatical about validation. Style sheets get validated by two different programs, and HTML markup via HTMLValidator. The fool JEditorPane is rendering all comments as text.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 06 Oct 2007 06:41 GMT >>Yes, I note they are visible, but had you validated the >>page recently? One thing Java HTML rendering is >>*extremely* bad at, is dealing with malformed or invalid >>mark-up. >Yes. I am quite fanatical about validation. The 2nd link (to the validator) identifed 8 validation errors at the moment I checked it.
>..Style sheets get >validated by two different programs, and HTML markup via >HTMLValidator. >The fool JEditorPane is rendering all comments as text. This example* does /not/ render HTML comments. 'Do you see me?' Can you produce an SSCCE** that supports your assertion?
* Admittedly, it uses a JLabel instead of a JEditorPane, but they use the same rendering engine.
** With HTML included, as opposed to coming off any potentially changeable source, such as a web page.
<sscce> import javax.swing.*;
/** Do comments in well formed HTML get rendered by Java's inbuilt rendering engine? This test, when run on Win XP Pro, suppresses the comment text from appearing. I.E. It is correctly rendered. */ class CheckHTMLRender {
static String message = "<HTML>" + "<BODY>" + "<H1>" + "Test HTML comments" + "</H1>" + "<!-- Do you see me? -->" + "<p>The comment above should not be visible." + "</BODY>" + "</HTML>";
public static void main(String[] args) { JLabel output = new JLabel(message); JOptionPane.showMessageDialog(null, output); } } </sscce>
 Signature Andrew Thompson http://www.athompson.info/andrew/
Roedy Green - 06 Oct 2007 11:27 GMT >This example* does /not/ render HTML comments. >'Do you see me?' Can you produce an SSCCE** that >supports your assertion? I pointed you to it earlier. See http://mindprod.com/jgloss/htmlrendering.html
You should recognise it. It is an implementation of your pseudocode.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Roedy Green - 06 Oct 2007 11:56 GMT >The 2nd link (to the validator) identifed 8 validation errors >at the moment I checked it. I got 4. I think it was complaining about my <link ...> instead of <link ... />. I am correcting them all throughout the site. W3 has gone down so I can't continue my validation experiments there.
That seems an unlikely error to cause it to render comments as text.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Roedy Green - 06 Oct 2007 13:17 GMT >The 2nd link (to the validator) identifed 8 validation errors >at the moment I checked it. The strange thing is now I have corrected the <link /> error (which propagated to create the other errors) and pass W3C, the rendering program just freezes, rather that butchering the rendering.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 06 Oct 2007 15:36 GMT >>The 2nd link (to the validator) identifed 8 validation errors >>at the moment I checked it. > >The strange thing is now I have corrected the <link /> error (which >propagated to create the other errors) and pass W3C, the rendering >program just freezes, rather that butchering the rendering. That's a bummer. I might look more closely into it later. Can you give me the exact URL of a page that is both valid and locking up? (I note that the original page I was validating, is now down to three errors, but still showing the comments).
 Signature Andrew Thompson http://www.athompson.info/andrew/
Roedy Green - 11 Oct 2007 21:48 GMT >That's a bummer. I might look more closely into it later. >Can you give me the exact URL of a page that is both >valid and locking up? The code I posted attempts to render my home page http://mindprod.com/index.html
The home page now passes W3C validation, and it suddenly mysteriously started rendering again in Java, but doing a bad job of it.
The code to render it in java is posted at http://mindprod.com/jgloss/htmlrendering.html
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Andrew Thompson - 09 Oct 2007 14:29 GMT > RoedyGreen wrote: (re: comments in HTML, as rendered by JEditorPane)
> >>Yes, I note they are visible, but had you validated the > >>page recently? ...
> >The fool JEditorPane is rendering all comments as text. I am *finally* convinced.
I went hunting for lint checkers (for Java), and of course the Java Glossary was in the top 5 hits, so I surfed over to.. <http://mindprod.com/jgloss/lint.html> ..then. I noticed something odd* in my 'browser' (IE 6) and did some further checking.
- That URL according to the W3C validator.. "This Page Is Valid HTML 4.01 Transitional!" - Contains comments - *Displays* the text of the comments when rendered in JEditorPane.
So, you are right in that even entirely valid and well-formed HTML can be screwed up to that extent, in the J2SE 1.6 JEditorPane.
Perhaps it is something in the styles.
What a pity. :-(
* Oh, and the odd thing? IE 6 inserts a 'space' to the right of the page content, for no apparent reason - all the content is rendered within 100% of the visible window width. This forces the page to always have a horizontal scrollbar, no matter how much/little screen space is devoted to it.
(mutters) Damn fool IE.
Andrew T.
Roedy Green - 11 Oct 2007 21:52 GMT On Tue, 09 Oct 2007 06:29:32 -0700, Andrew Thompson <andrewthommo@gmail.com> wrote, quoted or indirectly quoted someone who said :
>* Oh, and the odd thing? IE 6 inserts a 'space' >to the right of the page content, for no apparent >reason - all the content is rendered within 100% >of the visible window width. This forces the page >to always have a horizontal scrollbar, no matter >how much/little screen space is devoted to it. This is a bit of idiocy in IE Zoom. Compare Opera and IE Zoom. IE just tacks on scroll bars. Opera reflows the text to fit the bigger type.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|