Idea says "Wrong Root Element" based on a DTD even though the element is correct

I'm testing Tapestry with IDEA and when I create a file called "home.page" that uses the Tapestry DTD, IDEA is saying "Wrong Root Element" even though page-specification should be a valid element. I have mapped .page files as XML and have used IDEA's intention to fetch the DTD.

The funny thing is that IDEA even suggests that as one of the alternative root elements but when it has been written, IDEA marks it as an error.

It should be very easy to replicate this issue. The file looks as follows:

Test ]]>

7 comments

Markus Halttunen wrote:

I'm testing Tapestry with IDEA and when I create a file called "home.page" that uses the Tapestry DTD, IDEA is saying "Wrong Root Element" even though page-specification should be a valid element. I have mapped .page files as XML and have used IDEA's intention to fetch the DTD.

The funny thing is that IDEA even suggests that as one of the alternative root elements but when it has been written, IDEA marks it as an error.

It should be very easy to replicate this issue. The file looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application
PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<page-specification ><!-- This is marked as an error -->
<description>Test</description>
</page-specification>


I think IDEA is right. A DTD itself doesn't know about what the actual root element is. This
information is taken from the DOCTYPE declaration, which is "application" in your case.
This points to an element that is defined in the DTD. It's a little odd though that IDEA
suggests any element as the root element.

I guess IDEA doesn't complain if you write your XML like this:

Test ]]>


HTH,
Sascha

0

You are 100% correct, Sascha. Thank you!

Basically it was a copy-paste mistake on my part. It really should have said "DOCTYPE page-specification" instead of "DOCTYPE application".

But I do think that IDEA should not have been suggesting an invalid root element in the first place.

0

Markus Halttunen wrote:

Basically it was a copy-paste mistake on my part. It really should have said "DOCTYPE page-specification" instead of "DOCTYPE application".

But I do think that IDEA should not have been suggesting an invalid root element in the first place.


Nope, IDEA is entirely correct. The ONLY way that an XML parser knows
what the root element should be is by looking at the DOCTYPE
declaration. IDEA could not have known that "application" in the DOCTYPE
declaration was not correct.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0

page-specification might be allowed by the DTD, but your
doctypedeclaration specifies the document type (root element type) to be
application. Try to declare it to be of type page-specification by
changing the DOCTYPE declaration to:
<!DOCTYPE page-specification PUBLIC "-//Apache Software
Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">


On Tue, 31 Aug 2004 16:44:56 +0400 (MSD), Markus Halttunen
<no_mail@jetbrains.com> wrote:

I'm testing Tapestry with IDEA and when I create a file called
"home.page" that uses the Tapestry DTD, IDEA is saying "Wrong Root
Element" even though page-specification should be a valid element. I
have mapped .page files as XML and have used IDEA's intention to fetch
the DTD.

>

The funny thing is that IDEA even suggests that as one of the
alternative root elements but when it has been written, IDEA marks it as
an error.

>

It should be very easy to replicate this issue. The file looks as
follows:

>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application
PUBLIC "-//Apache Software Foundation//Tapestry Specification
3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<page-specification ><!-- This
is marked as an error -->
<description>Test</description>
</page-specification>

>



--
Fredrik Lindgren

0

No, I think you misunderstood me. What I mean is that when I use IDEA's autocomplete in the XML, IDEA should not suggest xml tags that are invalid.

When I type ", , , etc. But if I select anything else than ]]>, IDEA will immediately mark it as an error.

Of course this is not such a big deal, but still it is a bit misleading.

0

Markus Halttunen wrote:

No, I think you misunderstood me. What I mean is that when I use IDEA's autocomplete in the XML, IDEA should not suggest xml tags that are invalid.

When I type "<" and press space, IDEA suggests e.g. <application>, <bean>, <binding>, etc. But if I select anything else than <application>, IDEA will immediately mark it as an error.


As far as I know, and I may be wrong here, the root element name
specified by the DOCTYPE declaration doesn't have to appear in the DTD.
I.e. by specifying it in the DOCTYPE declaration, "application" becomes
a valid element name. Thus, as far as IDEA is concerned (and quite
correctly as far as I am concerned), "application" is a valid element
name to suggest.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0

Gordon Tyler wrote:

Markus Halttunen wrote:

>> No, I think you misunderstood me. What I mean is that when I use
>> IDEA's autocomplete in the XML, IDEA should not suggest xml tags that
>> are invalid.
>> When I type ", >> , , etc. But if I select anything else than >> ]]>, IDEA will immediately mark it as an error.


As far as I know, and I may be wrong here, the root element name
specified by the DOCTYPE declaration doesn't have to appear in the DTD.
I.e. by specifying it in the DOCTYPE declaration, "application" becomes
a valid element name. Thus, as far as IDEA is concerned (and quite
correctly as far as I am concerned), "application" is a valid element
name to suggest.


I think the point is that IDEA should only suggest "application" because
anything else will be invalid according to the DOCTYPE declaration. It makes
no sense to let the user choose something, just to immediately say that the
choice is invalid.

Btw, I didn't know that the root element doesn't have to be defined in the DTD.
If it is not, how is its content model defined then? Just a thought, I'm not
deeply familiar with DTDs either.


Sascha

0

Please sign in to leave a comment.