The Gilbert Arenas Dagger
The Gilbert Arenas Dagger

Reputation: 12741

Eclipse detects error on value XML Attribute (within hibernate.cfg.xml)

I have a hibernate configuration file that is being flagged in Eclipse. Specifically, the property's value attribute, as shown in the last line below, is being flagged

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />

The error messages is

Attribute "value" must be declared for element type "property"

Why is Eclipse flagging this? How can I update my Eclipse such that it no longer labels this an error?

By the way, I know I can rewrite the property element (like below) and avoid the error, but I shouldn't have to.

    <property name="hibernate.connection.driver_class"> oracle.jdbc.driver.OracleDriver</property>

Upvotes: 0

Views: 468

Answers (1)

E-Riz
E-Riz

Reputation: 32914

Eclipse is just going by the DTD you've referenced. According to that DTD, the <property> element has no attribute named value.

<!ELEMENT property (#PCDATA)>
<!ATTLIST property name CDATA #REQUIRED>

So your XML is invalid, which is what Eclipse is warning you about.

Perhaps Hibernate is tolerant of the XML content you're using, but that's in conflict with its own DTD.

Perhaps Hibernate 4's DTD has been corrected, or you can use schema-based XML instead of DTD.

Upvotes: 2

Related Questions