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 閱讀(271) 評論(0)  編輯  收藏 所屬分類: J2SE

          主站蜘蛛池模板: 吉隆县| 乐至县| 乐清市| 隆尧县| 温泉县| 张家川| 来宾市| 潞城市| 阳谷县| 榕江县| 榆树市| 河南省| 宣恩县| 黎平县| 腾冲县| 贺兰县| 磐安县| 德兴市| 广德县| 丰宁| 仲巴县| 德格县| 合肥市| 迁西县| 宜宾市| 潮州市| 清徐县| 凭祥市| 体育| 景德镇市| 阿克陶县| 瑞金市| 察雅县| 通化市| 阳山县| 南部县| 金堂县| 格尔木市| 盱眙县| 兴化市| 洪洞县|