[
next
] [
prev
] [
prev-tail
] [
tail
] [
up
]
7.3
Remove Trailing Entries
<..
remove
trailing
non-content
entries
..>
if
(node.hasChildNodes())
{
mtr
=
node.getLastChild();
while(
mtr
!=
null){
if(
mtr.getNodeType()
==
Node.ELEMENT_NODE
){
if
(mtr.hasChildNodes())
{
mtd
=
mtr.getLastChild();
int
count
=
0;
while(
mtd
!=
null){
if(
mtd.getNodeType()
==
Node.ELEMENT_NODE
){
count++;
d
=
mtd.getFirstChild();
if(
d
!=
null
){
<.
remove mspace-only content
.>
}
if(
d
!=
null
){
<.
remove d, if white space text
.>
}
}
d
=
mtd;
mtd
=
mtd.getPreviousSibling();
<.
remove d, if white space text
.>
if(
(d
!=
null)
&&
(d.getNodeType()
==
Node.ELEMENT_NODE)
){
<.
remove d, if trailing and childless node
.>
if(
d
==
null
){
count--;
}
}
}
if(
count
>
cols
){
cols
=
count;
}
}
}
d
=
mtr;
mtr
=
mtr.getPreviousSibling();
<.
remove d, if white space text
.>
if(
d
!=
null
){
<.
remove d, if trailing and childless node
.>
}
}
}
-_-_-
<..
remove
d,
if
white
space
text
..>
if(
(d.getNodeType()
==
Node.TEXT_NODE)
&&
d.getNodeValue().trim().equals("")
){
d.getParentNode().removeChild(d);
d
=
null;
}
-_-_-
<..
remove
d,
if
trailing
and
childless
node
..>
if(
(d.getNextSibling()==null)
&&
(d.getFirstChild()==null)
){
d.getParentNode().removeChild(d);
d
=
null;
}
-_-_-
[
next
] [
prev
] [
prev-tail
] [
front
] [
up
]