dims        01/04/12 14:12:41

  Modified:    src/org/apache/cocoon/components/language/markup Tag:
                        xml-cocoon2 AbstractMarkupLanguage.java
                        Logicsheet.java
               src/org/apache/cocoon/components/language/markup/sitemap
                        Tag: xml-cocoon2 SitemapMarkupLanguage.java
               src/org/apache/cocoon/components/language/markup/xsp Tag:
                        xml-cocoon2 XSPMarkupLanguage.java
               webapp   Tag: xml-cocoon2 cocoon.xconf
  Log:
  Recursively add Logic Sheets. Sorry, i have not yet taken care of circular
  dependencies. :)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.31  +24 -5     
xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java
  
  Index: AbstractMarkupLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/Attic/AbstractMarkupLanguage.java,v
  retrieving revision 1.1.2.30
  retrieving revision 1.1.2.31
  diff -u -r1.1.2.30 -r1.1.2.31
  --- AbstractMarkupLanguage.java       2001/04/12 12:30:33     1.1.2.30
  +++ AbstractMarkupLanguage.java       2001/04/12 21:12:35     1.1.2.31
  @@ -13,6 +13,8 @@
   import java.net.URL;
   import java.net.MalformedURLException;
   import java.util.Date;
  +import java.util.Map;
  +import java.util.Iterator;
   import java.util.Vector;
   import java.util.List;
   import java.util.ArrayList;
  @@ -47,7 +49,8 @@
    * Base implementation of <code>MarkupLanguage</code>. This class uses
    * logicsheets as the only means of code generation. Code generation should 
be decoupled from this context!!!
    * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.1.2.30 $ $Date: 2001/04/12 12:30:33 $
  + * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
  + * @version CVS $Revision: 1.1.2.31 $ $Date: 2001/04/12 21:12:35 $
    */
   public abstract class AbstractMarkupLanguage extends AbstractLoggable 
implements MarkupLanguage, Composer, Configurable {
       /** The supported language table */
  @@ -273,7 +276,7 @@
        * @exception IOException IO Error
        * @exception SAXException Logicsheet parse error
        */
  -    protected void addLogicsheet(LogicsheetCodeGenerator codeGenerator, 
String logicsheetLocation, EntityResolver entityResolver)
  +    protected void addLogicsheet(LogicsheetCodeGenerator codeGenerator, 
LanguageDescriptor language, String logicsheetLocation, EntityResolver 
entityResolver)
           throws MalformedURLException, IOException, SAXException {
               String systemId = null;
               InputSource inputSource = null;
  @@ -315,6 +318,22 @@
                   this.addDependency(IOUtils.getFullFilename(entry.getFile()));
               }
               codeGenerator.addLogicsheet(logicsheet);
  +            Map namespaces = logicsheet.getNamespaces();
  +            if(!logicsheetLocation.equals(language.getLogicsheet()))
  +            {
  +                if(namespaces != null && namespaces.size()>0) {
  +                    Iterator iter = namespaces.keySet().iterator();
  +                    while(iter.hasNext()) {
  +                        String namespace = (String) iter.next();
  +                        String namedLogicsheetName = 
language.getNamedLogicsheet(namespace);
  +                        if(namedLogicsheetName!= null && 
!logicsheetLocation.equals(namedLogicsheetName)) {
  +                            getLogger().debug("Adding embedded logic sheet 
for " + namespace + ":" + namedLogicsheetName);
  +                            // Add embedded logic sheets too.
  +                            addLogicsheet(codeGenerator, language, 
namedLogicsheetName, entityResolver);
  +                        }
  +                    }
  +                }
  +            }
       }
       //
       // Inner classes
  @@ -529,12 +548,12 @@
                           String[] prefixNamingArray = (String[]) 
this.startPrefixes.get(i);
                           String namedLogicsheetName = 
this.language.getNamedLogicsheet(prefixNamingArray[0]);
                           if (namedLogicsheetName != null) {
  -                            
AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator,
  -                                namedLogicsheetName, resolver);
  +                            
AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator, 
language, 
  +                                                namedLogicsheetName, 
resolver);
                           }
                       }
                       // Add the language stylesheet (Always the last one)
  -                    
AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator, 
this.language.getLogicsheet(), resolver);
  +                    
AbstractMarkupLanguage.this.addLogicsheet(this.logicsheetMarkupGenerator, 
language, this.language.getLogicsheet(), resolver);
                   } catch (IOException ioe) {
                       throw new SAXException(ioe);
                   }
  
  
  
  1.1.2.14  +89 -2     
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.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- Logicsheet.java   2001/02/01 18:44:39     1.1.2.13
  +++ Logicsheet.java   2001/04/12 21:12:36     1.1.2.14
  @@ -46,7 +46,7 @@
    * transformed into an equivalent XSLT stylesheet anyway... This class 
should probably be based on an interface...
    * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/02/01 18:44:39 $
  + * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/12 21:12:36 $
    */
   public class Logicsheet extends AbstractLoggable {
       /** The trax TransformerFactory */
  @@ -56,6 +56,20 @@
       protected Templates templates;
   
       /**
  +    * the template namespace's list
  +    */
  +    protected Map namespaces = new HashMap();
  +
  +
  +    /**
  +     * This will return the list of namespaces in this logicsheet.
  +     */
  +    public Map getNamespaces()
  +    {
  +        return namespaces;
  +    }
  +
  +    /**
        * The constructor. It does preserve the namespace from the stylesheet.
        * @param inputSource The stylesheet's input source
        * @exception IOException IOError processing input source
  @@ -64,7 +78,31 @@
       public void setInputSource(InputSource inputSource) throws SAXException, 
IOException {
           try {
               tfactory = 
(SAXTransformerFactory)TransformerFactory.newInstance();
  -            templates = tfactory.newTemplates(new SAXSource(inputSource));
  +            //templates = tfactory.newTemplates(new SAXSource(inputSource));
  +
  +            // Create a Templates ContentHandler to handle parsing of the 
  +            // stylesheet.
  +            javax.xml.transform.sax.TemplatesHandler templatesHandler = 
  +                                                
tfactory.newTemplatesHandler();
  +
  +            // Create an XMLReader and set its ContentHandler.
  +            org.xml.sax.XMLReader reader = 
  +                           
org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
  +            
reader.setFeature("http://xml.org/sax/features/namespace-prefixes";, true);
  +
  +            // Create a XMLFilter that save the namespace hold in the 
stylesheet
  +            XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaces);
  +            saveNSFilter.setParent(reader);
  +
  +            saveNSFilter.setContentHandler(templatesHandler);
  +            //reader.setContentHandler(templatesHandler);
  +    
  +            // Parse the stylesheet.                       
  +            reader.parse(inputSource);
  +
  +            // Get the Templates object (generated during the parsing of the 
stylesheet)
  +            // from the TemplatesHandler.
  +            templates = templatesHandler.getTemplates();
           } catch (TransformerConfigurationException e) {
               getLogger().error("Logicsheet.setInputSource", e);
           }
  @@ -84,4 +122,53 @@
           }
           return null;
       }
  +
  +    /**
  +     * This filter listen for source SAX events, and register the declared
  +     * namespaces into a <code>Map</code> object.
  +     *
  +     */
  +    protected class SaveNamespaceFilter extends XMLFilterImpl {
  +
  +        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 {
  +            super.startDocument();
  +        }
  +
  +        /**
  +         * @see ContentHandler
  +         */
  +        public void startPrefixMapping(String prefix, String uri) throws 
SAXException {
  +            originalNamepaces.put(prefix,uri);
  +            super.startPrefixMapping(prefix, uri);
  +        }
  +
  +        public void startElement (String namespaceURI, String localName,
  +                                   String qName, Attributes atts) throws 
SAXException {
  +            super.startElement(namespaceURI, localName, qName, atts);
  +        }
  +    }
  +
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.14  +3 -3      
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java
  
  Index: SitemapMarkupLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/Attic/SitemapMarkupLanguage.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- SitemapMarkupLanguage.java        2001/02/08 14:25:31     1.1.2.13
  +++ SitemapMarkupLanguage.java        2001/04/12 21:12:37     1.1.2.14
  @@ -39,7 +39,7 @@
    * <a href="http://xml.apache.org/cocoon/sitemap.html";>Sitemap</a>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/02/08 14:25:31 $
  + * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/12 21:12:37 $
    */
   public class SitemapMarkupLanguage extends AbstractMarkupLanguage {
   
  @@ -297,7 +297,7 @@
                       href = href.substring(0, end);
                       try {
                           SitemapMarkupLanguage.this.addLogicsheet(
  -                            this.logicsheetMarkupGenerator, href, 
this.resolver
  +                            this.logicsheetMarkupGenerator, language,  href, 
this.resolver
                           );
                       } catch (IOException ioe) {
                           log.warn("IOException in SitemapMarkupLanguage", 
ioe);
  @@ -339,7 +339,7 @@
                           String location = atts.getValue("location");
                           try {
                               SitemapMarkupLanguage.this.addLogicsheet(
  -                                this.logicsheetMarkupGenerator,
  +                                this.logicsheetMarkupGenerator, language, 
                                   location,
                                   this.resolver
                               );
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.11  +3 -3      
xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java
  
  Index: XSPMarkupLanguage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPMarkupLanguage.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- XSPMarkupLanguage.java    2001/01/31 15:21:37     1.1.2.10
  +++ XSPMarkupLanguage.java    2001/04/12 21:12:38     1.1.2.11
  @@ -41,7 +41,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Sahuc</a>
  - * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/01/31 15:21:37 $
  + * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/04/12 21:12:38 $
    */
   public class XSPMarkupLanguage extends AbstractMarkupLanguage {
   
  @@ -360,7 +360,7 @@
                       href = href.substring(0, end);
                       try {
                           XSPMarkupLanguage.this.addLogicsheet(
  -                            this.logicsheetMarkupGenerator,
  +                            this.logicsheetMarkupGenerator, language, 
                               href, this.resolver
                           );
                       } catch (IOException ioe) {
  @@ -413,7 +413,7 @@
                           String location = atts.getValue("location");
                           try {
                               XSPMarkupLanguage.this.addLogicsheet(
  -                                this.logicsheetMarkupGenerator,
  +                                this.logicsheetMarkupGenerator, language, 
                                   location, this.resolver
                               );
                           } catch (IOException ioe) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.37  +6 -0      xml-cocoon/webapp/Attic/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/Attic/cocoon.xconf,v
  retrieving revision 1.1.2.36
  retrieving revision 1.1.2.37
  diff -u -r1.1.2.36 -r1.1.2.37
  --- cocoon.xconf      2001/04/10 17:09:04     1.1.2.36
  +++ cocoon.xconf      2001/04/12 21:12:39     1.1.2.37
  @@ -68,6 +68,12 @@
             <parameter name="uri" value="http://apache.org/xsp/log"/>
             <parameter name="href" 
value="resource://org/apache/cocoon/components/language/markup/xsp/java/log.xsl"/>
           </builtin-logicsheet>
  +
  +        <builtin-logicsheet>
  +          <parameter name="prefix" value="util"/>
  +          <parameter name="uri" value="http://apache.org/xsp/util"/>
  +          <parameter name="href" 
value="resource://org/apache/cocoon/components/language/markup/xsp/java/util.xsl"/>
  +        </builtin-logicsheet>
         </target-language>
       </component-instance>
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to