19package org.openoffice.xmerge.converter.xml.xslt;
21import java.io.ByteArrayInputStream;
22import java.io.ByteArrayOutputStream;
23import java.io.IOException;
24import java.util.Iterator;
26import javax.xml.parsers.DocumentBuilder;
27import javax.xml.parsers.DocumentBuilderFactory;
28import javax.xml.transform.Source;
29import javax.xml.transform.Transformer;
30import javax.xml.transform.TransformerException;
31import javax.xml.transform.TransformerFactory;
32import javax.xml.transform.URIResolver;
33import javax.xml.transform.dom.DOMSource;
34import javax.xml.transform.stream.StreamResult;
35import javax.xml.transform.stream.StreamSource;
82 log(
"\nFound the XSLT deserializer");
84 org.w3c.dom.Document domDoc =
null;
86 ByteArrayOutputStream baos =
null;
88 while (enumerate.hasNext()) {
95 sxwDoc.initContentDOM();
96 DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
97 dFactory.setNamespaceAware(
true);
98 DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
99 sxwDoc.setContentDOM(dBuilder.parse(
new ByteArrayInputStream(baos.toByteArray())));
102 System.out.println(
"The following error occurred:" + e);
108 public Source resolve(String href, String base)
throws TransformerException {
110 if (href.equals(
"javax.xml.transform.dom.DOMSource") || href.length() == 0) {
116 StreamSource sheetFile =
new StreamSource(newhRef);
119 System.out.println(
"\nException in Xslt Resolver " + e);
134 log(
"\nTransforming...");
136 ByteArrayOutputStream baos=
new ByteArrayOutputStream();
138 DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
139 dFactory.setNamespaceAware(
true);
140 DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
143 teststr= teststr.substring(0,6);
144 org.w3c.dom.Document xslDoc=
null;
145 if ((teststr.equals(
"http:/"))||(teststr.equals(
"file:/"))
146 ||(teststr.equals(
"jar://"))){
153 xslDoc = dBuilder.parse(
158 DOMSource xslDomSource =
new DOMSource(xslDoc);
159 DOMSource xmlDomSource =
new DOMSource(xmlDoc);
162 TransformerFactory tFactory = TransformerFactory.newInstance();
163 tFactory.setURIResolver(
this);
164 Transformer transformer = tFactory.newTransformer(xslDomSource);
165 transformer.transform(xmlDomSource,
new StreamResult(baos));
167 log(
"\n** Transform Complete ***");
170 catch (StackOverflowError sOE){
171 System.out.println(
"\nERROR : Stack Overflow Error During Transformation\n Try increasing the stack size by passing the -Xss1m option to the JRE.");
175 System.out.println(
"An error occurred in the transformation : "+e);
185 private void log(String str) {
ConvertData is used as a container for passing Document objects in and out of the Convert class.
Iterator< Object > getDocumentEnumeration()
Gets an Enumeration to access the Vector of Document objects.
This Exception is thrown by convert algorithms.
ConverterInfo getConverterInfo()
Returns the ConvertInfo that corresponds to this plug-in.
An implementation of Document for StarOffice documents.
Document getContentDOM()
Return a DOM Document object of the document content file.
Xslt implementation of org.openoffice.xmerge.DocumentSerializer for the PluginFactoryImpl.
void log(String str)
Sends message to the log object.
Document deserialize()
This method performs the xslt transformation on the supplied Document and returns a ByteArrayOutputSt...
Source resolve(String href, String base)
final ConvertData cd
A ConvertData object assigned to this object.
ByteArrayOutputStream transform(org.w3c.dom.Document xmlDoc)
This method performs the xslt transformation on the supplied Dom Tree.
DocumentDeserializerImpl(PluginFactoryImpl pf, ConvertData cd)
Constructor that assigns the given ConvertData to this object.
final PluginFactoryImpl pluginFactory
This class is an implementation of OfficeDocument for the generic office format.
Xslt implementation of the PluginFactory.
This class is used for logging debug messages.
static final int TRACE
Trace messages.
static void log(int flag, String msg)
Log message based on the flag type.
Class for storing the information about a converter plug-in.
String getJarName()
Returns the jar file name.
String getXsltDeserial()
Returns a String containing the xslt stylesheet URL that is to be used by the Xslt Plug-in Deserializ...
A DocumentDeserializer represents a converter that converts "Device" Document objects into the "Offic...
A Document represents any Document to be converted and the resulting Document from any conversion.
This is an interface used by the DiffAlgorithm and MergeAlgorithm to access a Document.
Object next()
Move to next element in the sequence.
Provides classes for converting basic document types to/from a DOMDocument object,...
Provides an interface for plug-in registration.
Provides general purpose utilities.
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...