/**
 * Exportdocument.java
 */
package jp.co.nri.rid.export;

import  java.io.FileOutputStream;

import  javax.xml.parsers.DocumentBuilderFactory;
import  javax.xml.parsers.DocumentBuilder;
import  org.w3c.dom.*;

/* Xerces Serialize */
import  org.apache.xml.serialize.OutputFormat;
import  org.apache.xml.serialize.DOMSerializer;
import  org.apache.xml.serialize.XMLSerializer;

/**
 * CSV,SVGエキスポート用ドキュメント定義
 */
public class Exportdocument{
    protected   Document    myDocument  =   null;

    /**
     * コンストラクタ
     */
    public  Exportdocument(String filename)
        throws javax.xml.parsers.ParserConfigurationException
    {
        //ドキュメントビルダファクトリの生成
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        // ドキュメントビルダの生成
        DocumentBuilder myBuilder = factory.newDocumentBuilder();   
        
        //パース
        try{ myDocument = myBuilder.parse(filename); }
        catch(org.xml.sax.SAXException e){  myDocument = null; }
        catch(java.io.IOException e){       myDocument = null; }
    }

    public Exportdocument(Document document){ myDocument = document; }
    public Document document(){ return myDocument; }
    public Exportelement root(){ return new Exportelement(myDocument.getDocumentElement()); }
}
