com.hfg.xml.msofficexml.OfficeOpenXmlXsd Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.xml.msofficexml;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.hfg.util.StringUtil;
import com.hfg.xml.XMLException;
import com.hfg.xml.xsd.Xsd;
//------------------------------------------------------------------------------
/**
XML xsd specification for OfficeOpenXml files. This information is need when
producing OfficeOpenXml documents because, for some reason, MS Office applications
are extremely picky about XML tag order.
xsd files downloaded from:
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-376,%20Fourth%20Edition,%20Part%201%20-%20Fundamentals%20And%20Markup%20Language%20Reference.zip
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class OfficeOpenXmlXsd extends Xsd
{
private static OfficeOpenXmlXsd sInstance;
//---------------------------------------------------------------------------
private OfficeOpenXmlXsd()
throws Exception
{
super();
String rsrc = "rsrc/OfficeOpenXML-XMLSchema-Strict.zip";
InputStream is = OfficeXML.class.getResourceAsStream(rsrc);
if (null == is)
{
throw new RuntimeException("The resource " + StringUtil.singleQuote(rsrc) + " couldn't be found!");
}
ZipInputStream zis = new ZipInputStream(is);
ZipEntry zipEntry;
while ((zipEntry = zis.getNextEntry()) != null)
{
System.out.println("Extracting: " + zipEntry + " ...");
Reader reader = new BufferedReader(new InputStreamReader(zis));
parse(reader);
zis.closeEntry();
}
integrateTypesWithElements();
}
//---------------------------------------------------------------------------
public synchronized static OfficeOpenXmlXsd getInstance()
{
if (null == sInstance)
{
try
{
sInstance = new OfficeOpenXmlXsd();
}
catch (Exception e)
{
throw new XMLException("Problem initializing the OfficeOpenXML XSD info!", e);
}
}
return sInstance;
}
}