6 * Copyright 2001-2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 /*
21 * $Id: Transform.java,v 1.2.4.1 2005/09/12 09:07:33 pvedula Exp $
22 */
23
24 package com.sun.org.apache.xalan.internal.xsltc.cmdline;
25
26 import java.io.FileNotFoundException;
27 import java.net.MalformedURLException;
28 import java.net.UnknownHostException;
29 import java.util.Vector;
30
31 import javax.xml.parsers.SAXParser;
32 import javax.xml.parsers.SAXParserFactory;
33 import javax.xml.transform.sax.SAXSource;
34
35 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
36 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
37 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
38 import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
39 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
40 import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
41 import com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter;
42 import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
43 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
44
45 import org.xml.sax.InputSource;
46 import org.xml.sax.SAXException;
47 import org.xml.sax.XMLReader;
48
49 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
50 import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
51 import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
52 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
53
54 /**
55 * @author Jacek Ambroziak
56 * @author Santiago Pericas-Geertsen
57 * @author G. Todd Miller
58 * @author Morten Jorgensen
59 */
60 final public class Transform {
61
62 private SerializationHandler _handler;
63
64 private String _fileName;
65 private String _className;
66 private String _jarFileSrc;
67 private boolean _isJarFileSpecified = false;
68 private Vector _params = null;
69 private boolean _uri, _debug;
70 private int _iterations;
71
72 public Transform(String className, String fileName,
73 boolean uri, boolean debug, int iterations) {
98
99 private void doTransform() {
100 try {
101 final Class clazz = ObjectFactory.findProviderClass(_className, true);
102 final AbstractTranslet translet = (AbstractTranslet)clazz.newInstance();
103 translet.postInitialization();
104
105 // Create a SAX parser and get the XMLReader object it uses
106 final SAXParserFactory factory = SAXParserFactory.newInstance();
107 try {
108 factory.setFeature(Constants.NAMESPACE_FEATURE,true);
109 }
110 catch (Exception e) {
111 factory.setNamespaceAware(true);
112 }
113 final SAXParser parser = factory.newSAXParser();
114 final XMLReader reader = parser.getXMLReader();
115
116 // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
117 XSLTCDTMManager dtmManager =
118 (XSLTCDTMManager)XSLTCDTMManager.getDTMManagerClass()
119 .newInstance();
120
121 DTMWSFilter wsfilter;
122 if (translet != null && translet instanceof StripFilter) {
123 wsfilter = new DOMWSFilter(translet);
124 } else {
125 wsfilter = null;
126 }
127
128 final DOMEnhancedForDTM dom =
129 (DOMEnhancedForDTM)dtmManager.getDTM(
130 new SAXSource(reader, new InputSource(_fileName)),
131 false, wsfilter, true, false, translet.hasIdCall());
132
133 dom.setDocumentURI(_fileName);
134 translet.prepassDocument(dom);
135
136 // Pass global parameters
137 int n = _params.size();
138 for (int i = 0; i < n; i++) {
139 Parameter param = (Parameter) _params.elementAt(i);
|
6 * Copyright 2001-2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 /*
21 * $Id: Transform.java,v 1.2.4.1 2005/09/12 09:07:33 pvedula Exp $
22 */
23
24 package com.sun.org.apache.xalan.internal.xsltc.cmdline;
25
26 import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
27 import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
28 import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
29 import com.sun.org.apache.xalan.internal.xsltc.TransletException;
30 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
31 import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
32 import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
33 import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
34 import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
35 import com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter;
36 import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
37 import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
38 import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
39 import java.io.FileNotFoundException;
40 import java.net.MalformedURLException;
41 import java.net.UnknownHostException;
42 import java.util.Vector;
43 import javax.xml.parsers.SAXParser;
44 import javax.xml.parsers.SAXParserFactory;
45 import javax.xml.transform.sax.SAXSource;
46 import org.xml.sax.InputSource;
47 import org.xml.sax.SAXException;
48 import org.xml.sax.XMLReader;
49
50 /**
51 * @author Jacek Ambroziak
52 * @author Santiago Pericas-Geertsen
53 * @author G. Todd Miller
54 * @author Morten Jorgensen
55 */
56 final public class Transform {
57
58 private SerializationHandler _handler;
59
60 private String _fileName;
61 private String _className;
62 private String _jarFileSrc;
63 private boolean _isJarFileSpecified = false;
64 private Vector _params = null;
65 private boolean _uri, _debug;
66 private int _iterations;
67
68 public Transform(String className, String fileName,
69 boolean uri, boolean debug, int iterations) {
94
95 private void doTransform() {
96 try {
97 final Class clazz = ObjectFactory.findProviderClass(_className, true);
98 final AbstractTranslet translet = (AbstractTranslet)clazz.newInstance();
99 translet.postInitialization();
100
101 // Create a SAX parser and get the XMLReader object it uses
102 final SAXParserFactory factory = SAXParserFactory.newInstance();
103 try {
104 factory.setFeature(Constants.NAMESPACE_FEATURE,true);
105 }
106 catch (Exception e) {
107 factory.setNamespaceAware(true);
108 }
109 final SAXParser parser = factory.newSAXParser();
110 final XMLReader reader = parser.getXMLReader();
111
112 // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
113 XSLTCDTMManager dtmManager =
114 XSLTCDTMManager.createNewDTMManagerInstance();
115
116 DTMWSFilter wsfilter;
117 if (translet != null && translet instanceof StripFilter) {
118 wsfilter = new DOMWSFilter(translet);
119 } else {
120 wsfilter = null;
121 }
122
123 final DOMEnhancedForDTM dom =
124 (DOMEnhancedForDTM)dtmManager.getDTM(
125 new SAXSource(reader, new InputSource(_fileName)),
126 false, wsfilter, true, false, translet.hasIdCall());
127
128 dom.setDocumentURI(_fileName);
129 translet.prepassDocument(dom);
130
131 // Pass global parameters
132 int n = _params.size();
133 for (int i = 0; i < n; i++) {
134 Parameter param = (Parameter) _params.elementAt(i);
|