Here you can find the source of saveXML(Document doc, ByteArrayOutputStream outputStreamXML)
Parameter | Description |
---|---|
doc | a parameter |
outputStreamXML | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static void saveXML(Document doc, ByteArrayOutputStream outputStreamXML) throws Exception
//package com.java2s; /**//from w w w. ja v a 2 s . c o m * * API XBRL-PGC2007 is a set of packages for the treatment of instances XBRL * (eXtensible Business Reporting Language) corresponding to the taxonomy PGC2007. * The General Plan of Accounting 2007 is the legal text that regulates the accounting of * the companies in Spain. * * This program is part of the API XBRL-PGC2007. * * Copyright (C) 2009 INTECO (Instituto Nacional de Tecnolog?as de la * Comunicaci?n, S.A.) * * Authors: Members of Software Quality Department inside INTECO * * E-mail: difusioncalidad@inteco.es * * This program is free software; you can redistribute it and/or modify it under the terms of * the GNU Lesser General Public License as published by the Free Software Foundation; * either version 3 of the License, or (at your opinion) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program. If not, see http://www.gnu.org/licenses/ */ import java.io.ByteArrayOutputStream; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; public class Main { /** * Serializa un XML a ByteArrayOutputStream * @param doc * @param outputStreamXML * @throws Exception */ public static void saveXML(Document doc, ByteArrayOutputStream outputStreamXML) throws Exception { System.setProperty(DOMImplementationRegistry.PROPERTY, "org.apache.xerces.dom.DOMImplementationSourceImpl"); DOMImplementationRegistry registry = DOMImplementationRegistry .newInstance(); DOMImplementation domImpl = registry.getDOMImplementation("LS 3.0"); DOMImplementationLS implLS = (DOMImplementationLS) domImpl; LSSerializer dom3Writer = implLS.createLSSerializer(); LSOutput output = implLS.createLSOutput(); output.setByteStream(outputStreamXML); output.setEncoding("UTF-8"); dom3Writer.write(doc, output); } }