01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.cocoon.transformation;
17:
18: import java.io.IOException;
19: import java.io.Serializable;
20: import java.util.Map;
21:
22: import org.apache.avalon.framework.parameters.Parameters;
23: import org.apache.cocoon.ProcessingException;
24: import org.apache.cocoon.caching.CacheableProcessingComponent;
25: import org.apache.cocoon.environment.SourceResolver;
26: import org.apache.excalibur.source.SourceValidity;
27: import org.apache.excalibur.source.impl.validity.NOPValidity;
28: import org.xml.sax.Attributes;
29: import org.xml.sax.SAXException;
30:
31: /**
32: * @cocoon.sitemap.component.documentation
33: * The <code>StripNameSpacesTransformer</code> is a class that can be plugged into a pipeline
34: * to strip all namespaces from a SAX stream. It is much faster (certainly for larger
35: * streams, but easily factor 100) then the conventional stripnamespaces.xsl
36: *
37: * @cocoon.sitemap.component.name stripnamespaces
38: * @cocoon.sitemap.component.logger sitemap.transformer.stripnamespaces
39: *
40: * @cocoon.sitemap.component.pooling.max 32
41: *
42: * @version $Id: StripNameSpacesTransformer.java 518026 2007-03-14 05:25:54Z antonio $
43: * @author ard schrijvers
44: *
45: */
46: public class StripNameSpacesTransformer extends AbstractTransformer
47: implements CacheableProcessingComponent {
48:
49: private static final String EMPTY_NS = "";
50:
51: public void setup(SourceResolver resolver, Map objectModel,
52: String src, Parameters params) throws ProcessingException,
53: SAXException, IOException {
54: // nothing needed
55: }
56:
57: public void startPrefixMapping(String prefix, String uri)
58: throws SAXException {
59: // no prefix
60: }
61:
62: public void endPrefixMapping(String prefix) throws SAXException {
63: // no prefix
64: }
65:
66: public void startElement(String uri, String localName,
67: String qName, Attributes attr) throws SAXException {
68:
69: super .startElement(EMPTY_NS, localName, localName, attr);
70:
71: }
72:
73: public void endElement(String uri, String localName, String qName)
74: throws SAXException {
75: super .endElement(EMPTY_NS, localName, localName);
76: }
77:
78: public Serializable getKey() {
79: return "1";
80: }
81:
82: public SourceValidity getValidity() {
83: return NOPValidity.SHARED_INSTANCE;
84: }
85: }
|