You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Rahul Agarwal <re...@yahoo.com> on 2003/07/12 18:48:20 UTC
Empty Text nodes in DOM structure
Hi,
In the DOM sructure, many empty text nodes appear,
probably one below each structure (element, attr,
etc).
Is there anyway I can prevent them from occuring in
the structure ?? Or can I remove them ??
Thanks,
Rahul
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Empty Text nodes in DOM structure
Posted by Rahul Agarwal <re...@yahoo.com>.
Hi Simon,
Thanks for the reply. But there's one more problem. After getting the DOM, when I traverse it for the first time, to assign a key to each node, then these text nodes doesnt seem to be there, because the key is not assigned to them (I dont think that these nodes are null). When I travel the DOM second time (to make some changes to it), then they appear in between. What can be the reason for that ??
Also, I would like to know, if there is any other possible solution for removing these text nodes, rather than modifying the DTD (which I dont want to do at any cost).
Thanks,
Rahul
Simon Kitching <si...@ecnetwork.co.nz> wrote:
Hi Rahul,
On Sun, 2003-07-13 at 04:48, Rahul Agarwal wrote:
> Hi,
> In the DOM sructure, many empty text nodes appear,
> probably one below each structure (element, attr,
> etc).
> Is there anyway I can prevent them from occuring in
> the structure ?? Or can I remove them ??
If you have a document like this, and no DTD or schema:
then in the resulting DOM, node "foo" has 3 children:
* a linefeed (note: not "empty")
* a bar element
* a linefeed (note: not "empty")
If you don't want this behaviour, you can provide an XML schema which
specifies that node "foo" has element content only; the parser then
knows that all whitespace within foo can be ignored. I think a DTD can
also be used to specify element-only-content but am not absolutely sure.
Without a DTD or Schema, the parser can't throw away text within foo
(even whitespace) because it *might* be important to the calling
program.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
Re: Empty Text nodes in DOM structure
Posted by Bob Foster <bo...@objfac.com>.
> How can I specify this (element content only - no text nodes)?
Don't specify mixed in your complexType.
If you are asking, "Can I prohibit whitespace between elements?", I believe
the answer is no.
Bob
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Empty Text nodes in DOM structure
Posted by Ron Rothblum <RO...@il.ibm.com>.
How can I specify this (element content only - no text nodes)?
Ron Rothblum
Active Technologies Department
IBM Haifa Research Labs
Phone: +972 4 829-6459
|---------+---------------------------->
| | Simon Kitching |
| | <simon@ecnetwork.|
| | co.nz> |
| | |
| | 14/07/2003 02:53 |
| | Please respond to|
| | xerces-j-user |
|---------+---------------------------->
>--------------------------------------------------------------------------------------------------------------|
| |
| To: xerces-j-user@xml.apache.org |
| cc: |
| Subject: Re: Empty Text nodes in DOM structure |
>--------------------------------------------------------------------------------------------------------------|
Hi Rahul,
On Sun, 2003-07-13 at 04:48, Rahul Agarwal wrote:
> Hi,
> In the DOM sructure, many empty text nodes appear,
> probably one below each structure (element, attr,
> etc).
> Is there anyway I can prevent them from occuring in
> the structure ?? Or can I remove them ??
If you have a document like this, and no DTD or schema:
<foo>
<bar/>
</foo>
then in the resulting DOM, node "foo" has 3 children:
* a linefeed (note: not "empty")
* a bar element
* a linefeed (note: not "empty")
If you don't want this behaviour, you can provide an XML schema which
specifies that node "foo" has element content only; the parser then
knows that all whitespace within foo can be ignored. I think a DTD can
also be used to specify element-only-content but am not absolutely sure.
Without a DTD or Schema, the parser can't throw away text within foo
(even whitespace) because it *might* be important to the calling
program.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Empty Text nodes in DOM structure
Posted by Simon Kitching <si...@ecnetwork.co.nz>.
Hi Rahul,
On Sun, 2003-07-13 at 04:48, Rahul Agarwal wrote:
> Hi,
> In the DOM sructure, many empty text nodes appear,
> probably one below each structure (element, attr,
> etc).
> Is there anyway I can prevent them from occuring in
> the structure ?? Or can I remove them ??
If you have a document like this, and no DTD or schema:
<foo>
<bar/>
</foo>
then in the resulting DOM, node "foo" has 3 children:
* a linefeed (note: not "empty")
* a bar element
* a linefeed (note: not "empty")
If you don't want this behaviour, you can provide an XML schema which
specifies that node "foo" has element content only; the parser then
knows that all whitespace within foo can be ignored. I think a DTD can
also be used to specify element-only-content but am not absolutely sure.
Without a DTD or Schema, the parser can't throw away text within foo
(even whitespace) because it *might* be important to the calling
program.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org