ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Franck Silvestre <f.silves...@fylab.com>
Subject Re: customizing XML output
Date Mon, 14 Feb 2005 17:44:23 GMT
Clinton,

OK, I just checked the DTD : the attribute in "resultMap" is "xmlName"  
and not "xmlResultName".

Thank you for your answers,
Franck

Le 14 févr. 05, à 18:30, Clinton Begin a écrit :

> If you're using an Result Map, the xmlResultName has to go on the
> <resultMap> element.
>
> Clinton
>
>
> On Mon, 14 Feb 2005 18:25:15 +0100, Franck Silvestre
> <f.silvestre@fylab.com> wrote:
>> Here is the sql map file
>>
>> ------------
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
>> "http://www.ibatis.com/dtd/sql-map-2.dtd">
>> <sqlMap>
>>      <!-- <resultMap id="getActorsByNameResultMap"
>> class="org.fydji.wsrm.examples.Actor"> -->
>>      <resultMap id="getActorsByNameResultMap" class="xml">
>>          <result property="id" column="ID"  
>> javaType="java.lang.Integer"/>
>>          <result property="email" column="EMAIL"
>> javaType="java.lang.String"/>
>>          <result property="firstName" column="FIRST_NAME"
>> javaType="java.lang.String"/>
>>          <result property="name" column="NAME"
>> javaType="java.lang.String"/>
>>          <result property="organization" column="ORGANIZATION"
>> javaType="java.lang.String"/>
>>      </resultMap>
>>      <select id="getActorsByName" parameterClass="java.util.Map"
>> resultMap="getActorsByNameResultMap" xmlResultName="Actor">
>>          select
>>              ID,
>>              EMAIL,
>>              FIRST_NAME,
>>              NAME,
>>              ORGANIZATION
>>          from
>>              FY_ACTOR
>>          where
>>              NAME like #name#
>>      </select>
>> </sqlMap>
>> --------------
>>
>> Here is the obained output :
>>
>> --------------
>> DEBUG [main] - Created connection 5068254.
>> DEBUG [main] - {conn-100000} Connection
>> DEBUG [main] - {pstm-100001} PreparedStatement:          select
>>       ID,             EMAIL,             FIRST_NAME,             NAME,
>>            ORGANIZATION         from              FY_ACTOR          
>> where
>>              NAME like ?
>> DEBUG [main] - {pstm-100001} Parameters: [Si%]
>> DEBUG [main] - {pstm-100001} Types: [java.lang.String]
>> DEBUG [main] - {rset-100002} ResultSet
>> DEBUG [main] - {rset-100002} Header: [ID, EMAIL, FIRST_NAME, NAME,
>> ORGANIZATION]
>> DEBUG [main] - {rset-100002} Result: [1, f.silvestre@fylab.com,  
>> Franck,
>> Silvestre, Fylab]
>> DEBUG [main] - {rset-100002} Result: [5, s.sigur@fylab.com, StÈphane,
>> Sigur, Sigur.net]
>> <?xml version="1.0" encoding="UTF-8"?>
>> <result><id>1</id><email>f.silvestre@fylab.com</
>> email><firstName>Franck</firstName><name>Silvestre</
>> name><organization>Fylab</organization></result>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <result><id>5</id><email>s.sigur@fylab.com</ 
>> email><firstName>StÈphane</
>> firstName><name>Sigur</name><organization>Sigur.net</organization></
>> result>
>> DEBUG [main] - Returned connection 5068254 to pool.
>>
>> --------------
>>
>> Thanks in advance,
>> Franck
>>
>> Le 14 févr. 05, à 18:20, Clinton Begin a écrit :
>>
>>> There's no way to customize the XML output.  You'll just need to use
>>> either XSLT or some other means of transformation.  The xmlResultName
>>> should work though.  Can you post an example of what you're doing?
>>>
>>> Clinton
>>>
>>>
>>> On Mon, 14 Feb 2005 18:11:57 +0100, Franck Silvestre
>>> <f.silvestre@fylab.com> wrote:
>>>> I'm completely new to ibatis .
>>>> I play with the ability to get XML output.
>>>>
>>>> If I use in my sql map file a resultMap with the attribute class set
>>>> as
>>>> "xml" I get a String for each item of  the result list.
>>>> Is it possible to customize the root element name of  fetched items  
>>>> ?
>>>> The default root element name is "result". I tried to use the
>>>> "xmlResultName" of the "select" element but it did nothing.
>>>>
>>>> Second question : is there a way to customize the structure of the  
>>>> xml
>>>> output (for exemple tell  a fetched value to be an attribute of  an
>>>> element) ?
>>>>
>>>> Thanks in advance
>>>> Franck
>>>>
>>>>
>>>
>>>
>> ----------------------------------
>> Franck SILVESTRE
>> Directeur technique
>> FYLAB
>> 55, av Louis-Bréguet,
>> Bâtiment 7 - 1er étage
>> 31400 Toulouse
>> Tel :           +33 5 62 47 00 39
>> Mobil :         +33 6 14 65 23 76
>> Fax :           +33 5 62 47 00 36
>> http://www.fylab.com
>> http://www.fytraining.com
>>
>>
>
>
----------------------------------
Franck SILVESTRE
Directeur technique
FYLAB
55, av Louis-Bréguet,
Bâtiment 7 - 1er étage
31400 Toulouse
Tel : 		+33 5 62 47 00 39
Mobil : 	+33 6 14 65 23 76
Fax :		+33 5 62 47 00 36
http://www.fylab.com
http://www.fytraining.com



Mime
View raw message