stylebook/0000775000175000017500000000000010524615566012453 5ustar marcusmarcusstylebook/bin/0000775000175000017500000000000010524615560013215 5ustar marcusmarcusstylebook/bin/xalan.LICENSE.txt0000664000175000017500000000521110524601076016136 0ustar marcusmarcus/* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ stylebook/bin/stylebook-1.0-b1.LICENSE.txt0000664000175000017500000000521110524601076017642 0ustar marcusmarcus/* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ stylebook/bin/xerces.LICENSE.txt0000664000175000017500000000521110524601076016324 0ustar marcusmarcus/* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ stylebook/bin/stylebook-1.0-b2.LICENSE.txt0000664000175000017500000000521110524601076017643 0ustar marcusmarcus/* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ stylebook/src/0000775000175000017500000000000010524615560013234 5ustar marcusmarcusstylebook/src/org/0000775000175000017500000000000010524615560014023 5ustar marcusmarcusstylebook/src/org/apache/0000775000175000017500000000000010524615560015244 5ustar marcusmarcusstylebook/src/org/apache/stylebook/0000775000175000017500000000000010524615560017257 5ustar marcusmarcusstylebook/src/org/apache/stylebook/data/0000775000175000017500000000000010524615560020170 5ustar marcusmarcusstylebook/src/org/apache/stylebook/data/project.dtd0000664000175000017500000000517010524601076022333 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/project.xml0000664000175000017500000000347210524601076022363 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/loader.dtd0000664000175000017500000000137210524601076022133 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/loader.xml0000664000175000017500000000144610524601076022162 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/engine.dtd0000664000175000017500000000257510524601076022140 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/engine.xml0000664000175000017500000000255310524601076022161 0ustar marcusmarcus stylebook/src/org/apache/stylebook/data/stylebook.properties0000664000175000017500000000114110524601076024313 0ustar marcusmarcus############################################################################ # The StyleBook principal configuration file. # The class used to parse the loader, engine and project files parserClass=org.apache.stylebook.parsers.XercesParser # The URL of the location of the engine configuration engineConfig=res:/org/apache/stylebook/data/engine.xml # The URL of the location of the loader configuration loaderConfig=sbk:/style/loader.xml # The default targets directory where StyleBook will produce output targetDirectory=. # CVS $Revision: 313210 $ $Date: 1999-12-01 13:55:30 +0100 (ons, 01 dec 1999) $ stylebook/src/org/apache/stylebook/Parser.java0000664000175000017500000000402210524601076021351 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.net.URL; import org.w3c.dom.Document; import org.xml.sax.InputSource; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public interface Parser extends Component{ /** * Parse the specified InputSource. * * @param in The InputSource to parse. * @return A non-null DOM Document object. * @exception IOException If an I/O error occourred accessing the specified * System-ID. * @exception CreationException If an error occourred parsing the document. */ public Document parse(InputSource in) throws IOException, CreationException; /** * Parse the specified InputSource. * * @param in The InputSource to parse. * @return A non-null DOM Document object. * @exception IOException If an I/O error occourred accessing the specified * System-ID. * @exception CreationException If an error occourred parsing the document. */ public Document parse(URL url) throws IOException, CreationException; /** * Create a new empty DOM Document object. * * @return A non-null DOM Document object. */ public Document create(); } stylebook/src/org/apache/stylebook/Logger.java0000664000175000017500000000206410524601076021340 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Logger { /** * Report a message to the user. * * @param msg The log message to report. */ public void log(Object source, String message); } stylebook/src/org/apache/stylebook/CreationException.java0000664000175000017500000000726010524601076023547 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import org.w3c.dom.Document; /** * A CreationException is thrown whenever an Entry cannot be produced for * any reason. * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class CreationException extends Exception { private transient Exception exception=null; private transient Document document=null; /** * Create a new CreationException instance. */ public CreationException() { this(null,null,null); } /** * Create a new CreationException instance with a specified detail message. * * @param m The detail message. */ public CreationException(String m) { this(m,null,null); } /** * Create a new CreationException instance with a specified nested * exception. * * @param e The nested exception. */ public CreationException(Exception e) { this(null,e,null); } /** * Create a new CreationException instance with a specified invalid * document. * * @param d The invalid document. */ public CreationException(Document d) { this(null,null,d); } /** * Create a new CreationException instance with a specified detail message * and a specified nested exception. * * @param m The detail message. * @param e The nested exception. */ public CreationException(String m, Exception e) { this(m,e,null); } /** * Create a new CreationException instance with a specified detail message * and a specified invalid document. * * @param m The detail message. * @param d The invalid document. */ public CreationException(String m, Document d) { this(m,null,d); } /** * Create a new CreationException instance with a specified nested * exception and a specified invalid document. * * @param e The nested exception. * @param d The invalid document. */ public CreationException(Exception e, Document d) { this(null,e,d); } /** * Create a new CreationException instance with a specified detail message, * a specified nested exception and a specified invalid document. * * @param m The detail message. * @param e The nested exception. * @param d The invalid document. */ public CreationException(String m, Exception e, Document d) { super(m); this.exception=e; this.document=d; } /** * Retrieve the nested exception of this CreationException. * * @return The invalid document or null if this wasn't specified. */ public Exception getException() { return(this.exception); } /** * Retrieve the invalid document of this CreationException. * * @return The invalid document or null if this wasn't specified. */ public Document getDocument() { return(this.document); } } stylebook/src/org/apache/stylebook/InitializationException.java0000664000175000017500000000257510524601076024776 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; /** * A InitializationException is thrown whenever a Component cannot be * initialized for any reason. * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class InitializationException extends Exception { /** * Create a new InitializationException instance. */ public InitializationException() { super(); } /** * Create a new InitializationException instance with a specified detail * message. * * @param m The detail message. */ public InitializationException(String m) { super(m); } } stylebook/src/org/apache/stylebook/CreationContext.java0000664000175000017500000000201210524601076023223 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.net.URL; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public interface CreationContext extends Parameters { public URL getSourceURL(); public String getTargetName(); } stylebook/src/org/apache/stylebook/Processor.java0000664000175000017500000000213410524601076022076 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Processor extends Component { public Document process(Document doc, CreationContext c, Parameters p) throws CreationException, IOException; } stylebook/src/org/apache/stylebook/BasicParameters.java0000664000175000017500000000562610524601076023175 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.util.Enumeration; import java.util.Hashtable; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class BasicParameters implements Parameters { private Hashtable table=null; public BasicParameters() { super(); this.table=new Hashtable(); } /** * Retrieve a value for a specified parameter. * * @param name The parameter name. * @return The parameter value or null if the parameter has no specified * value. */ public String getParameter(String name) { return((String)this.table.get(name)); } /** * Retrieve a value for a specified parameter. * * @param name The parameter name. * @param def The parameter default value. * @return The parameter value or def if the parameter has no specified * value. */ public String getParameter(String name, String def) { String val=getParameter(name); if (val==null) return(def); else return(val); } /** * Get all valid parameter names. * * @return A non-null (maybe empty) Enumeration. */ public Enumeration getParameterNames() { return(table.keys()); } /** * Set or update parameter value. * * @parameter name The parameter name. * @parameter value The parameter value. * @return The old value of the parameter or null. */ public String setParameter(String name, String value) { if (value==null) return((String)this.table.remove(name)); else return((String)this.table.put(name,value)); } /** * Merge the values from another Parameters object into this instance. * * @param p The Parameters object from wich values must be retrieved. */ public Parameters merge(Parameters p) { if (p==null) return(this); Enumeration e=p.getParameterNames(); while (e.hasMoreElements()) { String name=(String)e.nextElement(); String value=p.getParameter(name); this.setParameter(name,value); } return(this); } }stylebook/src/org/apache/stylebook/Project.java0000664000175000017500000001377710524601076021544 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.util.Enumeration; import java.util.Hashtable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313221 $ $Date: 1999-12-01 19:39:14 +0100 (ons, 01 dec 1999) $ */ public class Project { private Hashtable entries=new Hashtable(); private Engine engine=null; private URL urlbase=null; public Project(Engine engine, Document project, Parameters parambase, URL u) throws LoadingException, IOException { this.engine=engine; this.urlbase=u; Element root=project.getDocumentElement(); if(!root.getTagName().equals("project")) throw new LoadingException("Project does not start with "); NodeList l=root.getChildNodes(); Parameters parameters=new NodeListParameters(l).merge(parambase); processNodeList(l,this.urlbase,parameters); } private void processNodeList(NodeList l, URL urlbase, Parameters parambase) throws LoadingException, IOException { for(int x=0;x"); } } public Enumeration getEntryNames() { return(this.entries.keys()); } public void create(String name, OutputStream out) throws IOException, CreationException { this.engine.log(this,"Creating \""+name+"\""); Entry e=(Entry)this.entries.get(name); if(e==null) throw new CreationException("No Entry \""+name+"\""); e.create(out); } private void setCreateEntry(Element e, URL urlbase, Parameters parambase) throws LoadingException, IOException { URL source=new URL(urlbase,e.getAttribute("source")); String target=e.getAttribute("target"); Entry entry=new BasicEntry(this.engine,source,target,e,parambase); Entry old=(Entry)this.entries.put(target,entry); if(old!=null) if(!old.equals(entry)) throw new LoadingException("Duplicate Entry \""+target+"\""); } private void setResourceEntry(Element e, URL urlbase) throws LoadingException, IOException { URL source=new URL(urlbase,e.getAttribute("source")); String target=e.getAttribute("target"); Entry entry=new ResourceEntry(this.engine,source,target); Entry old=(Entry)this.entries.put(target,entry); if(old!=null) if(!old.equals(entry)) throw new LoadingException("Duplicate Entry \""+target+"\""); } private void processEntry(Element e, URL urlbase, Parameters parambase) throws LoadingException, IOException { // Get the producer and the source, create a temporary context String prod=e.getAttribute("producer"); URL source=new URL(urlbase,e.getAttribute("source")); CreationContext ctx=new BasicContext(source,""); ctx.merge(parambase); // Try to load the producer this.engine.debug(this,"Processing Source=\""+source+"\" ["+prod+"]"); Producer producer=this.engine.getProducer(prod); if (producer==null) throw new LoadingException("Invalid Producer \""+prod+"\""); // Get local parameters NodeList l=e.getChildNodes(); ctx.merge(new NodeListParameters(l)); // Try to create the subproject Document doc=null; try { // Produce the document doc=producer.produce(ctx); // For every processor, generate the project for(int x=0;x"); Processor proc=this.engine.getProcessor(el.getAttribute("name")); if(proc==null) throw new LoadingException("No Processr \""+proc+"\""); Parameters p=new NodeListParameters(el.getChildNodes()).merge(ctx); doc=proc.process(doc,ctx,p); } } catch (CreationException x) { x.printStackTrace(System.out); throw new LoadingException("Processing Entry ("+x.getMessage()+")"); } // Check for proper document if (doc==null) return; // Do as a top-level project recursively Element root=doc.getDocumentElement(); if(!root.getTagName().equals("project")) throw new LoadingException("Result of process is not "); l=root.getChildNodes(); Parameters p=new NodeListParameters(l).merge(ctx); processNodeList(l,source,p); } } stylebook/src/org/apache/stylebook/Component.java0000664000175000017500000000244610524601076022067 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Component { /** * Initialize this component instance. * * @param e The Engine owning this Component instance * @param p This component initialization Parameters * @exception InitializationException If this Component instance cannot be * initialized. */ public void init(Engine e, Parameters p) throws InitializationException; } stylebook/src/org/apache/stylebook/Printer.java0000664000175000017500000000216510524601076021546 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.io.OutputStream; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Printer extends Component { public void print(Document doc, CreationContext c, OutputStream out) throws CreationException, IOException; } stylebook/src/org/apache/stylebook/StyleBook.java0000664000175000017500000001321710524601076022036 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.net.URL; import java.util.Enumeration; import java.util.Properties; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313278 $ $Date: 2000-07-14 20:31:36 +0200 (fre, 14 jul 2000) $ */ public class StyleBook implements Logger { /** The project on wich we must operate */ private URL project=null; /** Our properties */ private Properties properties=null; /** The properties file */ private String propertiesfile="org/apache/stylebook/data/stylebook.properties"; /** Deny construction */ private StyleBook() {} /** Create the StyleBook object */ private StyleBook(String argv[]) throws IOException { super(); this.properties=new Properties(); ClassLoader loader=this.getClass().getClassLoader(); InputStream in=loader.getResourceAsStream(propertiesfile); this.properties.load(in); String project=null; String style=null; for(int x=0;xPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Parameters { /** * Retrieve a value for a specified parameter. * * @param name The parameter name. * @return The parameter value or null if the parameter has no specified * value. */ public String getParameter(String name); /** * Retrieve a value for a specified parameter. * * @param name The parameter name. * @param def The parameter default value. * @return The parameter value or def if the parameter has no specified * value. */ public String getParameter(String name, String def); /** * Get all valid parameter names. * * @return A non-null (maybe empty) Enumeration. */ public Enumeration getParameterNames(); /** * Set or update parameter value. * * @parameter name The parameter name. * @parameter value The parameter value. * @return The old value of the parameter or null. */ public String setParameter(String name, String value); /** * Merge the values from another Parameters object into this instance. * * @param p The Parameters object from wich values must be retrieved. */ public Parameters merge(Parameters p); }stylebook/src/org/apache/stylebook/BasicEngine.java0000664000175000017500000001726610524601076022302 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.net.URL; import java.util.Enumeration; import java.util.Hashtable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class BasicEngine implements Engine { /** Our Parser instance */ private Parser parser=null; /** The Producer table */ private Hashtable producers=new Hashtable(); /** The Processor table */ private Hashtable processors=new Hashtable(); /** The Printers table */ private Hashtable printers=new Hashtable(); /** The Logger instance */ private Logger logger=null; /** The debug() activation flag */ private boolean debug=false; /** * Create a new instance of this Engine. * * @param parser The name of the Parser class used to read configuration. * @param cont The SystemID of the configuration file. * @param logger The Logger used by this Engine. */ public BasicEngine(String parser, URL conf, Logger logger) throws InitializationException { super(); // Check the Logger if (logger==null) throw new InitializationException("No Logger instance specified"); else this.logger=logger; // Parse the configuration file with the specified Parser Parser pars=ComponentFactory.getParser(parser); pars.init(this,new BasicParameters()); Document d=null; try { if ((d=pars.parse(conf))==null) throw new InitializationException("Parser returned null doc"); } catch (Exception e) { throw new InitializationException("Cannot parse configurations \""+ conf+"\""); } // Step thru the different elements to configure the engine this.logger.log(this,"Initializing"); Element e=d.getDocumentElement(); if (!e.getTagName().equals("engine")) throw new InitializationException("Conf don't begin with "); NodeList l=e.getChildNodes(); for (int x=0; x"); } if(this.parser==null) this.parser=pars; } /** Configure the Parser from a givent Element */ private void configureParser(Element e) throws InitializationException { if (this.parser!=null) throw new InitializationException("Parser already configured"); String classname=e.getAttribute("class"); this.parser=ComponentFactory.getParser(classname); this.parser.init(this,new NodeListParameters(e.getChildNodes())); } /** Configure a Producer from a givent Element */ private void configureProducer(Element e) throws InitializationException { String name=e.getAttribute("name"); String cls=e.getAttribute("class"); if(name.length()==0) throw new InitializationException("No name specified for Producer"); Producer p=ComponentFactory.getProducer(cls); p.init(this,new NodeListParameters(e.getChildNodes())); if(this.producers.put(name,p)!=null) throw new InitializationException("Duplucate Producer \""+ name+"\""); } /** Configure a Processor from a givent Element */ private void configureProcessor(Element e) throws InitializationException { String name=e.getAttribute("name"); String cls=e.getAttribute("class"); if(name.length()==0) throw new InitializationException("No name specified for Processor"); Processor p=ComponentFactory.getProcessor(cls); p.init(this,new NodeListParameters(e.getChildNodes())); if(this.processors.put(name,p)!=null) throw new InitializationException("Duplucate Processor \""+ name+"\""); } /** Configure a Printer from a givent Element */ private void configurePrinter(Element e) throws InitializationException { String name=e.getAttribute("name"); String cls=e.getAttribute("class"); if(name.length()==0) throw new InitializationException("No name specified for Printer"); Printer p=ComponentFactory.getPrinter(cls); p.init(this,new NodeListParameters(e.getChildNodes())); if(this.printers.put(name,p)!=null) throw new InitializationException("Duplucate Printer \""+ name+"\""); } /** * Return the Parser instance owned by this Engine. * * @return A non-null Parser instance. */ public Parser getParser() { return(this.parser); } /** * Return a Producer instance associated with the specified name. * * @param name A non-null String representing the Producer name. * @return A non-null Producer instance or null if no Producer is associated * with the specified name. */ public Producer getProducer(String name) { return((Producer)this.producers.get(name)); } /** * Return a Processor instance associated with the specified name. * * @param name A non-null String representing the Processor name. * @return A non-null Processor instance or null if no Processor is * associated with the specified name. */ public Processor getProcessor(String name) { return((Processor)this.processors.get(name)); } /** * Return a Printer instance associated with the specified name. * * @param name A non-null String representing the Printer name. * @return A non-null Printer instance or null if no Printer is * associated with the specified name. */ public Printer getPrinter(String name) { return((Printer)this.printers.get(name)); } /** * Report a debug message to the user. * * @param msg The debug message to report. */ public void debug(Object source, String msg) { if(this.debug) this.logger.log(source,msg); } /** * Report a log message to the user. * * @param msg The log message to report. */ public void log(Object source, String msg) { this.logger.log(source,msg); } } stylebook/src/org/apache/stylebook/processors/0000775000175000017500000000000010524615560021461 5ustar marcusmarcusstylebook/src/org/apache/stylebook/processors/Xalan2Processor.java0000664000175000017500000001141710524601076025352 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 2000 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.processors; import org.apache.stylebook.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.io.Reader; import java.net.URL; import java.util.Enumeration; import java.util.StringTokenizer; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.xml.sax.InputSource; import org.xml.sax.SAXException; // Imported TraX classes import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerConfigurationException; // Imported JAVA API for XML Parsing 1.0 classes import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; /* * A revision of XalanProcessor for use with Xalan-Java 2. * If you build Stylebook with Xalan2Processor rather than XalanProcessor, you can * use Stylebook to process documents with Xalan-Java 2. * * @author Donald Leslie (donald_leslie@lotus.com) */ public class Xalan2Processor extends AbstractComponent implements Processor { public Document process(Document doc, CreationContext c, Parameters p) throws CreationException, IOException { try { // Retrieve the style String styf=p.getParameter("stylesheet"); if (null==styf) styf=this.getStyleSheet(doc); if (null==styf) return(doc); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(styf)); // Set stylesheet parameters Enumeration en=p.getParameterNames(); while (en.hasMoreElements()) { String name=(String)en.nextElement(); transformer.setParameter(name, p.getParameter(name)); } // Set up DOM container for result. DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setNamespaceAware(true); DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); Document res = docBuilder.newDocument(); // Perform the transformation. log("Applying XSL sheet \""+styf+"\""); transformer.transform(new DOMSource(doc), new DOMResult(res)); return(res); } catch (Exception e) { e.printStackTrace(System.out); throw new CreationException(e.getMessage(),e,doc); } } /** Search for the <?xml:stylesheet ... ?> processing instruction. */ private String getStyleSheet(Document sourceTree) { String uri=null; NodeList children=sourceTree.getChildNodes(); int nNodes=children.getLength(); for(int i=0; iPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class NullProcessor extends AbstractComponent implements Processor { public Document process(Document doc, CreationContext c, Parameters p) throws CreationException, IOException { log("Processing document"); return(doc); } } stylebook/src/org/apache/stylebook/processors/XalanProcessor.java0000664000175000017500000001351710524601076025273 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.processors; import org.apache.stylebook.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.io.Reader; import java.net.URL; import java.util.Enumeration; import java.util.StringTokenizer; import org.apache.xalan.xpath.xml.FormatterToDOM; import org.apache.xalan.xpath.xml.XMLParserLiaison; import org.apache.xalan.xpath.xml.XMLParserLiaisonDefault; import org.apache.xalan.xslt.XSLTInputSource; import org.apache.xalan.xslt.XSLTProcessor; import org.apache.xalan.xslt.XSLTProcessorFactory; import org.apache.xalan.xslt.XSLTResultTarget; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class XalanProcessor extends AbstractComponent implements Processor { public Document process(Document doc, CreationContext c, Parameters p) throws CreationException, IOException { try { // Create a new XSLTProcessor instance XMLParserLiaison liaison=new Liaison(this.engine); XSLTProcessor proc=XSLTProcessorFactory.getProcessor(liaison); proc.setDiagnosticsOutput(System.out); // Set processor parameters Enumeration enum=p.getParameterNames(); while (enum.hasMoreElements()) { String name=(String)enum.nextElement(); proc.setStylesheetParam(name,proc.createXString(p.getParameter(name))); } // Retrieve the style String styf=p.getParameter("stylesheet"); if (null==styf) styf=this.getStyleSheet(doc); if (null==styf) return(doc); // Setup the input sources and the result target Document res=this.engine.getParser().create(); Document sty=this.engine.getParser().parse(new InputSource(styf)); XSLTInputSource docin=new XSLTInputSource(doc); XSLTInputSource styin=new XSLTInputSource(sty); XSLTResultTarget out=new XSLTResultTarget(new FormatterToDOM(res)); // Process the document log("Applying XSL sheet \""+styf+"\""); proc.process(docin,styin,out); return(res); } catch (Exception e) { e.printStackTrace(System.out); throw new CreationException(e.getMessage(),e,doc); } } /** Search for the <?xml:stylesheet ... ?> processing instruction. */ private String getStyleSheet(Document sourceTree) { String uri=null; NodeList children=sourceTree.getChildNodes(); int nNodes=children.getLength(); for(int i=0; iPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class ImportProcessor extends AbstractComponent implements Processor { public Document process(Document doc, CreationContext c, Parameters p) throws CreationException, IOException { processNode(doc.getDocumentElement(),doc,c); return(doc); } private void processNode(Node node, Document doc, CreationContext ctx) throws IOException, CreationException { if(node==null) return; if(node.getNodeType()!=Node.PROCESSING_INSTRUCTION_NODE) { NodeList l=node.getChildNodes(); for (int x=0; xPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class ImagePrinter extends AbstractComponent implements Printer { int R=0; int G=1; int B=2; int A=3; /** * Print a DOM Document. * * @param doc The Document to print. * @param out The OutputStream used for printing. * @param env The Environment of this printing request. * @exception IOException If an I/O error occourred accessing resources. * @exception CreationException If the Document cannot be printed. */ public void print(Document doc, CreationContext ctx, OutputStream out) throws CreationException, IOException { // Check for proper root element Element element=doc.getDocumentElement(); if (!element.getTagName().equals("image")) { throw new CreationException("Invalid document supplied",doc); } // Check wether we have a source image String source=element.getAttribute("source"); BufferedImage img=null; Graphics2D gr=null; // If we have a source image, this is taken as our source. if (source.length()>0) { ImageIcon ico=null; if (source.indexOf(":/")>=0) { ico=new ImageIcon(new URL(source).openConnection().getURL()); } else ico=new ImageIcon(source); if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) { throw new CreationException("Cannot load image \""+source+"\""); } img=new BufferedImage(ico.getIconWidth(), ico.getIconHeight(), BufferedImage.TYPE_INT_RGB); gr=img.createGraphics(); gr.drawImage(ico.getImage(),0,0,ico.getImageObserver()); } else { // We don't have a source image. Build up a new getting height and // width from attributes int w=0; int h=0; try { String width=element.getAttribute("width"); String height=element.getAttribute("height"); w=Integer.parseInt(width); h=Integer.parseInt(height); } catch (NumberFormatException e) { throw new CreationException("Image witdth or height error"); } if ((w<1) | (h<1)) { throw new CreationException("Image witdth or height unspecified"); } img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); gr=img.createGraphics(); // Now process the bgcolor attribute for background colorization int bg=0; try { String bgcolor=element.getAttribute("bgcolor"); bg=Integer.parseInt(bgcolor,16); } catch (NumberFormatException e) { throw new CreationException("Background color error"); } Color c=new Color(bg); gr.setBackground(c); gr.clearRect(0,0,w,h); // Check if we have a background to tile String background=element.getAttribute("background"); if (background.length()>0) { // We have a background image. Load it. ImageIcon ico=new ImageIcon(background); if ((ico.getIconWidth()<1) | (ico.getIconHeight()<1)) { throw new CreationException("Cannot load background \""+source+"\""); } // Tile the image. int x=0; int y=0; while (true) { gr.drawImage(ico.getImage(),x,y,ico.getImageObserver()); x+=ico.getIconWidth(); if (x>w) { x=0; y+=ico.getIconHeight(); } if (y>h) break; } } } // Process child elements NodeList l=element.getChildNodes(); for (int x=0;x0) { na=((double)np[A]/255); ia=(1-na); ip[R]=(int)(((double)ip[R]*ia) + ((double)np[R]*na)); ip[G]=(int)(((double)ip[G]*ia) + ((double)np[G]*na));; ip[B]=(int)(((double)ip[B]*ia) + ((double)np[B]*na));; } ir.setPixel(x,y,ip); } } private boolean placeText(Element e, BufferedImage i) throws CreationException { String text=e.getAttribute("text"); String font=e.getAttribute("font"); String ssize=e.getAttribute("size"); String sstyle=e.getAttribute("style"); String scolor=e.getAttribute("color"); String sx=e.getAttribute("x"); String sy=e.getAttribute("y"); String halign=e.getAttribute("halign"); String valign=e.getAttribute("valign"); // Check proper text if (text.length()<1) return(false); // Check size, x and y parameters int color,size,insx,insy; try { size=Integer.parseInt(ssize); insx=Integer.parseInt(sx); insy=Integer.parseInt(sy); color=Integer.parseInt(scolor,16); } catch (NumberFormatException ex) { throw new CreationException("Attribute size, x, y or color error"); } // Get style int style=Font.PLAIN; if (sstyle.equals("bold")) style=Font.BOLD; else if (sstyle.equals("italic")) style=Font.ITALIC; else if (sstyle.equals("bolditalic")) style=Font.BOLD+Font.ITALIC; Font f=new Font(font,style,size); FontMetrics m=i.createGraphics().getFontMetrics(f); // Create temporary image int w=m.stringWidth(text)*2; int h=m.getHeight()*2; BufferedImage n=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB); // Write out some text Graphics2D gr=n.createGraphics(); gr.setColor(new Color(0x0ff000000,true)); gr.setFont(f); gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); gr.drawString(text,5,h-(h/4)); // Resize image int minx=w; int miny=h; int maxx=0; int maxy=0; WritableRaster nr=n.getRaster(); int np[]=new int[]{0,0,0,0}; for (int x=0;x0) { if(xmaxx) maxx=x; if(ymaxy) maxy=y; } } if (halign.equals("right")) insx=insx-((maxx-minx)+1); if (halign.equals("center")) insx=insx-(((maxx-minx)+1)/2); if (valign.equals("bottom")) insy=insy-((maxy-miny)+1); if (valign.equals("center")) insy=insy-(((maxy-miny)+1)/2); WritableRaster ir=i.getRaster(); int newx,newy; newy=insy; for (int y=miny;y<=maxy;y++) { newx=insx; if(newy>=0) { for (int x=minx;x<=maxx;x++) { nr.getPixel(x,y,np); np[R]=(color >> 16) & 0x0ff; np[G]=(color >> 8) & 0x0ff; np[B]=(color & 0x0ff); if(newx>=0) ir.setPixel(newx,newy,np); newx++; if(newx>=i.getWidth()) break; } } newy++; if(newy>=i.getHeight()) break; } return(true); } } stylebook/src/org/apache/stylebook/printers/HTMLSerializer.java0000664000175000017500000000414010524601076024562 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.printers; import org.apache.stylebook.*; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.Method; import org.apache.xml.serialize.XHTMLSerializer; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313265 $ $Date: 2000-06-06 03:03:21 +0200 (tis, 06 jun 2000) $ */ public class HTMLSerializer extends AbstractComponent implements org.apache.stylebook.Printer { /** * Print a DOM Document. * * @param doc The Document to print. * @param out The OutputStream used for printing. * @param env The Environment of this printing request. * @exception IOException If an I/O error occourred accessing resources. * @exception CreationException If the Document cannot be printed. */ public void print(Document doc, CreationContext c, OutputStream out) throws CreationException, IOException { // Thanks to Ingo Macherius //OutputFormat f=new OutputFormat(OutputFormat.METHOD_XHTML, OutputFormat f=new OutputFormat(Method.XHTML, "US-ASCII",true); //Serializer s=Serializer.makeSerializer(out,f); XHTMLSerializer s = new XHTMLSerializer(out, f); s.serialize(doc); } } stylebook/src/org/apache/stylebook/printers/HTMLPrinter.java0000664000175000017500000003302110524601076024074 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.printers; import org.apache.stylebook.*; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.Entity; import org.w3c.dom.EntityReference; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Notation; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313270 $ $Date: 2000-06-23 23:21:08 +0200 (fre, 23 jun 2000) $ */ public class HTMLPrinter extends AbstractComponent implements Printer { final static String ENCODING = "UTF8"; /** * Print a DOM Document. * * @param doc The Document to print. * @param out The OutputStream used for printing. * @param env The Environment of this printing request. * @exception IOException If an I/O error occourred accessing resources. * @exception CreationException If the Document cannot be printed. */ public void print(Document doc, CreationContext c, OutputStream out) throws CreationException, IOException { BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(out,ENCODING)); printDocument(doc, writer); writer.flush(); } /** Process a nodelist calling the appropriate print...() method. */ private void printNodeList(NodeList list, BufferedWriter out) throws IOException { for ( int x=0;x) node. */ private void printCDATASection(CDATASection node, BufferedWriter out) throws IOException { printString(node.getData(),out); } /** Print a COMMENT () node. */ private void printComment(Comment node, BufferedWriter out) throws IOException { out.write(""); } /** Print a DOCUMENT FRAGMENT (????) node. */ private void printDocumentFragment(DocumentFragment node, BufferedWriter out) throws IOException { out.write(""); } /** Print a DOCUMENT node. */ private void printDocument(Document node, BufferedWriter out) throws IOException { printNodeList(node.getChildNodes(),out); } /** Print a DOCUMENT TYPE () node. */ private void printDocumentType(DocumentType node, BufferedWriter out) throws IOException { out.write(""); } /** Print a ELEMENT (do I need to supply the example ??? :) node. */ private void printElement(Element node, BufferedWriter out) throws IOException { String tag=node.getTagName().toUpperCase(); out.write("<"+tag); // Process attributes NamedNodeMap atts=node.getAttributes(); if ( (null!=atts) && (atts.getLength()>0) ) { for ( int x=0; x"); // Process child nodes if ( (null!=node.getChildNodes()) && (node.getChildNodes().getLength()>0) ) { printNodeList(node.getChildNodes(),out); } // Print the END tag... if ( tag.equals("AREA") ) return; else if ( tag.equals("BASE") ) return; else if ( tag.equals("BASEFONT") ) return; else if ( tag.equals("BR") ) return; else if ( tag.equals("COL") ) return; else if ( tag.equals("FRAME") ) return; else if ( tag.equals("HR") ) return; else if ( tag.equals("IMG") ) return; else if ( tag.equals("INPUT") ) return; else if ( tag.equals("ISINDEX") ) return; else if ( tag.equals("LINK") ) return; else if ( tag.equals("META") ) return; else if ( tag.equals("PARAM") ) return; out.write(""); } /** Print a ENTITY node (NOTE: This should be used with DOCTYPE). */ private void printEntity(Entity node, BufferedWriter out) throws IOException { out.write(""); } /** Print a ENTITY REFERENCE node (NOTE: Again, used in within DOCTYPE). */ private void printEntityReference(EntityReference node, BufferedWriter out) throws IOException { printString(node.getFirstChild().getNodeValue(),out); } /** Print a NOTATION node (NOTE: Again -3rd-, used in within DOCTYPE). */ private void printNotation(Notation node, BufferedWriter out) throws IOException { out.write(""); } /** Print a PROCESSING INSTRUCTION () node. */ private void printProcessingInstruction(ProcessingInstruction node, BufferedWriter out) throws IOException { out.write(""); } /** Print a TEXT (see example for ELEMENT) node. */ private void printText(Text node, BufferedWriter out) throws IOException { printString(node.getData(),out); } private void printString(String data, BufferedWriter out) throws IOException { for ( int x=0; x=160) && (c<=255) ) switch ( c ) { case 160: out.write(" "); break; case 161: out.write("¡"); break; case 162: out.write("¢"); break; case 163: out.write("£"); break; case 164: out.write("¤"); break; case 165: out.write("¥"); break; case 166: out.write("¦"); break; case 167: out.write("§"); break; case 168: out.write("¨"); break; case 169: out.write("©"); break; case 170: out.write("ª"); break; case 171: out.write("«"); break; case 172: out.write("¬"); break; case 173: out.write("­"); break; case 174: out.write("®"); break; case 175: out.write("¯"); break; case 176: out.write("°"); break; case 177: out.write("±"); break; case 178: out.write("²"); break; case 179: out.write("³"); break; case 180: out.write("´"); break; case 181: out.write("µ"); break; case 182: out.write("¶"); break; case 183: out.write("·"); break; case 184: out.write("¸"); break; case 185: out.write("¹"); break; case 186: out.write("º"); break; case 187: out.write("»"); break; case 188: out.write("¼"); break; case 189: out.write("½"); break; case 190: out.write("¾"); break; case 191: out.write("¿"); break; case 192: out.write("À"); break; case 193: out.write("Á"); break; case 194: out.write("Â"); break; case 195: out.write("Ã"); break; case 196: out.write("Ä"); break; case 197: out.write("Å"); break; case 198: out.write("Æ"); break; case 199: out.write("Ç"); break; case 200: out.write("È"); break; case 201: out.write("É"); break; case 202: out.write("Ê"); break; case 203: out.write("Ë"); break; case 204: out.write("Ì"); break; case 205: out.write("Í"); break; case 206: out.write("Î"); break; case 207: out.write("Ï"); break; case 208: out.write("Ð"); break; case 209: out.write("Ñ"); break; case 210: out.write("Ò"); break; case 211: out.write("Ó"); break; case 212: out.write("Ô"); break; case 213: out.write("Õ"); break; case 214: out.write("Ö"); break; case 215: out.write("×"); break; case 216: out.write("Ø"); break; case 217: out.write("Ù"); break; case 218: out.write("Ú"); break; case 219: out.write("Û"); break; case 220: out.write("Ü"); break; case 221: out.write("Ý"); break; case 222: out.write("Þ"); break; case 223: out.write("ß"); break; case 224: out.write("à"); break; case 225: out.write("á"); break; case 226: out.write("â"); break; case 227: out.write("ã"); break; case 228: out.write("ä"); break; case 229: out.write("å"); break; case 230: out.write("æ"); break; case 231: out.write("ç"); break; case 232: out.write("è"); break; case 233: out.write("é"); break; case 234: out.write("ê"); break; case 235: out.write("ë"); break; case 236: out.write("ì"); break; case 237: out.write("í"); break; case 238: out.write("î"); break; case 239: out.write("ï"); break; case 240: out.write("ð"); break; case 241: out.write("ñ"); break; case 242: out.write("ò"); break; case 243: out.write("ó"); break; case 244: out.write("ô"); break; case 245: out.write("õ"); break; case 246: out.write("ö"); break; case 247: out.write("÷"); break; case 248: out.write("ø"); break; case 249: out.write("ù"); break; case 250: out.write("ú"); break; case 251: out.write("û"); break; case 252: out.write("ü"); break; case 253: out.write("ý"); break; case 254: out.write("þ"); break; case 255: out.write("ÿ"); break; } else out.write(c); } } } stylebook/src/org/apache/stylebook/printers/XMLPrinter.java0000664000175000017500000002175510524601076024003 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.printers; import org.apache.stylebook.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.Entity; import org.w3c.dom.EntityReference; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Notation; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; /** * The XMLPrinter Printer writes documents in their canonical XML form. * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class XMLPrinter extends AbstractComponent implements Printer { /** * Print a DOM Document. */ public void print(Document doc, CreationContext c, OutputStream out) throws CreationException, IOException { printDocument(doc,new PrintStream(out),0); } /** Process a nodelist calling the appropriate print...() method. */ private void printNodeList(NodeList list, PrintStream out, int indent) { for (int x=0;x) node. */ private void printCDATASection(CDATASection node, PrintStream out, int indent) { indent(out,indent); out.println("<[CDATA["+node.getData()+"]]>"); } /** Print a COMMENT () node. */ private void printComment(Comment node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a DOCUMENT FRAGMENT (????) node. */ private void printDocumentFragment(DocumentFragment node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a DOCUMENT node. */ private void printDocument(Document node, PrintStream out, int indent) { indent(out,indent); out.println(""); printNodeList(node.getChildNodes(),out,indent); } /** Print a DOCUMENT TYPE () node. */ private void printDocumentType(DocumentType node, PrintStream out, int indent) { indent(out,indent); out.println(""); // Should we insert ENTITIES and NOTATIONS? } /** Print a ELEMENT (do I need to supply the example ??? :) node. */ private void printElement(Element node, PrintStream out, int indent) { // Print the tag name indent(out,indent); out.print("<"+node.getTagName()); // Process attributes NamedNodeMap atts=node.getAttributes(); if ((null!=atts) && (atts.getLength()>0)) { for (int x=0; x0)) { out.println(">"); printNodeList(node.getChildNodes(),out,indent+1); indent(out,indent); out.println(""); } else { out.println("/>"); } } /** Print a ENTITY node (NOTE: This should be used with DOCTYPE). */ private void printEntity(Entity node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a ENTITY REFERENCE node (NOTE: Again, used in within DOCTYPE). */ private void printEntityReference(EntityReference node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a NOTATION node (NOTE: Again -3rd-, used in within DOCTYPE). */ private void printNotation(Notation node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a PROCESSING INSTRUCTION () node. */ private void printProcessingInstruction(ProcessingInstruction node, PrintStream out, int indent) { indent(out,indent); out.println(""); } /** Print a TEXT (see example for ELEMENT) node. */ private void printText(Text node, PrintStream out, int indent) { String data=node.getData(); if (data.length()==0) return; data=leftTrim(data); if (data.length()==0) return; Text curr=node; while(true) { Node nextnode=curr.getNextSibling(); if (nextnode==null) break; if (nextnode.getNodeType()!=Node.TEXT_NODE) break; Text next=(Text)nextnode; String app=next.getData(); if (app.length()>0) { if (Character.isWhitespace(app.charAt(0))) { data=trim(data)+' '+leftTrim(app); } else { data=trim(data)+leftTrim(app); } } next.setData(""); curr=next; } data=trim(data); node.setData(data); if (data.length()>0) { indent(out,indent); out.println(data); } } /** Remove white space at string beginning. */ private String leftTrim(String data) { if (data.length()==0) return(data); int index=0; for (int x=0;x=0;x--) { if (Character.isWhitespace(data.charAt(x))) index=x; else break; } return(data.substring(0,index)); } /** Remove white space at string beginning and ending. */ private String trim(String data) { return(leftTrim(rightTrim(data))); } /** Indent data (print whitespaces). */ private void indent(PrintStream out, int indent) { for (int x=0; xPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class ProjectProducer extends AbstractComponent implements Producer { public Document produce(CreationContext c) throws CreationException, java.io.IOException { String project=c.getParameter("stylebook.project"); if(project==null) throw new CreationException("Cannot produce project"); return(engine.getParser().parse(new InputSource(project))); } } stylebook/src/org/apache/stylebook/producers/DirectoryProducer.java0000664000175000017500000001352410524601076025602 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.producers; import org.apache.stylebook.*; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.Enumeration; import java.util.zip.ZipFile; import java.util.zip.ZipEntry; import org.xml.sax.InputSource; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313274 $ $Date: 2000-07-09 14:44:21 +0200 (sön, 09 jul 2000) $ */ public class DirectoryProducer extends AbstractComponent implements Producer { public Document produce(CreationContext c) throws CreationException, java.io.IOException { // Create the root document and the root element Document d=engine.getParser().create(); Element root=d.createElement("directory"); // Retrieve the REAL url URL source=c.getSourceURL().openConnection().getURL(); // Proceed if the protocol is "file:" if (source.getProtocol().equals("file")) { // Trim the file name and open the directory String src=source.getFile(); // // These lines seems to break UNIX files (duplicating the name // of the directory. // Thanks to "Gerard van Enk" // //for(int x=0;x0) { jarname=source.getFile().substring(0,index); dirname=source.getFile().substring(index+1); if (dirname.equals("/")) dirname=""; } // Check if we can open the jar file (only file:) URL jarurl=new URL(jarname); if (!jarurl.getProtocol().equalsIgnoreCase("file")) throw new CreationException("Cannot open zip files over "+ jarurl.getProtocol()+": protocol"); jarname=jarurl.getFile(); // Remove leading '/' chars from jar name and jar entry if (System.getProperty("path.separator").equals(";")) { // I believe that this is a workaround for a Windows JDK1.1 bug for(int x=0;x0) { ZipEntry e=f.getEntry(dirname); if (e==null) throw new CreationException("Cannot find \""+dirname+ "\" in \""+jarname+"\""); else if (!e.isDirectory()) throw new CreationException("Entry \""+dirname+"\" in \""+ jarname+"\" is not a Directory"); } // Enumerate the JAR entries Enumeration list=new ZipFile(jarname).entries(); while(list.hasMoreElements()) { ZipEntry zipentry=(ZipEntry)list.nextElement(); // Check if the entry begins w/ dirname and doesn't go further String entry=zipentry.getName(); if(!entry.startsWith(dirname)) continue; entry=entry.substring(dirname.length()); if(entry.length()==0) continue; if ((entry.indexOf('/')!=-1) && (entry.indexOf('/')!=entry.length()-1)) continue; // Create the elements Element elem=d.createElement("entry"); elem.setAttribute("href",entry); if(zipentry.isDirectory()) elem.setAttribute("directory","true"); elem.appendChild(d.createTextNode(entry)); root.appendChild(elem); } } d.appendChild(root); return(d); } } stylebook/src/org/apache/stylebook/producers/ContextProducer.java0000664000175000017500000000356310524601076025264 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.producers; import org.apache.stylebook.*; import java.io.IOException; import java.util.Enumeration; import org.xml.sax.InputSource; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class ContextProducer extends AbstractComponent implements Producer { public Document produce(CreationContext c) throws CreationException, java.io.IOException { Document d=engine.getParser().create(); Element root=d.createElement("context"); root.setAttribute("source",c.getSourceURL().toExternalForm()); root.setAttribute("target",c.getTargetName()); Enumeration e=c.getParameterNames(); while(e.hasMoreElements()) { String name=(String)e.nextElement(); String value=c.getParameter(name); Element param=d.createElement("parameter"); param.setAttribute("name",name); param.setAttribute("value",value); root.appendChild(param); } d.appendChild(root); return(d); } } stylebook/src/org/apache/stylebook/producers/ParserProducer.java0000664000175000017500000000236010524601076025066 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.producers; import org.apache.stylebook.*; import java.io.IOException; import org.xml.sax.InputSource; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class ParserProducer extends AbstractComponent implements Producer { public Document produce(CreationContext c) throws CreationException, java.io.IOException { return(engine.getParser().parse(c.getSourceURL())); } } stylebook/src/org/apache/stylebook/parsers/0000775000175000017500000000000010524615560020736 5ustar marcusmarcusstylebook/src/org/apache/stylebook/parsers/AbstractParser.java0000664000175000017500000000237310524601076024523 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.parsers; import org.apache.stylebook.*; import java.io.IOException; import java.net.URL; import org.xml.sax.InputSource; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public abstract class AbstractParser extends AbstractComponent implements Parser { public Document parse(URL in) throws IOException, CreationException { return(this.parse(new InputSource(in.toExternalForm()))); } }stylebook/src/org/apache/stylebook/parsers/XercesParser.java0000664000175000017500000001207110524601076024205 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.parsers; import java.io.IOException; import org.apache.stylebook.AbstractComponent; import org.apache.stylebook.Parser; import org.apache.stylebook.CreationException; import org.apache.xerces.dom.DocumentImpl; import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313289 $ $Date: 2002-01-22 19:24:53 +0100 (tis, 22 jan 2002) $ */ public class XercesParser extends AbstractParser implements Parser,ErrorHandler { DocumentBuilderFactory docFactory; /** * Instantiate a DocumentBuilderFactory. */ public XercesParser() { docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); docFactory.setExpandEntityReferences(true); } /** * Parse the specified InputSource. * * @param in The InputSource to parse. * @return A non-null DOM Document object. * @exception IOException If an I/O error occourred accessing the specified * System-ID. * @exception CreationException If an error occourred parsing the document. */ public Document parse(InputSource in) throws IOException, CreationException { this.debug("Parsing \""+in.getSystemId()+"\""); try { DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document document = docBuilder.parse(in); if (document==null) { throw new CreationException("Cannot retrieve parsed document"); } else return(document); } catch (IOException e) { this.log(e.getMessage()); throw new CreationException("IOException caught while using DocumentBuilder to parse an XML document.",e); } catch (ParserConfigurationException e) { this.log(e.getMessage()); throw new CreationException("ParserConfigurationException caught while using DocumentBuilder to parse an XML document.",e); } catch (SAXNotRecognizedException e) { this.log(e.getMessage()); throw new CreationException("SAXNotRecognizedException caught while using DocumentBuilder to parse an XML document.",e); } catch (SAXException e) { this.log(e.getMessage()); throw new CreationException("SAXException caught using DocumentBuilder to parse an XML document.",e); } } /** * Create a new empty DOM Document object. * * @return A non-null DOM Document object. * @exception DocumentException If the new Document cannot be created. */ public Document create() { this.debug("Creating new Document"); return new DocumentImpl(); } /** * Receive notification of a recoverable error. * * @param e The Exception thrown during parsing. * @exception SAXException The Exception notifying the client. */ public void error(SAXParseException e) throws SAXException { throw new SAXException(e.getMessage()+" [File: \""+e.getSystemId()+ "\" Line: "+e.getLineNumber()+" Column: "+ e.getColumnNumber()+"]",e); } /** * Receive notification of a non-recoverable error. * * @param e The Exception thrown during parsing. * @exception SAXException The Exception notifying the client. */ public void fatalError(SAXParseException e) throws SAXException { throw new SAXException(e.getMessage()+" [File: \""+e.getSystemId()+ "\" Line: "+e.getLineNumber()+" Column: "+ e.getColumnNumber()+"]",e); } /** * Receive notification of a warning. * * @param e The Exception thrown during parsing. * @exception SAXException The Exception notifying the client. */ public void warning(SAXParseException e) throws SAXException { throw new SAXException(e.getMessage()+" [File: \""+e.getSystemId()+ "\" Line: "+e.getLineNumber()+" Column: "+ e.getColumnNumber()+"]",e); } }stylebook/src/org/apache/stylebook/parsers/CachingParser.java0000664000175000017500000001011110524601076024301 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook.parsers; import org.apache.stylebook.*; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import org.xml.sax.InputSource; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class CachingParser extends AbstractParser implements Parser { private Parser parser=null; private int cachesize=10; private Hashtable cache=new Hashtable(); /** * Initialize this component instance. * * @param e The Engine owning this Component instance * @param p This component initialization Parameters */ public void init(Engine e, Parameters p) throws InitializationException { super.init(e,p); // Instantiate the sub-parser String cls=p.getParameter("parserclass"); if (cls==null) throw new InitializationException("Parameter \"parserclass\" not "+ "specified"); this.parser=ComponentFactory.getParser(cls); // Create the parameters for the sub-parser Parameters p2=new BasicParameters(); Enumeration n=p.getParameterNames(); while(n.hasMoreElements()) { String name=(String)n.nextElement(); String value=p.getParameter(name); if(!name.startsWith("parser.")) continue; name=name.substring(7); p2.setParameter(name,value); } // Initialize the sub-parser this.parser.init(e,p2); // Set up the cache size try { this.cachesize=Integer.parseInt(p.getParameter("cachesize")); } catch (Exception x) { debug("Cache size not specified (default=10)"); this.cachesize=10; } } /** * Create a new empty DOM Document object. * * @return A non-null DOM Document object. * @exception DocumentException If the new Document cannot be created. */ public Document create() { return(this.parser.create()); } /** * Parse the specified InputSource. * * @param in The InputSource to parse. * @return A non-null DOM Document object. * @exception IOException If an I/O error occourred accessing the specified * System-ID. * @exception CreationException If an error occourred parsing the document. */ public Document parse(InputSource in) throws IOException, CreationException { String name=in.getSystemId(); if (name==null) return(this.parser.parse(in)); CachedEntry ent=(CachedEntry)this.cache.get(name); Document doc=null; if (ent==null) { doc=this.parser.parse(in); ent=new CachedEntry(doc); this.cache.put(name,ent); } else { ent.hits++; doc=ent.document; if (doc==null) doc=this.parser.parse(in); else log("Serving cached document \""+name+"\" ("+ent.hits+")"); ent.document=doc; } purge(); return(doc); } private void purge() { // Cache purging algorithm... } private class CachedEntry { public Document document=null; public int hits=0; public CachedEntry(Document doc) { this.document=doc; } } }stylebook/src/org/apache/stylebook/BasicEntry.java0000664000175000017500000000647210524601076022173 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.util.Enumeration; import java.util.Vector; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313221 $ $Date: 1999-12-01 19:39:14 +0100 (ons, 01 dec 1999) $ */ public class BasicEntry extends BasicContext implements Entry { private Producer producer=null; private Printer printer=null; private Vector tasks=new Vector(); public BasicEntry(Engine e, URL s, String t, Element d, Parameters p) throws LoadingException { super(s,t); String prod=d.getAttribute("producer"); String prnt=d.getAttribute("printer"); e.debug(this,"Creating Entry Source=\""+s+"\" Target=\""+t+"\""+ " ["+prod+"/"+prnt+"]"); if ((this.producer=e.getProducer(prod))==null) throw new LoadingException("Invalid Producer \""+prod+"\""); if ((this.printer=e.getPrinter(prnt))==null) throw new LoadingException("Invalid Printer \""+prnt+"\""); NodeList l=d.getChildNodes(); Parameters p2=new NodeListParameters(l).merge(p); for(int x=0;x"); Processor proc=e.getProcessor(el.getAttribute("name")); if(proc==null) throw new LoadingException("Invalid Processr \""+proc+"\""); Parameters par=new NodeListParameters(el.getChildNodes()).merge(p2); this.tasks.add(new Task(proc,par)); } this.merge(p2); } public void create(OutputStream out) throws IOException, CreationException { Document d=this.producer.produce(this); Enumeration e=this.tasks.elements(); while(e.hasMoreElements()) { Task t=(Task)e.nextElement(); d=t.processor.process(d,this,t.parameters); } this.printer.print(d,this,out); } private class Task { public Processor processor=null; public Parameters parameters=null; public Task(Processor proc, Parameters param) { this.processor=proc; this.parameters=param; } } public boolean equals(Entry e) { return(false); } } stylebook/src/org/apache/stylebook/StreamHandler.java0000664000175000017500000000351110524601076022650 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class StreamHandler { private File base=null; public StreamHandler(String base) throws IOException { if(base==null) base=System.getProperty("user.dir"); this.base=new File(base).getCanonicalFile(); if(!this.base.isDirectory()) { mkdir(this.base); } } public OutputStream getOutputStream(String name) throws IOException { File f=new File(name); if (f.isAbsolute()) return new FileOutputStream(f); if (f.getParent()!=null) mkdir(new File(base,f.getParent())); return(new FileOutputStream(new File(base,name))); } private void mkdir(File file) throws IOException { if (file==null) return; mkdir(file.getParentFile()); if (file.isDirectory()) return; else file.mkdir(); } } stylebook/src/org/apache/stylebook/Entry.java0000664000175000017500000000211410524601076021216 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.io.OutputStream; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313221 $ $Date: 1999-12-01 19:39:14 +0100 (ons, 01 dec 1999) $ */ public interface Entry { public void create(OutputStream out) throws IOException, CreationException; public boolean equals(Entry e); } stylebook/src/org/apache/stylebook/ComponentFactory.java0000664000175000017500000001133410524601076023413 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class ComponentFactory { /** Deny construction. */ private ComponentFactory() { super(); } /** * Create a new Component instance. * * @param classname The name of the Component class. * @return A non-null Component instance. * @exception InitializationException If the Component instance cannot be * created. */ public static Component getComponent(String classname) throws InitializationException { try { return ((Component)Class.forName(classname).newInstance()); } catch (ClassCastException e) { throw new InitializationException("Class \""+classname+ "\" is not a Component"); } catch (InstantiationException e) { throw new InitializationException("Class \""+classname+ "\" cannot be instantiated"); } catch (IllegalAccessException e) { throw new InitializationException("Class \""+classname+ "\" cannot be accessed"); } catch (ClassNotFoundException e) { throw new InitializationException("Class \""+classname+ "\" not found"); } } /** * Create a new Parser instance. * * @param classname The name of the Parser class. * @return A non-null Parser instance. * @exception InitializationException If the Parser instance cannot be * created. */ public static Parser getParser(String classname) throws InitializationException { try { return ((Parser)getComponent(classname)); } catch (ClassCastException e) { throw new InitializationException("Class \""+classname+ "\" is not a Parser"); } } /** * Create a new Producer instance. * * @param classname The name of the Producer class. * @return A non-null Producer instance. * @exception InitializationException If the Producer instance cannot be * created. */ public static Producer getProducer(String classname) throws InitializationException { try { return ((Producer)getComponent(classname)); } catch (ClassCastException e) { throw new InitializationException("Class \""+classname+ "\" is not a Producer"); } } /** * Create a new Processor instance. * * @param classname The name of the Processor class. * @return A non-null Processor instance. * @exception InitializationException If the Processor instance cannot be * created. */ public static Processor getProcessor(String classname) throws InitializationException { try { return ((Processor)getComponent(classname)); } catch (ClassCastException e) { throw new InitializationException("Class \""+classname+ "\" is not a Processor"); } } /** * Create a new Printer instance. * * @param classname The name of the Printer class. * @return A non-null Printer instance. * @exception InitializationException If the Printer instance cannot be * created. */ public static Printer getPrinter(String classname) throws InitializationException { try { return ((Printer)getComponent(classname)); } catch (ClassCastException e) { throw new InitializationException("Class \""+classname+ "\" is not a Printer"); } } } stylebook/src/org/apache/stylebook/Loader.java0000664000175000017500000000636410524601076021336 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.File; import java.io.IOException; import java.net.URL; import org.xml.sax.InputSource; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class Loader { private Engine engine=null; public Loader(Engine e) { this.engine=e; } public Project load(URL loader, URL project) throws LoadingException { try { // Parse the project file this.engine.log(this,"Parsing Project file"); Document p=this.engine.getParser().parse(project); // Prepare a temporary creationcontext CreationContext c=new BasicContext(project,""); // Parse the loader configuration file this.engine.debug(this,"Parsing Loader configuration"); Document d=this.engine.getParser().parse(loader); // Check the parsed loader configuration root element if (!d.getDocumentElement().getTagName().equals("loader")) throw new LoadingException("Loader config is not "); // Apply the different processors NodeList l=d.getDocumentElement().getChildNodes(); for(int x=0;x"); String name=e.getAttribute("name"); Parameters p=new NodeListParameters(e.getChildNodes()); d=this.engine.getProcessor(name).process(d,c,p); return(d); } }stylebook/src/org/apache/stylebook/BasicContext.java0000664000175000017500000000253310524601076022510 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.net.URL; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313202 $ $Date: 1999-11-30 13:28:55 +0100 (tis, 30 nov 1999) $ */ public class BasicContext extends BasicParameters implements CreationContext { /** Our Source */ private URL source=null; /** Our Target */ private String target=null; public BasicContext(URL source, String target) { super(); this.source=source; this.target=target; } public URL getSourceURL() { return(this.source); } public String getTargetName() { return(this.target); } } stylebook/src/org/apache/stylebook/NodeListParameters.java0000664000175000017500000000274010524601076023667 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.util.Enumeration; import java.util.Hashtable; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class NodeListParameters extends BasicParameters implements Parameters { public NodeListParameters(NodeList l) { super(); if (l!=null) for (int x=0; x * Handled by this factory are the "res" protocol (wich handles * resources derived from the actual or the system class loaders) and the * "sbk" protocol wich handles files in the style name space and the * sources name space. * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313217 $ $Date: 1999-12-01 15:21:27 +0100 (ons, 01 dec 1999) $ */ public class URLHandler implements URLStreamHandlerFactory { private URL sty=null; private URL src=null; public URLHandler() { super(); } public URLHandler(File sources, File style) throws IOException { super(); if (sources==null) throw new IOException("Null Sources"); if (style==null) throw new IOException("Null Style"); if (style.isDirectory()) { this.sty=style.getCanonicalFile().toURL(); } else if (style.exists()) { // Check if it's a proper ZipFile new ZipFile(style).close(); this.sty=new URL("jar:"+style.getCanonicalFile().toURL()+"!/"); } else throw new IOException("Style File/Directory not found"); if (sources.isFile()) { this.src=sources.getCanonicalFile().toURL(); } else throw new IOException("Sources File/Directory not found"); } public URLStreamHandler createURLStreamHandler(String protocol) { if (protocol==null) return(null); try { if (protocol.equalsIgnoreCase("sbk")) return(new StylebookStreamHandler(this.sty,this.src)); 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 StylebookStreamHandler() { super(); } private StylebookStreamHandler(URL style, URL sources) throws IOException { this(); this.style=style; this.sources=sources; } public URLConnection openConnection(URL u) throws IOException { if (u==null) return(null); String file=u.getFile(); for(int x=0;xPierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public class LoadingException extends Exception { /** * Create a new LoadingException instance. */ public LoadingException() { super(); } /** * Create a new LoadingException instance with a specified detail * message. * * @param m The detail message. */ public LoadingException(String m) { super(m); } } stylebook/src/org/apache/stylebook/AbstractComponent.java0000664000175000017500000000377710524601076023563 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public abstract class AbstractComponent implements Component { /** The Engine owning this Component instance. */ protected Engine engine=null; /** This component initialization Parameters. */ protected Parameters params=null; /** * Initialize this component instance. * * @param e The Engine owning this Component instance * @param p This component initialization Parameters */ public void init(Engine e, Parameters p) throws InitializationException { if (e==null) throw new NullPointerException("Null Engine"); if (p==null) throw new NullPointerException("Null Parameters"); this.engine=e; this.params=p; this.debug("Initializing"); } /** * Report a debug message to the owning Engine. * * @param msg The debug message to report. */ protected void debug(String message) { this.engine.debug(this, message); } /** * Report a log message to the owning Engine. * * @param msg The log message to report. */ protected void log(String message) { this.engine.log(this, message); } } stylebook/src/org/apache/stylebook/ResourceEntry.java0000664000175000017500000000360210524601076022731 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313221 $ $Date: 1999-12-01 19:39:14 +0100 (ons, 01 dec 1999) $ */ public class ResourceEntry implements Entry { private URL src=null; public ResourceEntry(Engine e, URL s, String t) { e.debug(this,"Creating Resource Source=\""+s+"\" Target=\""+t+"\""); this.src=s; } public void create(OutputStream o) throws IOException, CreationException { InputStream in=new BufferedInputStream(this.src.openStream()); OutputStream out=new BufferedOutputStream(o); int data=-1; while((data=in.read())!=-1) out.write(data); in.close(); out.flush(); } public boolean equals(Entry e) { try { ResourceEntry r=(ResourceEntry)e; if(r.src.equals(this.src)) return(true); return(false); } catch (Exception x) { return(false); } } } stylebook/src/org/apache/stylebook/Producer.java0000664000175000017500000000207610524601076021707 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.io.IOException; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Producer extends Component{ public Document produce(CreationContext c) throws CreationException, IOException; } stylebook/src/org/apache/stylebook/Engine.java0000664000175000017500000000462410524601076021332 0ustar marcusmarcus/***************************************************************************** * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of wich has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.stylebook; import java.util.Enumeration; import org.w3c.dom.Document; /** * * * @author Pierpaolo Fumagalli * @author Copyright 1999 © The Apache * Software Foundation. All rights reserved. * @version CVS $Revision: 313195 $ $Date: 1999-11-15 23:08:18 +0100 (mån, 15 nov 1999) $ */ public interface Engine { /** * Return the Parser instance owned by this Engine. * * @return A non-null Parser instance. */ public Parser getParser(); /** * Return a Producer instance associated with the specified name. * * @param name A non-null String representing the Producer name. * @return A non-null Producer instance or null if no Producer is associated * with the specified name. */ public Producer getProducer(String name); /** * Return a Processor instance associated with the specified name. * * @param name A non-null String representing the Processor name. * @return A non-null Processor instance or null if no Processor is * associated with the specified name. */ public Processor getProcessor(String name); /** * Return a Printer instance associated with the specified name. * * @param name A non-null String representing the Printer name. * @return A non-null Printer instance or null if no Printer is * associated with the specified name. */ public Printer getPrinter(String name); /** * Report a debug message to the user. * * @param msg The debug message to report. */ public void debug(Object source, String message); /** * Report a log message to the user. * * @param msg The log message to report. */ public void log(Object source, String message); } stylebook/docs/0000775000175000017500000000000010524615560013375 5ustar marcusmarcusstylebook/docs/characters.xml0000664000175000017500000000206410524601076016235 0ustar marcusmarcus

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

This is a regular paragraph. When using <em> we obtain this effect. When, instead, we use <ref> we obtain this other effect. Another interesting modifier is <code> wich produces this effect.

Here is an example of <br>. Here we go to the next line without closing the paragraph tag.
This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

stylebook/docs/faqs-1.xml0000664000175000017500000000266710524601076015217 0ustar marcusmarcus Question 1 of Second file

Answer 1 of Second file

Question 2 of Second file

Answer 2 of Second file

Question 3 of Second file

Answer 3 of Second file

Question 4 of Second file

Answer 4 of Second file

Question 5 of Second file

Answer 5 of Second file

Question 6 of Second file

Answer 6 of Second file

Question 7 of Second file

Answer 7 of Second file

Question 8 of Second file

Answer 8 of Second file

Question 9 of Second file

Answer 9 of Second file

stylebook/docs/faqs-2.xml0000664000175000017500000000263710524601076015215 0ustar marcusmarcus Question 1 of Third file

Answer 1 of Third file

Question 2 of Third file

Answer 2 of Third file

Question 3 of Third file

Answer 3 of Third file

Question 4 of Third file

Answer 4 of Third file

Question 5 of Third file

Answer 5 of Third file

Question 6 of Third file

Answer 6 of Third file

Question 7 of Third file

Answer 7 of Third file

Question 8 of Third file

Answer 8 of Third file

Question 9 of Third file

Answer 9 of Third file

stylebook/docs/faqs.xml0000664000175000017500000000263710524601076015056 0ustar marcusmarcus Question 1 of First file

Answer 1 of First file

Question 2 of First file

Answer 2 of First file

Question 3 of First file

Answer 3 of First file

Question 4 of First file

Answer 4 of First file

Question 5 of First file

Answer 5 of First file

Question 6 of First file

Answer 6 of First file

Question 7 of First file

Answer 7 of First file

Question 8 of First file

Answer 8 of First file

Question 9 of First file

Answer 9 of First file

stylebook/docs/run.bat0000775000175000017500000000021610524601076014670 0ustar marcusmarcus@echo off java -classpath "..\bin\stylebook-1.0-b1.jar" org.apache.stylebook.StyleBook "targetDirectory=targets" book.xml ../styles/apachexml stylebook/docs/test.jpg0000664000175000017500000001416710524601076015064 0ustar marcusmarcusJFIFHHdPhotoshop 3.08BIMHH8BIM x8BIM8BIM 8BIM' 8BIMH/fflff/ff2Z5-8BIMp8BIM@@8BIM8BIM 22JFIFHH&File written by Adobe Photoshop 5.0Adobed            22"?   3!1AQa"q2B#$Rb34rC%Scs5&DTdE£t6UeuF'Vfv7GWgw5!1AQaq"2B#R3$brCScs4%&5DTdEU6teuFVfv'7GWgw ?ly 'b$و`#LjmmMej~ե[@h%=w|:*zDUX'IB%GʲZ81'ALXkDhoIAydp#DT`΅6[/Qߺ>$_I>ЍO'u ov%_ q 0N*1eUt?;[NEߦf[v_@R{qNZ5Dϸ}%k]v{Ƈ0̇Vݬ菣%2R݀m\菽G,kXG)o⢑ZHmoLj-%TFAn':~X3Vc۶H.DCi0mps_QBz-&T.0~F| k#r~ұ̭7պI~:. wn̨@ODž^3/a9&M]I{Z'S<-{I5e5C%qK^g E~$;ҳOg<}k+E<6jty>I}/_dw|{|$Ca7d}3W<I4K/i$ů8BIM XICC_PROFILE HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Km&File written by Adobe Photoshop 5.0Adobed              22"  s!1AQa"q2B#R3b$r%C4Scs5D'6Tdt& EFVU(eufv7GWgw8HXhx)9IYiy*:JZjzm!1AQa"q2#BRbr3$4CS%cs5DT &6E'dtU7()󄔤euFVfvGWgw8HXhx9IYiy*:JZjz ? wkʬ\u$nyQG^<0=l#`|#aY"'%FEJøvp}x> JF?:aMF&ъiGoyHFʣ\C~€h¬7*EvcZ45ۘ;ᇖK{.#ǶWʙI]|OHy.Zl~ xZ@|Fa\\o,h%_MKr4p顏JH)A?\xcQdc(8n؃;c4[/2,AjWz'KlQH\dqʏW_Tm|3N o^pT]m f=Upd!}8?R+=Ώ4,.}Axq rU5=򬞘ˆ7]-JK^TDQïJc PIW׸Y^O/Lʿ߰-\s-ւs2Y#{\/{r!r 'z{B{sMOeV݆##IY'/z

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum. &myentity;

stylebook/docs/sections.xml0000664000175000017500000000652610524601076015754 0ustar marcusmarcus

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Nos autem fortes viri satis facere rei publicae videmur, si istius furorem ac tela vitemus. Ad mortem te, Catilina, duci iussu consulis iam pridem oportebat, in te conferri pestem, quam tu in nos machinaris. An vero vir amplissumus, P. Scipio, pontifex maximus, Ti. Gracchum mediocriter labefactantem statum rei publicae privatus interfecit.

Catilinam orbem terrae caede atque incendiis vastare cupientem nos consules perferemus? Namilla nimis antiqua praetereo, quod C. Servilius Ahala Sp. Maelium novis rebus studentem manu sua occidit.

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Nos autem fortes viri satis facere rei publicae videmur, si istius furorem ac tela vitemus. Ad mortem te, Catilina, duci iussu consulis iam pridem oportebat, in te conferri pestem, quam tu in nos machinaris. An vero vir amplissumus, P. Scipio, pontifex maximus, Ti. Gracchum mediocriter labefactantem statum rei publicae privatus interfecit.

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Nos autem fortes viri satis facere rei publicae videmur, si istius furorem ac tela vitemus. Ad mortem te, Catilina, duci iussu consulis iam pridem oportebat, in te conferri pestem, quam tu in nos machinaris. An vero vir amplissumus, P. Scipio, pontifex maximus, Ti. Gracchum mediocriter labefactantem statum rei publicae privatus interfecit.

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Catilinam orbem terrae caede atque incendiis vastare cupientem nos consules perferemus? Namilla nimis antiqua praetereo, quod C. Servilius Ahala Sp. Maelium novis rebus studentem manu sua occidit.

Catilinam orbem terrae caede atque incendiis vastare cupientem nos consules perferemus? Namilla nimis antiqua praetereo, quod C. Servilius Ahala Sp. Maelium novis rebus studentem manu sua occidit.

stylebook/docs/blocks.xml0000664000175000017500000000633610524601076015401 0ustar marcusmarcus

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

This is a <note>. Nos autem fortes viri satis facere rei publicae videmur, si istius furorem ac tela vitemus. Ad mortem te, Catilina, duci iussu consulis iam pridem oportebat, in te conferri pestem, quam tu in nos machinaris. An vero vir amplissumus, P. Scipio, pontifex maximus, Ti. Gracchum mediocriter labefactantem statum rei publicae privatus interfecit.

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

  • Element number one of an unordered list.
  • Element number two of an unordered list.
  • Element number three of an unordered list.
  • Element number four of an unordered list.
  1. Element number one of an ordered list.
  2. Element number two of an ordered list.
  3. Element number three of an ordered list.
  4. Element number four of an ordered list.
public class Source { private int errors=0; public static void main(String argv[]) { if (argv.length!=1) { System.out.println("Command Line Error"); } } }]]>

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

header 1 / 2 header 3 header 4
header a data a1 data a2 data a3 / a4
header b / c data b1 data b2 data b4 / c4
data c1 data c2 / c3 / d2 / d3
header d data d1 data d4

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

stylebook/docs/entities.ent0000664000175000017500000000010310524601076015720 0ustar marcusmarcus stylebook/docs/links.xml0000664000175000017500000000507610524601076015244 0ustar marcusmarcus

This is a regular paragraph. Senatus haec intellegit. consul videt; hic tamen vivit. Vivit? immo vero etiam in senatum venit, fit publici consilii particeps, notat et designat oculis ad caedem unum quemque nostrum.

Clicking here you will be transported to the Readme file. This has been achieved with <link idref="readme">here</link>.
Note that the idref="..." MUST refer to an id="..." specified in the book file.

Clicking here you will be transported to the end of this file. This has been achieved with <link anchor="bottom">here</link> and inserting <anchor name="bottom"/> at the end of this file.

Clicking here you will be able to send me E-Mail. This can be done inserting <jump href="mailto:pier@apache.org">here</jump>. The jump tag is used whenever you cannot use link, since the target is outside stylebook domain.

Clicking here you will be transported to the end of the Sections file. This has been achieved with <link idref="sections" anchor="bottom">here</link> and inserting <anchor name="bottom"/> at the end of the target file (sections.xml).

A squirrel Last, but not least, inserting here <img src="test.jpg"/> we see an image appear in the target html. I know I sound stupid but I don't know what to write and I need to keep this long...

The same squirrel Inserting here a different image, but this time surrounded with a <jump href="mailto:pier@apache.org"/> element, clicking on the image you will be able to send me mail.

stylebook/docs/book.xml0000664000175000017500000000212710524601076015050 0ustar marcusmarcus stylebook/docs/changes.xml0000664000175000017500000000141010524601076015520 0ustar marcusmarcus First Feature Added Second Feature Added First bug fix Second bug fix First Feature Added (Testing the em tag) Second Feature Added (Testing the ref tag) First bug fix (Testing the em tag) Second bug fix (Testing the ref tag) stylebook/LICENSE.txt0000664000175000017500000000521010524601076014263 0ustar marcusmarcus/* * The Apache Software License, Version 1.1 * * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * . */ stylebook/build.bat0000775000175000017500000000141110524601076014231 0ustar marcusmarcus@echo off echo Xerces-Java Build System echo ------------------------ if "%JAVA_HOME%" == "" goto error set TOOLS_DIR=../xml-xerces/java/tools set LOCALCLASSPATH=%JAVA_HOME%\lib\tools.jar;%TOOLS_DIR%\ant.jar;%TOOLS_DIR%\xerces.jar;%TOOLS_DIR%\xalan.jar;%TOOLS_DIR%\stylebook-1.0-b2.jar;%TOOLS_DIR%\style-apachexml.jar; set ANT_HOME=%TOOLS_DIR% echo Building with classpath %LOCALCLASSPATH% echo Starting Ant... %JAVA_HOME%\bin\java.exe -Dant.home="%ANT_HOME%" -classpath "%LOCALCLASSPATH%" org.apache.tools.ant.Main %1 %2 %3 %4 %5 goto end :error echo "ERROR: JAVA_HOME not found in your environment." echo "Please, set the JAVA_HOME variable in your environment to match the" echo "location of the Java Virtual Machine you want to use." :end set LOCALCLASSPATH= @echo on stylebook/build.xml0000664000175000017500000000721610524612211014262 0ustar marcusmarcus stylebook/styles/0000775000175000017500000000000010524615557013776 5ustar marcusmarcusstylebook/styles/christmas/0000775000175000017500000000000010524615560015765 5ustar marcusmarcusstylebook/styles/christmas/dtd/0000775000175000017500000000000010524615560016540 5ustar marcusmarcusstylebook/styles/christmas/dtd/characters.ent0000664000175000017500000010034610524601076021370 0ustar marcusmarcus stylebook/styles/christmas/dtd/links1.ent0000664000175000017500000000144010524601076020445 0ustar marcusmarcus stylebook/styles/christmas/dtd/faqs.dtd0000664000175000017500000000064410524601076020170 0ustar marcusmarcus %blocksEntity; stylebook/styles/christmas/dtd/document.dtd0000664000175000017500000000100110524601076021040 0ustar marcusmarcus %blocksEntity; stylebook/styles/christmas/dtd/blocks1.ent0000664000175000017500000000172410524601076020607 0ustar marcusmarcus %markupEntity; stylebook/styles/christmas/dtd/markup.ent0000664000175000017500000000117410524601076020547 0ustar marcusmarcus %externalEntity; %charEntity; %linksEntity; stylebook/styles/christmas/dtd/document1.dtd0000664000175000017500000000203010524601076021124 0ustar marcusmarcus %blocksEntity; stylebook/styles/christmas/dtd/blocks.ent0000664000175000017500000000146110524601076020524 0ustar marcusmarcus %markupEntity; stylebook/styles/christmas/dtd/markup1.ent0000664000175000017500000000117410524601076020630 0ustar marcusmarcus %externalEntity; %charEntity; %linksEntity; stylebook/styles/christmas/dtd/links.ent0000664000175000017500000000100310524601076020357 0ustar marcusmarcus stylebook/styles/christmas/dtd/book.dtd0000664000175000017500000000251510524601076020167 0ustar marcusmarcus %externalEntity; stylebook/styles/christmas/dtd/changes.dtd0000664000175000017500000000115710524601076020646 0ustar marcusmarcus %markupEntity; stylebook/styles/christmas/stylesheets/0000775000175000017500000000000010524615560020341 5ustar marcusmarcusstylebook/styles/christmas/stylesheets/any2project.xsl0000664000175000017500000000064410524601076023332 0ustar marcusmarcus stylebook/styles/christmas/stylesheets/group2document.xsl0000664000175000017500000000132010524601076024037 0ustar marcusmarcus

Read the document or jump directly to:

  • stylebook/styles/christmas/stylesheets/book2group.xsl0000664000175000017500000000160510524601076023161 0ustar marcusmarcus stylebook/styles/christmas/stylesheets/changes2document.xsl0000664000175000017500000000161710524601076024324 0ustar marcusmarcus
  • stylebook/styles/christmas/stylesheets/document2html1.xsl0000664000175000017500000004236010524601076023741 0ustar marcusmarcus