paulwong

          大對象XML讀寫

          I am using JAXB and I have a large set of data which i have to marshal into a xml.Since marshalling the whole thing into xml in a single step will be using most of the memory , i want to split it into parts and write to the xml file incremently

          For example if my generated output xml should be like this:
          <Employees>
          <employee>......</employee>
          <employee>.....</employee>
          <employee>.....</employee>
          <employee>.....</employee>
          ..
          ...
          ..
          </Employees>

          I would like to write the <employee> sections separately into a file instead of writing the whole thing together.I am retrieving the employee details from the database and converting to xml.There are almost 8 lakh records.So marshalling the whole thing in single step will use up my memory.How can i do it?????


          Use Stax API (XMLStreamWriter) as the underlying XML processing thing;
          write <Employees> tag using that, and then pass XMLStreamWriter to
          JAXB Marshaller, marshall employee by employee.
          This is the pattern I use; similarly works well with unmarshalling.
          Not sure if this is in FAQ or not, but it probably should be. 

          posted on 2013-04-12 19:18 paulwong 閱讀(274) 評論(0)  編輯  收藏 所屬分類: J2SE

          主站蜘蛛池模板: 准格尔旗| 衢州市| 惠东县| 德令哈市| 郧西县| 博湖县| 靖边县| 鄂尔多斯市| 天全县| 元氏县| 肥西县| 龙川县| 武宣县| 定日县| 固原市| 博野县| 屏山县| 无棣县| 册亨县| 福泉市| 惠州市| 休宁县| 元江| 云浮市| 厦门市| 安西县| 汶川县| 龙江县| 新晃| 博湖县| 永定县| 资中县| 天长市| 屯昌县| 土默特右旗| 连平县| 屯门区| 平潭县| 浠水县| 广河县| 乃东县|