You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@locus.apache.org on 2000/10/19 22:21:31 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/xml/xpath XPathAPI.java

bloritsch    00/10/19 13:21:29

  Modified:    src/org/apache/cocoon/components/language/generator Tag:
                        xml-cocoon2 ProgramGeneratorImpl.java
               src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 Logicsheet.java
               src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        XalanTransformer.java
  Removed:     src/org/apache/cocoon/util Tag: xml-cocoon2 DOMUtils.java
               src/org/apache/cocoon/xml/xpath Tag: xml-cocoon2
                        XPathAPI.java
  Log:
  XalanJ2 cleanup.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.14  +1 -2      xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- ProgramGeneratorImpl.java	2000/10/19 14:43:08	1.1.2.13
  +++ ProgramGeneratorImpl.java	2000/10/19 20:21:15	1.1.2.14
  @@ -37,7 +37,6 @@
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
   
   import org.apache.cocoon.util.IOUtils;
  -import org.apache.cocoon.util.DOMUtils;
   
   import org.w3c.dom.Document;
   import org.w3c.dom.Document;
  @@ -50,7 +49,7 @@
    * The default implementation of <code>ProgramGenerator</code>
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.13 $ $Date: 2000/10/19 14:43:08 $
  + * @version CVS $Revision: 1.1.2.14 $ $Date: 2000/10/19 20:21:15 $
    */
   public class ProgramGeneratorImpl
     implements ProgramGenerator, Composer, Configurable
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +11 -287   xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java
  
  Index: Logicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/Logicsheet.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- Logicsheet.java	2000/10/19 16:39:23	1.1.2.5
  +++ Logicsheet.java	2000/10/19 20:21:18	1.1.2.6
  @@ -46,7 +46,7 @@
    * This class should probably be based on an interface...
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/10/19 16:39:23 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/10/19 20:21:18 $
    */
   public class Logicsheet {
       /**
  @@ -55,12 +55,6 @@
       protected Templates templates;
   
       /**
  -    * the template namespace's list
  -    */
  -    protected Map namespaces;
  -
  -
  -    /**
       * The constructor. It does preserve the namespace from the stylesheet.
       *
       * @param inputSource The stylesheet's input source
  @@ -71,301 +65,31 @@
           throws SAXException, IOException
       {
           Processor processor = Processor.newInstance("xslt");
  +
           // Create a XMLReader with the namespace-prefixes feature
           XMLReader reader = XMLReaderFactory.createXMLReader();
           reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
  -        namespaces = new HashMap();
  -        // Create a XMLFilter that save the namespace hold in the stylesheet
  -        XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaces);
  -        saveNSFilter.setParent(reader);
  +
           // Create the TemplatesBuilder and register as ContentHandler
  -        TemplatesBuilder temBuilder = processor.getTemplatesBuilder();
  -        saveNSFilter.setContentHandler(temBuilder);
  +        TemplatesBuilder templatesBuilder = processor.getTemplatesBuilder();
  +	reader.setContentHandler(templatesBuilder);
  +	if(templatesBuilder instanceof org.xml.sax.ext.LexicalHandler)
  +	    reader.setProperty("http://xml.org/sax/properties/lexical-handler",
  +	                       templatesBuilder);
  +
           // Parse and get the templates
           reader.parse(inputSource);
  -        this.templates = temBuilder.getTemplates();
  +        this.templates = templatesBuilder.getTemplates();
       }
   
       /**
       * Get the XMLFilter that performs the stylesheet transformation.
  -    * The XMLFilter might be an aggregation of XMLFilter that does additional
  -    * namespace preserving as stylesheet processing may drop namespace required
  -    * by further code-generation steps.
       *
       * @return The XMLFilter for the associated stylesheet.
       */
       public XMLFilter getXMLFilter() {
  -        XMLFilter transformer = templates.newTransformer();
  -
  -        // The collection that hold the original namespace's declarations
  -        Map originalNamespaces = new HashMap();
  -
  -        // 'Wraps' the transformer with two filters that do the the namespace preserving.
  -        XMLFilter saveNSFilter = new SaveNamespaceFilter(originalNamespaces);
  -        XMLFilter restoreNSFilter = new RestoreNamepaceFilter(this.namespaces, originalNamespaces);
  -
  -        // constructs and returns an aggregate filter.
  -        return new AggregateFilter(saveNSFilter, transformer, restoreNSFilter);
  -
  -    }
  -
  -    /**
  -     * The aggregator filter aggregate 3 filters as if there were one filter.
  -     * This allows us to work with one filter, whereas it internally manage the
  -     * SaveNamespaceFilter as prefilter, a Transformer as a mainfilter, and a
  -     * RestoreNamepaceFilter as a postfilter.
  -     */
  -    protected class AggregateFilter implements XMLFilter {
  -
  -        /**
  -         * the preFilter, usually an instance of SaveNamespaceFilter
  -         */
  -        protected XMLFilter preFilter;
  -
  -        /**
  -         * the mainFilter, usually an instance of Transformer
  -         */
  -        protected XMLFilter mainFilter;
  -
  -        /**
  -         * the postFilter, usually an instance of RestoreNamepaceFilter
  -         */
  -        protected XMLFilter postFilter;
  -
  -        private XMLReader parent;
  -
  -        /**
  -         * The constructor chaina the prefilter, the mainfilter and the
  -         * postfilter in the respective order.
  -         */
  -        public AggregateFilter (XMLFilter preFilter, XMLFilter mainFilter, XMLFilter postFilter) {
  -            this.preFilter = preFilter;
  -            this.mainFilter = mainFilter;
  -            this.postFilter = postFilter;
  -        }
  -
  -        //
  -        // Implements XMLFilter interface
  -        //
  -        public void setParent (XMLReader parent) {
  -        	this.parent = parent;
  -            preFilter.setParent(parent);
  -            mainFilter.setParent(preFilter);
  -            postFilter.setParent(mainFilter);
  -        }
  -
  -        public XMLReader getParent () {
  -	        return parent;
  -        }
  -
  -        //
  -        // Implements XMLReader interface
  -        //
  -        public boolean getFeature (String name)
  -            throws SAXNotRecognizedException, SAXNotSupportedException {
  -            return parent.getFeature(name);
  -        }
  -
  -        public void setFeature (String name, boolean value)
  -            throws SAXNotRecognizedException, SAXNotSupportedException {
  -            parent.setFeature(name, value);
  -        }
  -
  -        public Object getProperty (String name)
  -            throws SAXNotRecognizedException, SAXNotSupportedException {
  -            return parent.getProperty(name);
  -        }
  -
  -        public void setProperty (String name, Object value)
  -            throws SAXNotRecognizedException, SAXNotSupportedException {
  -            parent.setProperty(name, value);
  -        }
  -
  -        public void setEntityResolver (EntityResolver resolver) { }
  -
  -        public EntityResolver getEntityResolver () { return null; }
  -
  -        public void setDTDHandler (DTDHandler handler) { }
  -
  -        public DTDHandler getDTDHandler () { return null; }
  -
  -        public void setContentHandler (ContentHandler handler) {
  -            this.postFilter.setContentHandler(handler);
  -        }
  -
  -        public ContentHandler getContentHandler () {
  -            return this.postFilter.getContentHandler();
  -        }
  -
  -        public void setErrorHandler (ErrorHandler handler) { }
  +        return templates.newTransformer();
   
  -        public ErrorHandler getErrorHandler () { return null; }
  -
  -        public void parse (InputSource input)
  -            throws SAXException, IOException  {
  -            this.getParent().parse(input);
  -        }
  -
  -        public void parse (String systemId)
  -            throws SAXException, IOException {
  -            this.parse(new InputSource(systemId));
  -        }
  -
  -    }
  -
  -    /**
  -     * This filter listen for source SAX events, and register the declared
  -     * namespaces into a <code>Map</code> object.
  -     *
  -     */
  -    protected class SaveNamespaceFilter extends XMLFilterImpl {
  -
  -        private boolean isRootElem;
  -
  -        private Map originalNamepaces;
  -
  -        /**
  -         * The contructor needs an initialized <code>Map</code> object where it
  -         * can store the found namespace declarations.
  -         * @param originalNamepaces a initialized <code>Map</code> instance.
  -         */
  -        public SaveNamespaceFilter(Map originalNamepaces) {
  -            this.originalNamepaces = originalNamepaces;
  -        }
  -
  -        /**
  -         * @param reader the parent reader
  -         * @see XMLFilter
  -         */
  -        public void setParent(XMLReader reader) {
  -            super.setParent(reader);
  -            reader.setContentHandler(this);
  -        }
  -
  -        /**
  -         * @see ContentHandler
  -         */
  -        public void startDocument () throws SAXException {
  -            isRootElem=true;
  -            super.startDocument();
  -        }
  -
  -        /**
  -         * @see ContentHandler
  -         */
  -        public void startPrefixMapping(String prefix, String uri) throws SAXException {
  -            originalNamepaces.put(prefix, uri);
  -            super.startPrefixMapping(prefix, uri);
  -        }
  -    }
  -
  -    /**
  -     * This filter listen for SAX events generated by the transformer filter,
  -     * and store back the registered namespaces to the output SAX stream.
  -     *
  -     */
  -    protected class RestoreNamepaceFilter extends XMLFilterImpl {
  -
  -        private boolean isRootElem;
  -
  -        // FIXME (SSA) Xalan2 workaround, should be removed
  -        private boolean hasStarted;
  -
  -        private Map originalNamespaces;
  -
  -        /**
  -         * Contructor needs a <code>Map</code> object where the stylesheet namespace
  -         * have been stored, plus another <code>Map</code> object where the original
  -         * namespaces from input document have been stored.
  -         */
  -        public RestoreNamepaceFilter(Map stylesheetNamespaces, Map originalNamespaces) {
  -            this.originalNamespaces = originalNamespaces;
  -            this.originalNamespaces.putAll(stylesheetNamespaces);
  -        }
  -
  -        /**
  -         * @see XMLFilter
  -         */
  -        public void setParent(XMLReader reader) {
  -            super.setParent(reader);
  -            reader.setContentHandler(this);
  -        }
  -
  -        public void startDocument () throws SAXException {
  -            super.startDocument();
  -            isRootElem=true;
  -            // FIXME (SSA) Xalan2 workaround, should be removed
  -            hasStarted= true;
  -        }
  -
  -        public void endDocument () throws SAXException {
  -            // endMappingPrefix for orginal namespace
  -            // FIXME (SSA) Xalan2j workaround, should be removed
  -            Set prefixes = originalNamespaces.keySet();
  -            Object[] keys = prefixes.toArray();
  -            for (int i=(keys.length-1); i>=0; i--) {
  -                super.endPrefixMapping((String) keys[i]);
  -            }
  -            // FIXME (SSA) Xalan2j workaround, should be replaced
  -    //      Iterator iter = prefixes.iterator();
  -    //      String prefix;
  -    //      while(iter.hasNext()) {
  -    //          prefix = (String) iter.next();
  -    //          super.endPrefixMapping(prefix);
  -    //      }
  -            // Forward endDocument event
  -            super.endDocument();
  -
  -            // FIXME (SSA) Xalan2 workaround, should be removed
  -            hasStarted= false;
  -        }
  -
  -
  -        public void startPrefixMapping(String prefix, String uri) throws SAXException {
  -            // FIXME (SSA) Xalan2 workaround, should be put back
  -    //      if(isRootElem ) {
  -    //          if (originalNamespaces.containsKey(prefix)) {
  -    //              originalNamespaces.remove(prefix);
  -    //          }
  -    //      }
  -            // FIXME (SSA) Xalan2 workaround, should be removed
  -            if (hasStarted)
  -                super.startPrefixMapping(prefix, uri);
  -
  -        }
  -
  -        public void endPrefixMapping(String prefix) throws SAXException {
  -            super.endPrefixMapping(prefix);
  -        }
  -
  -
  -
  -        public void startElement (String namespaceURI, String localName,
  -        			      String qName, Attributes atts) throws SAXException {
  -            if(isRootElem) {
  -                isRootElem=false;
  -                // We are in the root element so send the registered namespaces
  -                Set prefixes = originalNamespaces.keySet();
  -                Iterator iter = prefixes.iterator();
  -                String prefix;
  -                while(iter.hasNext()) {
  -                    prefix = (String) iter.next();
  -                    super.startPrefixMapping(prefix, (String) originalNamespaces.get(prefix));
  -                }
  -                // FIXME (SSA) Xalan2 workaround, should be removed
  -                AttributesImpl newAtts = new AttributesImpl(atts);
  -                int attsLen = newAtts.getLength();
  -                for (int i=0; i<attsLen; i++) {
  -                    // force the URI to empty string, otherwise Xalan2J doesn't
  -                    // interpret correctly the 'namespace::' axis (XPath axis)
  -                    newAtts.setURI(i, "");
  -                }
  -                atts = newAtts;
  -            }
  -            super.startElement(namespaceURI, localName, qName, atts);
  -        }
  -
       }
  -
   }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.16  +2 -3      xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java
  
  Index: XalanTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/XalanTransformer.java,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- XalanTransformer.java	2000/10/19 16:40:00	1.1.2.15
  +++ XalanTransformer.java	2000/10/19 20:21:22	1.1.2.16
  @@ -25,7 +25,6 @@
   import org.apache.cocoon.Roles;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.store.Store;
  -import org.apache.cocoon.util.DOMUtils;
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.ContentHandlerWrapper;
   
  @@ -43,7 +42,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.15 $ $Date: 2000/10/19 16:40:00 $
  + * @version CVS $Revision: 1.1.2.16 $ $Date: 2000/10/19 20:21:22 $
    */
   public class XalanTransformer extends ContentHandlerWrapper
   implements Transformer, Composer, Poolable {
  @@ -63,7 +62,7 @@
           Templates templates = (Templates)templatesCache.get(xsluri);
           if(templates == null)
           {
  -    	    Processor processor = DOMUtils.getXSLTProcessor();
  +    	    Processor processor = Processor.newInstance("xslt");
   	    templates = processor.process(resolver.resolveEntity(null, xsluri));
               templatesCache.put(xsluri,templates);
           }