Thursday, January 12, 2012

The content of element type "properties" must match "(comment?,entry*)".

I'm trying to make my Java XML properties file a little more human-readable by breaking the entries into blocks. Evidently my assumptions on how to do this were wrong. Here are the error, cause, and solution:

Error:

java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException: The content of element type "properties" must match "(comment?,entry*)".

Cause:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>

<comment>---SQL settings---</comment>
<entry key="SQLJNDIName">SQLDataSource</entry>
<entry key="SQLServerName">server01</entry>
<entry key="SQLPortNumber">12345</entry>
<entry key="SQLDatabaseName">db01</entry>
<entry key="SQLUser">user01</entry>
<entry key="SQLPassword">changeme</entry>
<entry key="SQLTableOwner">dbo</entry>

<comment>---TEST settings---</comment>
<entry key="TEST">TEST</entry>

</properties>


Solution: I changed the comment elements into XML comments, and it worked.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>

<!--SQL settings-->
<entry key="SQLJNDIName">SQLDataSource</entry>
<entry key="SQLServerName">server01</entry>
<entry key="SQLPortNumber">12345</entry>
<entry key="SQLDatabaseName">db01</entry>
<entry key="SQLUser">user01</entry>
<entry key="SQLPassword">changeme</entry>
<entry key="SQLTableOwner">dbo</entry>

<!--TEST settings-->
<entry key="TEST">TEST</entry>

</properties>

3 comments:

  1. Cool stuff you have and you keep overhaul every one of us
    You have done a amazing job with you website
    real estate in Stone Oak

    ReplyDelete
  2. The content writing training institute online in India provides the interested candidates with alluring course module, everything you would like to jump for.
    spin rewriter

    ReplyDelete