5 /*
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: ToSAXHandler.java,v 1.2.4.1 2005/09/22 11:03:15 pvedula Exp $
22 */
23 package com.sun.org.apache.xml.internal.serializer;
24
25 import java.util.Vector;
26
27 import org.xml.sax.Attributes;
28 import org.xml.sax.ContentHandler;
29 import org.xml.sax.ErrorHandler;
30 import org.xml.sax.SAXException;
31 import org.xml.sax.SAXParseException;
32 import org.xml.sax.ext.LexicalHandler;
33
34 /**
35 * This class is used to provide a base behavior to be inherited
36 * by other To...SAXHandler serializers.
37 *
38 * This class is not a public API.
39 *
40 * @xsl.usage internal
41 */
42 public abstract class ToSAXHandler extends SerializerBase
43 {
44 public ToSAXHandler()
45 {
217 }
218
219 /**
220 * Sets the SAX ContentHandler.
221 * @param _saxHandler The ContentHandler to set
222 */
223 public void setContentHandler(ContentHandler _saxHandler)
224 {
225 this.m_saxHandler = _saxHandler;
226 if (m_lexHandler == null && _saxHandler instanceof LexicalHandler)
227 {
228 // we are not overwriting an existing LexicalHandler, and _saxHandler
229 // is also implements LexicalHandler, so lets use it
230 m_lexHandler = (LexicalHandler) _saxHandler;
231 }
232 }
233
234 /**
235 * Does nothing. The setting of CDATA section elements has an impact on
236 * stream serializers.
237 * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
238 */
239 public void setCdataSectionElements(Vector URI_and_localNames)
240 {
241 // do nothing
242 }
243
244 /** Set whether or not namespace declarations (e.g.
245 * xmlns:foo) should appear as attributes of
246 * elements
247 * @param doOutputNSAttr whether or not namespace declarations
248 * should appear as attributes
249 */
250 public void setShouldOutputNSAttr(boolean doOutputNSAttr)
251 {
252 m_shouldGenerateNSAttribute = doOutputNSAttr;
253 }
254
255 /**
256 * Returns true if namespace declarations from calls such as
257 * startPrefixMapping("prefix1","uri1") should
258 * also be mirrored with self generated additional attributes of elements
259 * that declare the namespace, for example the attribute xmlns:prefix1="uri1"
|
5 /*
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: ToSAXHandler.java,v 1.2.4.1 2005/09/22 11:03:15 pvedula Exp $
22 */
23 package com.sun.org.apache.xml.internal.serializer;
24
25 import java.util.ArrayList;
26
27 import org.xml.sax.Attributes;
28 import org.xml.sax.ContentHandler;
29 import org.xml.sax.ErrorHandler;
30 import org.xml.sax.SAXException;
31 import org.xml.sax.SAXParseException;
32 import org.xml.sax.ext.LexicalHandler;
33
34 /**
35 * This class is used to provide a base behavior to be inherited
36 * by other To...SAXHandler serializers.
37 *
38 * This class is not a public API.
39 *
40 * @xsl.usage internal
41 */
42 public abstract class ToSAXHandler extends SerializerBase
43 {
44 public ToSAXHandler()
45 {
217 }
218
219 /**
220 * Sets the SAX ContentHandler.
221 * @param _saxHandler The ContentHandler to set
222 */
223 public void setContentHandler(ContentHandler _saxHandler)
224 {
225 this.m_saxHandler = _saxHandler;
226 if (m_lexHandler == null && _saxHandler instanceof LexicalHandler)
227 {
228 // we are not overwriting an existing LexicalHandler, and _saxHandler
229 // is also implements LexicalHandler, so lets use it
230 m_lexHandler = (LexicalHandler) _saxHandler;
231 }
232 }
233
234 /**
235 * Does nothing. The setting of CDATA section elements has an impact on
236 * stream serializers.
237 * @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
238 */
239 public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
240 {
241 // do nothing
242 }
243
244 /** Set whether or not namespace declarations (e.g.
245 * xmlns:foo) should appear as attributes of
246 * elements
247 * @param doOutputNSAttr whether or not namespace declarations
248 * should appear as attributes
249 */
250 public void setShouldOutputNSAttr(boolean doOutputNSAttr)
251 {
252 m_shouldGenerateNSAttribute = doOutputNSAttr;
253 }
254
255 /**
256 * Returns true if namespace declarations from calls such as
257 * startPrefixMapping("prefix1","uri1") should
258 * also be mirrored with self generated additional attributes of elements
259 * that declare the namespace, for example the attribute xmlns:prefix1="uri1"
|