Reputation: 1
I using Java 8 and Struts Framework. I want to convert from DTD to XSD, i.e. remove <!DOCTYPE...
, in the sqlMapConfig.xml
and sqlMap.xml
files. However, there doesn't appear to be an alternative XSD file link for http://ibatis.apache.org/dtd/sql-map-2.dtd. Additionally, there is also a missing !DOCTYPE error. Is there any way to fix this?
sqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings useStatementNamespaces="true"/>
<sqlMap resource="sql/sql.xml"/>
</sqlMapConfig>
sqlMap.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="sql">
<resultMap id="personMap" class="com.example.model.Person">
<result property="name" column="name" />
<result property="id" column="id" />
</resultMap>
<resultMap id="playerMap" class="com.example.model.Player">
<result property="name" column="name" />
<result property="id" column="player_id" />
<result property="email" column="email" />
<result property="password" column="password" />
<result property="avatarUrl" column="avatar_url" />
</resultMap>
<resultMap id="matchMap" class="com.example.model.Match">
<result property="id" column="match_id" />
<result property="p1" column="p1_id" select="sql.getPlayerById" />
<result property="p2" column="p2_id" select="sql.getPlayerById" />
<result property="p1Score" column="p1_score" />
<result property="p2Score" column="p2_score" />
<result property="date" column="date" />
</resultMap>
<select id="getById" parameterClass="java.lang.String" resultMap="sql.personMap">
select * from person where id = #id#
</select>
<select id="getPlayerById" parameterClass="java.lang.String" resultMap="sql.playerMap">
select * from player where player_id = #id#
</select>
<select id="getPlayers" resultMap="sql.playerMap">
select * from player
</select>
<select id="getByEmail" resultMap="sql.playerMap">
select * from player where email = #email#
</select>
<select id="getByEmailAndPassword" parameterClass="java.util.Map" resultMap="sql.playerMap">
select * from player where email = #email# and password = md5(#password#)
</select>
<insert id="insertRegistration" parameterClass="com.example.model.Player">
insert into player
(name, email, password, avatar_url)
values
(#name#, #email#, md5(#password#), #avatarUrl#)
<selectKey resultClass="java.lang.String" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
</insert>
<insert id="insertMatch" parameterClass="com.example.model.Match">
insert into matches
(p1_id, p2_id, p1_score, p2_score, date)
values
(#p1.id#, #p2.id#, #p1Score#, #p2Score#, #date#)
<selectKey resultClass="java.lang.String" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
</insert>
<select id="getMatchesByPlayer" resultMap="sql.matchMap">
select * from matches where p1_id = 1 OR p2_id = #playerId#
</select>
<select id="getMatchesByPlayerByDateDesc" resultMap="sql.matchMap">
select * from matches where p1_id = #playerId# OR p2_id = #playerId# order by date desc
</select>
</sqlMap>
I have checked various sources and tried many methods, but most of the time I receive the following error:
Error processing XML. Cause: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 76; Document root element "xs:schema" must match the DOCTYPE root "null".
Upvotes: 0
Views: 42