commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly maven.xml project.xml
Date Fri, 19 Jul 2002 22:19:32 GMT
jstrachan    2002/07/19 15:19:32

  Modified:    jelly/src/java/org/apache/commons/jelly jelly.properties
               jelly    maven.xml project.xml
  Added:       jelly/src/test/org/apache/commons/jelly/html index.html
                        example.jelly
               jelly/src/java/org/apache/commons/jelly/tags/html
                        ParseTag.java package.html HTMLTagLibrary.java
  Log:
  Added a HTML Jelly library so that regular HTML documents can be parsed and then processed
via Jelly, via XPath etc.
  
  This library uses Andy Clark's excellent  NekoHTML SAX parser
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/html/index.html
  
  Index: index.html
  ===================================================================
    <!DOCTYPE html PUBLIC "-//CollabNet//DTD XHTML 1.0 Transitional//EN"
        "http://www.collabnet.com/dtds/collabnet_transitional_10.dtd">
  
    <html>
      <head>
        <title>Jelly - Jelly : Java and XML based processing engine</title>
  
  		<meta name="author" value="James Strachan"/>
          <meta name="email" value="jstrachan@apache.org" />
        
      </head>
  
      <body class="composite" marginwidth="0" marginheight="0">
      
  		some unmatched tags here...		    	
      	<p>
      	
      	and here...
      	<p>
      	
      	<img uri="foo">
      	
      	<br>
  
  		<foo:bar name="a custom tag"/>
  		    	
      </body>
    </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/html/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:html="jelly:html">
  
    <html:parse var="doc" html="index.html"/>
  
    The title is: 
    
    <x:expr select="$doc/HTML/HEAD/TITLE"/>
  
    <j:whitespace>
    	
    The XML of the document is
    
    <x:copyOf select="$doc"/>
    
    </j:whitespace>
    
  </j:jelly>
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/html/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java,v
1.9 2002/06/26 09:24:35 jstrachan Exp $
   * $Revision: 1.9 $
   * $Date: 2002/06/26 09:24:35 $
   *
   * ====================================================================
   *
   * 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
   * 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ParseTag.java,v 1.9 2002/06/26 09:24:35 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.html;
  
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.xml.ParseTagSupport;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.cyberneko.html.parsers.SAXParser;
  
  import org.dom4j.Document;
  import org.dom4j.io.SAXReader;
  
  
  /** A tag which parses some HTML and defines a variable with the parsed Document.
    * The HTML can either be specified as its body or can be passed in via the
    * html property which can be a Reader, InputStream, URL or String URI.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.9 $
    */
  public class ParseTag extends ParseTagSupport {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog(ParseTag.class);
  
      /** The HTML to parse, either a String URI, a Reader or InputStream */
      private Object html;
  
      public ParseTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void doTag(XMLOutput output) throws Exception {
          if (getVar() == null) {
              throw new IllegalArgumentException("The var attribute cannot be null");
          }
          Document document = null;
          if (html == null) {
              document = parseBody(output);
          }
          else {
              document = parse(html);
          }
          context.setVariable(getVar(), document);
      }
  
      // Properties
      //-------------------------------------------------------------------------        
       
      /** Sets the source of the HTML which is either a String URI, Reader or InputStream
*/
      public void setHtml(Object html) {
          this.html = html;
      }
  
  
      // Implementation methods
      //-------------------------------------------------------------------------        
       
  
      /**
       * Factory method to create a new SAXReader
       */    
      protected SAXReader createSAXReader() throws Exception {
          // installs the NeckHTML parser
          return new SAXReader( new SAXParser() );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/html/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Tags for parsing HTML so that it can be processed by Jelly using Andy Clark's

    	<a href="http://www.apache.org/~andyc/neko/doc/index.html">NeckoHTML</a>
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/html/HTMLTagLibrary.java
  
  Index: HTMLTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v
1.9 2002/06/18 08:31:02 jstrachan Exp $
   * $Revision: 1.9 $
   * $Date: 2002/06/18 08:31:02 $
   *
   * ====================================================================
   *
   * 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
   * 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: XMLTagLibrary.java,v 1.9 2002/06/18 08:31:02 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.html;
  
  import org.apache.commons.jelly.TagLibrary;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.9 $
    */
  public class HTMLTagLibrary extends TagLibrary {
  
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog(HTMLTagLibrary.class);
      
      public HTMLTagLibrary() {
          registerTag("parse", ParseTag.class);
      }
  }
  
  
  
  1.17      +1 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
  
  Index: jelly.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jelly.properties	16 Jul 2002 05:43:32 -0000	1.16
  +++ jelly.properties	19 Jul 2002 22:19:32 -0000	1.17
  @@ -10,6 +10,7 @@
   util        = org.apache.commons.jelly.tags.util.UtilTagLibrary
   
   # optional taglibs
  +html		= org.apache.commons.jelly.tags.html.HTMLTagLibrary
   jms         = org.apache.commons.jelly.tags.jms.JMSTagLibrary
   validate    = org.apache.commons.jelly.tags.validate.ValidateTagLibrary
   ojb         = org.apache.commons.jelly.tags.ojb.OjbTagLibrary
  
  
  
  1.14      +13 -0     jakarta-commons-sandbox/jelly/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/maven.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- maven.xml	19 Jul 2002 22:07:34 -0000	1.13
  +++ maven.xml	19 Jul 2002 22:19:32 -0000	1.14
  @@ -186,6 +186,18 @@
   	<jelly file="src/test/org/apache/commons/jelly/testStatic.jelly"/> 
     </goal>
   
  +  <goal name="demo:html" prereqs="jelly-task" 
  +	description="Runs the example of parsing HTML with jelly">
  +	
  +<!--	
  +	<jelly file="src/test/org/apache/commons/jelly/html/example.jelly"/> 
  +-->	
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <arg value="src/test/org/apache/commons/jelly/html/example.jelly"/> 
  +    </java>
  +  </goal>
  +
     <goal name="demo:jeez" prereqs="jelly-task" 
   	description="A demo of the jeez taglib">
   	
  @@ -197,6 +209,7 @@
   	
   	<jelly file="src/test/org/apache/commons/jelly/ant/filescanner.jelly"/> 
     </goal>
  +
   
   
   
  
  
  
  1.43      +6 -0      jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- project.xml	18 Jul 2002 04:50:17 -0000	1.42
  +++ project.xml	19 Jul 2002 22:19:32 -0000	1.43
  @@ -190,6 +190,12 @@
         <version>2.2</version>
       </dependency>
   
  +	<!-- html taglib -->
  +    <dependency>
  +      <id>nekohtml</id>
  +      <version>0.6.5</version>
  +    </dependency>
  +
   	<!-- ojb taglib -->
       <dependency>
         <id>ojb</id>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message