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

          主站蜘蛛池模板: 梁山县| 千阳县| 崇仁县| 油尖旺区| 自治县| 潼南县| 涡阳县| 海南省| 孙吴县| 舟山市| 富顺县| 故城县| 长海县| 盘锦市| 镇江市| 义乌市| 广宗县| 威信县| 南郑县| 普兰县| 随州市| 法库县| 新晃| 西华县| 伊春市| 牙克石市| 曲水县| 阳春市| 海门市| 自贡市| 霸州市| 鲁山县| 青海省| 磴口县| 白银市| 满城县| 阿拉善右旗| 西城区| 罗源县| 罗田县| 巨野县|