HTML

F

freesoft_2000

Hi everyone,

I am trying to add html tables to a html document and
the html table appears but here is the problem in that only certain
attributes of the table is being adhered to and the rest ignored. This is
what i am doing

String table = "<table width="80%" height="80%" cellspacing="200"
cellpadding="10" border="20" bordercolor="#ff0033" bgcolor="#33ff33">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>";

Element ele = doc.getParagraphElement(Pane1.getCaretPosition());

try
{
doc.insertAfterEnd(ele, table);
}

catch(Exception e)
{
e.printStackTrace();
}

Please note that Pane1 is an instance of the JTextPane class and doc is an
instance of the HTMLDocument class which uses the default HTMLEditorKit
class.

The table appears in the document but only cell
padding, background color and table width options if varied produces the
appropriate changes to the table that is being inserted.

The rest of the options such as borderwidth,
bordercolor cell spacing and table height don't have any differences even
when they are varied. They always remain the same.

Basically i need to know if i am inserting the html
table correctly into the HTMLDocument or is there something that i need to
do which i am not doing in the above code.

I am using the java sdk 1.4.2

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
S

shakah

freesoft_2000 said:
Hi everyone,

I am trying to add html tables to a html document and
the html table appears but here is the problem in that only certain
attributes of the table is being adhered to and the rest ignored. This is
what i am doing

String table = "<table width="80%" height="80%" cellspacing="200"
cellpadding="10" border="20" bordercolor="#ff0033" bgcolor="#33ff33">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

Element ele = doc.getParagraphElement(Pane1.getCaretPosition());

try
{
doc.insertAfterEnd(ele, table);
}

catch(Exception e)
{
e.printStackTrace();
}

Please note that Pane1 is an instance of the JTextPane class and doc is an
instance of the HTMLDocument class which uses the default HTMLEditorKit
class.

The table appears in the document but only cell
padding, background color and table width options if varied produces the
appropriate changes to the table that is being inserted.

The rest of the options such as borderwidth,
bordercolor cell spacing and table height don't have any differences even
when they are varied. They always remain the same.

Basically i need to know if i am inserting the html
table correctly into the HTMLDocument or is there something that i need to
do which i am not doing in the above code.

I am using the java sdk 1.4.2

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West

You're probably running into HTML version support issues.

The Javadocs for HTMLEditorKit say, in part: "The default support is
provided by this class, which supports HTML version 3.2 (with some
extensions), and is migrating toward version 4.0."

The validator at htmlhelp.com:
http://htmlhelp.com/tools/validator/direct.html.en

spits out the following for your HTML when using a HTML 3.2 DOCTYPE
(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">):

<table width="80%" height="80%" cellspacing="200"
Error: there is no attribute HEIGHT for this element (in this
HTML version)

.... "10" border="20" bordercolor="#ff0033" bgcolor="#33ff33">
Error: there is no attribute BORDERCOLOR for this element (in
this HTML version)

.... ordercolor="#ff0033" bgcolor="#33ff33">
Error: there is no attribute BGCOLOR for this element (in this
HTML version)
 
A

Andrew Thompson

You're probably running into HTML version support issues.
[ snip detailed response ]

Aah yes. Good answer shakah. The '110%' answer that I neglected
to post. ( Mine was was more 'here is 5% - google the rest' )

To freesoft.. Having got that complete and clear answer from
shakah - why did you repost the question?
 
F

freesoft_2000

Hi everyone,

I got the same results as you when i ran the code via the
html validator which are as follows:

HTML Validation Results

Document Checked
Character encoding: ISO-8859-1
Level of HTML: HTML 3.2
Errors and Warnings
Line 9, character 27:
<table width="80%" height="80%" cellspacing="200"
^
Error: there is no attribute HEIGHT for this element (in this HTML
version)

Line 10, character 42:
... "10" border="20" bordercolor="#ff0033" bgcolor="#33ff33">
^
Error: there is no attribute BORDERCOLOR for this element (in this HTML
version)

Line 10, character 60:
... ordercolor="#ff0033" bgcolor="#33ff33">
^
Error: there is no attribute BGCOLOR for this element (in this HTML
version)

Input
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <html>
3 <head>
4
5 <title></title>
6
7 </head>
8 <body>
9 <table width="80%" height="80%" cellspacing="200"
10 cellpadding="10" border="20" bordercolor="#ff0033"
bgcolor="#33ff33">
11 <tr>
12 <td>&nbsp;</td>
13 <td>&nbsp;</td>
14 </tr>
15 <tr>
16 <td>&nbsp;</td>
17 <td>&nbsp;</td>
18 </tr>
19 <tr>
20 <td>&nbsp;</td>
21 <td>&nbsp;</td>
22 </tr>
23 </table>
24 </body>
25 </html>


It explains to me why the background color, table height and border color
does not work because the attributes are not supported.

What about the rest of the attributes such as cellspacing and
border, i am not getting any errors from them yet the same problem
persists. What do you think this is so??

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,096
Members
48,773
Latest member
Kaybee

Latest Threads

Top