xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@locus.apache.org
Subject cvs commit: xml-stylebook/src/org/apache/stylebook/data engine.xml entities.xml loader.xml stylebook.properties
Date Wed, 01 Dec 1999 06:00:36 GMT
pier        99/11/30 22:00:36

  Modified:    src/org/apache/stylebook StyleBook.java URLHandler.java
  Added:       src/org/apache/stylebook/data engine.xml entities.xml
                        loader.xml stylebook.properties
  Removed:     src/org/apache/stylebook engine.conf.xml loader.conf.xml
                        stylebook.properties
  Log:
  Added tests for External Entities support and moved non-java file in a different directory.
  
  Revision  Changes    Path
  1.3       +11 -7     xml-stylebook/src/org/apache/stylebook/StyleBook.java
  
  Index: StyleBook.java
  ===================================================================
  RCS file: /home/cvs/xml-stylebook/src/org/apache/stylebook/StyleBook.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StyleBook.java	1999/11/30 12:28:52	1.2
  +++ StyleBook.java	1999/12/01 06:00:35	1.3
  @@ -21,7 +21,7 @@
    * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
    * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
    *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.2 $ $Date: 1999/11/30 12:28:52 $
  + * @version CVS $Revision: 1.3 $ $Date: 1999/12/01 06:00:35 $
    */
   public class StyleBook implements Logger {
       /** The project on wich we must operate */
  @@ -29,7 +29,7 @@
       /** Our properties */
       private Properties properties=null;
       /** The properties file */
  -    private String propertiesfile="org/apache/stylebook/stylebook.properties";
  +    private String propertiesfile="org/apache/stylebook/data/stylebook.properties";
       /** Deny construction */
       private StyleBook() {}
   
  @@ -66,7 +66,10 @@
           if(style==null) exit("Style file non specified",1);
           File projectFile=new File(project);
           File styleFile=new File(style);
  -        URLHandler u=new URLHandler(projectFile,styleFile);
  +        File entitiesFile=null;
  +        String entities=this.properties.getProperty("entitiesFile");
  +        if (entities!=null) entitiesFile=new File(entities);
  +        URLHandler u=new URLHandler(projectFile,styleFile,entitiesFile);
           URL.setURLStreamHandlerFactory(u);
           this.project=new URL("sbk:/sources/"+projectFile.getName());
           log("Project URL: \""+this.project+"\"");
  @@ -84,7 +87,8 @@
               if (e==null) exit("Error creating engine",3);
               Project p=sb.getProject(e);
               if (p==null) exit("Error creating project",3);
  -            StreamHandler s=new StreamHandler(sb.properties.getProperty("target.dir"));
  +            String targets=sb.properties.getProperty("targetDirectory");
  +            StreamHandler s=new StreamHandler(targets);
               Enumeration n=p.getEntryNames();
               while (n.hasMoreElements()) {
                   String t=(String)n.nextElement();
  @@ -103,8 +107,8 @@
       /** Create and Initialize Engine */
       private Engine getEngine() throws IOException {
           try {
  -            String parser=properties.getProperty("parser.class");
  -            URL config=new URL(properties.getProperty("engine.conf"));
  +            String parser=properties.getProperty("parserClass");
  +            URL config=new URL(properties.getProperty("engineConfig"));
               return(new BasicEngine(parser,config,this));
           } catch (InitializationException e) {
               log(e);
  @@ -116,7 +120,7 @@
       private Project getProject(Engine e) throws IOException {
           try {
               Loader l=new Loader(e);
  -            URL u=new URL(properties.getProperty("loader.conf"));
  +            URL u=new URL(properties.getProperty("loaderConfig"));
               return(l.load(u,project));
           } catch (LoadingException x) {
               log(x);
  
  
  
  1.2       +36 -19    xml-stylebook/src/org/apache/stylebook/URLHandler.java
  
  Index: URLHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-stylebook/src/org/apache/stylebook/URLHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- URLHandler.java	1999/11/30 12:28:52	1.1
  +++ URLHandler.java	1999/12/01 06:00:35	1.2
  @@ -26,58 +26,74 @@
    * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
    * @author Copyright 1999 &copy; <a href="http://www.apache.org">The Apache
    *         Software Foundation</a>. All rights reserved.
  - * @version CVS $Revision: 1.1 $ $Date: 1999/11/30 12:28:52 $
  + * @version CVS $Revision: 1.2 $ $Date: 1999/12/01 06:00:35 $
    */
   public class URLHandler implements URLStreamHandlerFactory {
  -    private URL style=null;
  -    private URL sources=null;
  +    private URL sty=null;
  +    private URL src=null;
  +    private URL ent=null;
       
       public URLHandler() {
           super();
       }
   
  -    public URLHandler(File sources, File style) throws IOException {
  +    public URLHandler(File sources, File style, File entities)
  +    throws IOException {
           super();
  +        if (sources==null) throw new IOException("Null Sources");
           if (style==null) throw new IOException("Null Style");
  -        if (sources==null) throw new IOException("Null sources");
   
           if (style.isDirectory()) {
  -            this.style=style.getCanonicalFile().toURL();
  +            this.sty=style.getCanonicalFile().toURL();
           } else if (style.exists()) {
               // Check if it's a proper ZipFile
               new ZipFile(style).close();
  -            this.style=new URL("jar:"+style.getCanonicalFile().toURL()+"!/");
  +            this.sty=new URL("jar:"+style.getCanonicalFile().toURL()+"!/");
           } else throw new IOException("Style File/Directory not found");
   
           if (sources.isDirectory()) {
  -            this.sources=sources.getCanonicalFile().toURL();
  +            this.src=sources.getCanonicalFile().toURL();
           } else if (sources.isFile()) {
  -            this.sources=sources.getCanonicalFile().getParentFile().toURL();
  -        } else throw new IOException("sources File/Directory not found");
  +            this.src=sources.getCanonicalFile().getParentFile().toURL();
  +        } else throw new IOException("Sources File/Directory not found");
  +
  +        if (entities!=null) {
  +            if (sources.isFile()) {
  +                this.ent=entities.getCanonicalFile().toURL();
  +            } else throw new IOException("Entity File not found");
  +        }
       }
       
       public URLStreamHandler createURLStreamHandler(String protocol) {
  -        if (style==null) return(null);
           if (protocol==null) return(null);
  -        if (protocol.equalsIgnoreCase("sbk"))
  -            return(new StylebookStreamHandler(this.style,this.sources));
  -        if (protocol.equalsIgnoreCase("res"))
  -            return(new ResourceStreamHandler());
  -        else return(null);
  +        try {
  +            if (protocol.equalsIgnoreCase("sbk"))
  +                return(new StylebookStreamHandler(this.sty,this.src,this.ent));
  +            if (protocol.equalsIgnoreCase("res"))
  +                return(new ResourceStreamHandler());
  +            else return(null);
  +        } catch (IOException e) {
  +            return(null);
  +        }
       }
   
       private class StylebookStreamHandler extends URLStreamHandler {
           private URL style=null;
           private URL sources=null;
  +        private URL entities=null;
   
           private StylebookStreamHandler() {
               super();
           }
   
  -        private StylebookStreamHandler(URL style, URL sources) {
  +        private StylebookStreamHandler(URL style, URL sources, URL entities)
  +        throws IOException {
               this();
               this.style=style;
               this.sources=sources;
  +            if (entities==null)
  +                entities=new URL("res:/org/apache/stylebook/data/entities.xml");
  +            this.entities=entities;
           }
   
           public URLConnection openConnection(URL u) throws IOException {
  @@ -93,8 +109,9 @@
               } else if (file.startsWith("sources/")) {
                   if (file.length()==8) return(this.sources.openConnection());
                   return new URL(this.sources,file.substring(8)).openConnection();
  -            }
  -            else throw new IOException("Invalid StyleBook URL \""+u+"\"");
  +            } else if (file.equals("entities")) {
  +                return(this.entities.openConnection());
  +            } else throw new IOException("Invalid StyleBook URL \""+u+"\"");
           }
       }
   
  
  
  
  1.1                  xml-stylebook/src/org/apache/stylebook/data/engine.xml
  
  Index: engine.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS $Revision: 1.1 $ $Date: 1999/12/01 06:00:35 $ -->
  
  <engine>
    <debug enabled="true"/>
  
    <parser class="org.apache.stylebook.parsers.CachingParser">
      <parameter name="parserclass" value="org.apache.stylebook.parsers.XercesParser"/>
      <parameter name="cachesize" value="10"/>
    </parser>
  
    <producer name="parser" class="org.apache.stylebook.producers.ParserProducer"/>
    <producer name="context" class="org.apache.stylebook.producers.ContextProducer"/>
    <producer name="project" class="org.apache.stylebook.producers.ProjectProducer"/>
    <producer name="directory" class="org.apache.stylebook.producers.DirectoryProducer"/>
  
    <processor name="null" class="org.apache.stylebook.processors.NullProcessor"/>
    <processor name="xslt" class="org.apache.stylebook.processors.XalanProcessor"/>
    <processor name="import" class="org.apache.stylebook.processors.ImportProcessor"/>
  
    <printer name="xml" class="org.apache.stylebook.printers.XMLPrinter"/>
    <printer name="html" class="org.apache.stylebook.printers.HTMLPrinter"/>
    <printer name="image" class="org.apache.stylebook.printers.ImagePrinter"/>
  </engine>
  
  
  
  
  1.1                  xml-stylebook/src/org/apache/stylebook/data/entities.xml
  
  Index: entities.xml
  ===================================================================
  <?xml encoding='US-ASCII'?>
  
  
  
  1.1                  xml-stylebook/src/org/apache/stylebook/data/loader.xml
  
  Index: loader.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- CVS $Revision: 1.1 $ $Date: 1999/12/01 06:00:36 $ -->
  
  <loader>
      <processor name="xslt"/>
  </loader>
  
  
  
  1.1                  xml-stylebook/src/org/apache/stylebook/data/stylebook.properties
  
  Index: stylebook.properties
  ===================================================================
  # CVS $Revision: 1.1 $ $Date: 1999/12/01 06:00:36 $
  
  parserClass=org.apache.stylebook.parsers.XercesParser
  engineConfig=res:/org/apache/stylebook/data/engine.xml
  loaderConfig=sbk:/style/loader.xml
  targetDirectory=.
  
  
  
  

Mime
View raw message