paulwong

          大對(duì)象XML讀寫(xiě)

          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) 評(píng)論(0)  編輯  收藏 所屬分類: J2SE

          主站蜘蛛池模板: 福贡县| 南岸区| 通州市| 龙胜| 石泉县| 大余县| 东乡| 湘潭县| 湘乡市| 县级市| 宁都县| 怀远县| 广饶县| 蛟河市| 门头沟区| 武川县| 买车| 韩城市| 沅陵县| 金坛市| 华池县| 凤冈县| 鞍山市| 阳高县| 宁乡县| 凤山市| 扎鲁特旗| 泸西县| 黎城县| 黄石市| 宁蒗| 东宁县| 阳江市| 海晏县| 鄂托克前旗| 庆阳市| 星座| 日喀则市| 富川| 永昌县| 秦安县|