ibatis2mybatis icon indicating copy to clipboard operation
ibatis2mybatis copied to clipboard

When <result> is converted to <association>, the <association> is not at the end

Open ooizj opened this issue 4 years ago • 2 comments

I have a problem:When <result select=""> is converted to <association>, the <association> is not at the end

source

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
    "sql-map-2.dtd">

<sqlMap namespace="ns1">
	
	<resultMap id="rm1" class="a.b.T1">
		<result column="ID" property="id" jdbcType="DECIMAL" />
		<result column="AID" property="aid" select="ns2.s1" />
		<result column="NAME" property="name" jdbcType="VARCHAR2" />
	</resultMap>

</sqlMap>

destination

<?xml version="1.0" encoding="UTF-8"?><!--Converted at: Tue Jan 26 14:03:48 CST 2021-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="ns1">
	
	<resultMap id="rm1" type="a.b.T1">
		<result property="id" column="ID" jdbcType="DECIMAL"/>
		<association property="aid" select="ns2.s1" column="AID"/>
		<result property="name" column="NAME" jdbcType="VARCHAR2"/>
	</resultMap>

</mapper>

output

PS C:\download\ibatis2mybatis-master> ant
Buildfile: build.xml

migrateToMyBatis3:
     [xslt] Transforming into C:\download\ibatis2mybatis-master\destination
     [xslt] Processing C:\download\ibatis2mybatis-master\source\TestMap.xml to C:\download\ibatis2mybatis-master\destination\TestMap.xml
     [xslt] Loading stylesheet C:\download\ibatis2mybatis-master\migrate.xslt
     [xslt] Warning: org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser: Property 'http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
     [xslt] Warning: org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.
[xmlvalidate] C:\download\ibatis2mybatis-master\destination\TestMap.xml:10:14: The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".

BUILD FAILED
C:\download\ibatis2mybatis-master\build.xml:46: C:\download\ibatis2mybatis-master\destination\TestMap.xml is not a valid XML document.

ooizj avatar Jan 26 '21 06:01 ooizj

Thank you for the report, @ooizj !

This repo is not actively maintained, unfortunately. You may have to move the <association /> manually after the conversion.

If someone knows how to fix this, please send us a PR.

harawata avatar Jan 28 '21 17:01 harawata

Hi, I run the previous code i received Error like this

 [xslt] Loading stylesheet C:\download\ibatis2mybatis\migrate.xslt
 [xslt] : Error! Use of the extension function 'http://xml.apache.org/xslt/java:new' is not allowed when the secure processing 
 feature is set to true.
 [xslt] Failed to process null.

BUILD FAILED C:\download\batis2mybatis\build.xml:25: javax.xml.transform.TransformerException: java.lang.RuntimeException: Use of the extension function 'http://xml.apache.org/xslt/java:new' is not allowed when the secure processing feature is set to true.

Total time: 1 second.

SuryaT1999 avatar Jun 21 '22 07:06 SuryaT1999