You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Peter Luttrell <pe...@firepod.com> on 2000/08/18 09:57:10 UTC

EMPTY rule question

I am using Xerces 1.1.3 (latest bin from site).
Specifically I am using org.apache.xerces.parsers.DOMParser.
I have the validation feature turned on.

I am wondering why when I specify a rule in an element discoloration in a
dtd to EMPTY, the parser returns an error when there is whitespace.

For example:

Reference this dtd:

<!ELEMENT element1 (subelement+)>
<!ELEMENT subelement EMPTY>

When I use this xml doc:

<!DOCTYPE element1 SYSTEM "file:/// .. whereever.../test.dtd" >
<element1>
	<subelement>
	</subelement>
	<subelement>
	</subelement>
</element1>

I get the following exception:
org.xml.sax.SAXParseException: The content of element type "subelement" must
match "EMPTY".


However when I use the following xml doc, I get no error:

<!DOCTYPE element1 SYSTEM "file:/// .. wherever.../test.dtd" >
<element1>
	<subelement></subelement>
	<subelement></subelement>
</element1>

I thought that setting the
http://apache.org/xml/features/dom/include-ignorable-whitespace feature to
false might do it, however it didn't.

Does anyone have any ideas?

Thanks.


Re: EMPTY rule question

Posted by Eric Ye <er...@locus.apache.org>.
>
> I thought that setting the
> http://apache.org/xml/features/dom/include-ignorable-whitespace feature to
> false might do it, however it didn't.
>

This feature only affects building the dom tree. Please refer to Features in
the Readme.html

_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org



RE: EMPTY rule question

Posted by Ed Staub <es...@mediaone.net>.
Lawrence Fry wrote:

>I don't
>think that \n is a white-space. There have been many threads that follow
>this here, and the conclusion has been..."that's the spec".

I'm afraid this isn't quite right.

The spec (http://www.w3.org/TR/REC-xml#sec-common-syn) says:
"S (white space) consists of one or more space (#x20) characters, carriage
returns, line feeds, or tabs."

I believe the problem is that the white space in each <subelement> is not
ignorable.
<element1>
	<subelement>
	</subelement>
	<subelement>
	</subelement>
</element1>

Ignorability is controlled in XMLValidator.java by lines like:
        fInElementContent = (fCurrentContentSpecType ==
XMLElementDecl.TYPE_CHILDREN);
which is testing whether the DTD declaration of the current element is of
type "children", as described in http://www.w3.org/TR/REC-xml#NT-children;
in other words, it's testing whether text is allowed here.  If text is
allowed, then white space is not ignored.

-Ed Staub

-----Original Message-----
From: Lawrence Fry [mailto:lwfry@bbnow.net]
Sent: Friday, August 18, 2000 11:18 AM
To: xerces-j-dev@xml.apache.org
Subject: RE: EMPTY rule question


I believe it is because you have "\n" in the example with two lines. I don't
think that \n is a white-space. There have been many threads that follow
this here, and the conclusion has been..."that's the spec".


-----Original Message-----
From: Peter Luttrell [mailto:peter@firepod.com]
Sent: Friday, August 18, 2000 12:57 AM
To: xerces-j-dev@xml.apache.org
Subject: EMPTY rule question



I am using Xerces 1.1.3 (latest bin from site).
Specifically I am using org.apache.xerces.parsers.DOMParser.
I have the validation feature turned on.

I am wondering why when I specify a rule in an element discoloration in a
dtd to EMPTY, the parser returns an error when there is whitespace.

For example:

Reference this dtd:

<!ELEMENT element1 (subelement+)>
<!ELEMENT subelement EMPTY>

When I use this xml doc:

<!DOCTYPE element1 SYSTEM "file:/// .. whereever.../test.dtd" >
<element1>
	<subelement>
	</subelement>
	<subelement>
	</subelement>
</element1>

I get the following exception:
org.xml.sax.SAXParseException: The content of element type "subelement" must
match "EMPTY".


However when I use the following xml doc, I get no error:

<!DOCTYPE element1 SYSTEM "file:/// .. wherever.../test.dtd" >
<element1>
	<subelement></subelement>
	<subelement></subelement>
</element1>

I thought that setting the
http://apache.org/xml/features/dom/include-ignorable-whitespace feature to
false might do it, however it didn't.



RE: EMPTY rule question

Posted by Lawrence Fry <lw...@bbnow.net>.
I believe it is because you have "\n" in the example with two lines. I don't
think that \n is a white-space. There have been many threads that follow
this here, and the conclusion has been..."that's the spec".


-----Original Message-----
From: Peter Luttrell [mailto:peter@firepod.com]
Sent: Friday, August 18, 2000 12:57 AM
To: xerces-j-dev@xml.apache.org
Subject: EMPTY rule question



I am using Xerces 1.1.3 (latest bin from site).
Specifically I am using org.apache.xerces.parsers.DOMParser.
I have the validation feature turned on.

I am wondering why when I specify a rule in an element discoloration in a
dtd to EMPTY, the parser returns an error when there is whitespace.

For example:

Reference this dtd:

<!ELEMENT element1 (subelement+)>
<!ELEMENT subelement EMPTY>

When I use this xml doc:

<!DOCTYPE element1 SYSTEM "file:/// .. whereever.../test.dtd" >
<element1>
	<subelement>
	</subelement>
	<subelement>
	</subelement>
</element1>

I get the following exception:
org.xml.sax.SAXParseException: The content of element type "subelement" must
match "EMPTY".


However when I use the following xml doc, I get no error:

<!DOCTYPE element1 SYSTEM "file:/// .. wherever.../test.dtd" >
<element1>
	<subelement></subelement>
	<subelement></subelement>
</element1>

I thought that setting the
http://apache.org/xml/features/dom/include-ignorable-whitespace feature to
false might do it, however it didn't.

Does anyone have any ideas?

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org