隨筆-12  評論-1  文章-0  trackbacks-0
            2012年8月21日
          1.logger.info(LogUtils.getLogFmt("ResponseXML", "ResultCode",
               "ErrorDesc", "ServiceType", "Version"), new Object[] {
               rs.getResponseXML(), rs.getResultCode(), rs.getErrorDesc(),
               rs.getServiceType(), rs.getVersion() });
          2.logger.error("error when call webservice: " + serviceType, e);
          3.logger.info(LogUtils.getLogFmt("RequestXML"), requestXML);
          posted @ 2012-09-04 18:44 小熊寶貝的每一天 閱讀(186) | 評論 (0)編輯 收藏
          ID屬性的聲明必須被置于最后
          <xs:attribute name="orderid" type="xs:string" use="required"/>

          ComplexContent的用法:

          <?xml version="1.0" encoding="UTF-8"?>
          <xs:element name="employee" type="fullpersoninfo"/>

          <xs:complexType name="personinfo">
            <xs:sequence>
              <xs:element name="firstname" type="xs:string"/>
              <xs:element name="lastname" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>

          <xs:complexType name="fullpersoninfo">
            <xs:complexContent>
              <xs:extension base="personinfo">
                <xs:sequence>
                  <xs:element name="address" type="xs:string"/>
                  <xs:element name="city" type="xs:string"/>
                  <xs:element name="country" type="xs:string"/>
                </xs:sequence>
              </xs:extension>
            </xs:complexContent>
          </xs:complexType>

          posted @ 2012-08-21 17:23 小熊寶貝的每一天 閱讀(183) | 評論 (0)編輯 收藏
          1.
          準確說是一種Java XML數據綁定技術。
          http://www.iteye.com/topic/582459
          :
          <bind-xml name="borndate" node="attribute"/> ,name規定了這個值在xml中的顯示名,而node規定了該值的xml存儲方式,這里是用attribute形式進行存儲,即寫到了結點的屬性里。   
          2.Castor介紹----比較詳細易懂的BLOG:
          http://www.open-open.com/lib/view/open1326514404093.html

          mapping.xml配置如下:  
          01<?xml version="1.0" encoding="UTF-8"?>
          02<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">
          03<mapping>
          04    <class name="com.hoo.entity.Account" auto-complete="true"
          05        <map-to xml="Account"/>
          06
          07        <field name="id" type="integer">
          08            <bind-xml name="id" node="attribute" />
          09        </field>
          10
          11        <field name="name" type="string">
          12            <bind-xml name="name" node="element" />
          13        </field>
          14
          15        <field name="email" type="string">
          16            <bind-xml name="email" node="element" />
          17        </field>
          18
          19        <field name="address" type="string">
          20            <bind-xml name="address" node="element" />
          21        </field>
          22
          23        <field name="birthday" type="com.hoo.entity.Birthday">
          24            <bind-xml name="生日" node="element" />
          25        </field>
          26    </class>
          27
          28    <class name="com.hoo.entity.Birthday">
          29        <map-to xml="birthday" />
          30
          31        <field name="birthday" type="string">
          32            <bind-xml name="birthday" node="attribute" />
          33        </field>
          34    </class>
          35</mapping>


          首先,看看這個xml文檔的根元素是mapping,在mapping中可以配置class。也就是我們要轉換的JavaObject的配置描述了。  

          class元素的name屬性就是配置的JavaObject的classpath路徑了。  

          關于class元素的auto-complate屬性,如果這個屬性的值為ture。那么編組后的xml,castor會自動給沒有在mapping配置文件進行配置的屬性自動編組(轉換)到xml中。如果為false,那么在mapping配置文件中出現的屬性將在編組后不現在在編組后的xml中。  

          map-to就是當前class編組后的xml文檔的節點元素名稱。  

          field就是描述JavaObject中的屬性,name是Java對象的屬性名稱,type是類型。關于配置的type類型也有規定,你可以參考:http://www.castor.org/xml-mapping.html的field配置講解。  

          而field還有其他的屬性配置,如get-method應該是getter方法、set-method應該是setter的方法、has-mehtod 應該是hashCode方法,有時候我們不一定要提高getter、setter方法,我們需要用自己的方法名稱來代替setter、getter。如果當前field配置的是集合類型,那么你需要給field元素配置collection屬性。  

          bind-xml就是綁定(編組)成xml后的xml內容的描述,name就是編組后xml的節點元素名稱,node有2個值,分別是 attribute、element。attribute是屬性,它會在節點元素的屬性中顯示,例如:<account id=”2”></account>  

          而element則是單獨的一個元素,例如:<account><id>2</id></account>  

          就這個樣子的。  

          mapping.xml還可以有其他標簽,如:  

          <include href="other_mapping_file.xml"/>  

          導入外部xml文件,可以分多個配置。  




           

          posted @ 2012-08-21 16:01 小熊寶貝的每一天 閱讀(311) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 永康市| 鲜城| 巴楚县| 利辛县| 松阳县| 垣曲县| 同心县| 汨罗市| 中宁县| 容城县| 万年县| 遵义市| 呈贡县| 乡城县| 庆城县| 景宁| 吐鲁番市| 湘西| 古浪县| 苗栗县| 花莲市| 贵州省| 那坡县| 长泰县| 高平市| 丁青县| 廉江市| 邳州市| 天水市| 曲靖市| 蛟河市| 三原县| 龙井市| 聂拉木县| 平潭县| 江口县| 普定县| 新营市| 洪泽县| 饶河县| 长宁区|