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/src/test/org/apache/commons/jelly/xml testDoctype.jelly TestXMLTags.java
Date Tue, 29 Oct 2002 09:10:15 GMT
jstrachan    2002/10/29 01:10:15

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/xml
                        XMLTagLibrary.java
               jelly/src/test/org/apache/commons/jelly/xml TestXMLTags.java
  Added:       jelly/src/java/org/apache/commons/jelly/tags/xml
                        DoctypeTag.java
               jelly/src/test/org/apache/commons/jelly/xml
                        testDoctype.jelly
  Log:
  There is now an <x:doctype> tag which outputs the DOCTYPE event to the current (SAX)
XML event stream. So you can use this inside a <j:file> tag. e.g.
  
  <j:file name="foo.xml">
    <x:doctype name="foo" publicId="whatever" systemId="foo.dtd"/>
    <foo>
    ...
    </foo>
  </j:file>   
  
  Revision  Changes    Path
  1.13      +6 -5      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java
  
  Index: XMLTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLTagLibrary.java	30 Sep 2002 08:05:45 -0000	1.12
  +++ XMLTagLibrary.java	29 Oct 2002 09:10:14 -0000	1.13
  @@ -98,6 +98,7 @@
           registerTag("attribute", AttributeTag.class);
           registerTag("copy", CopyTag.class);
           registerTag("copyOf", CopyOfTag.class);
  +        registerTag("doctype", DoctypeTag.class);
       }
   
       public Expression createExpression(
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/DoctypeTag.java
  
  Index: DoctypeTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/DoctypeTag.java,v
1.8 2002/05/20 10:09:28 jstrachan Exp $
   * $Revision: 1.8 $
   * $Date: 2002/05/20 10:09:28 $
   *
   * ====================================================================
   *
   * 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: DoctypeTag.java,v 1.8 2002/05/20 10:09:28 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.jaxen.XPath;
  
  /** 
   * A tag which outputs a DOCTYPE declaration to the current XML output pipe.
   * Note that there should only be a single DOCTYPE declaration in any XML stream and
   * it should occur before any element content.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public class DoctypeTag extends XPathTagSupport {
  
      private String name;
      private String publicId;
      private String systemId;
  
      public DoctypeTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void doTag(XMLOutput output) throws Exception {
          if (name == null) {
              throw new MissingAttributeException( "name" );
          }
          
          output.startDTD(name, publicId, systemId);
          invokeBody(output);
          output.endDTD();
      }
  
      // Properties
      //-------------------------------------------------------------------------        
       
      /**
       * Returns the name.
       * @return String
       */
      public String getName() {
          return name;
      }
  
      /**
       * Returns the publicId.
       * @return String
       */
      public String getPublicId() {
          return publicId;
      }
  
      /**
       * Returns the systemId.
       * @return String
       */
      public String getSystemId() {
          return systemId;
      }
  
      /**
       * Sets the document type name of the DOCTYPE 
       */
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * Sets the declared public identifier for DTD 
       */
      public void setPublicId(String publicId) {
          this.publicId = publicId;
      }
  
      /**
       * Sets the declared system identifier for the DTD
       */
      public void setSystemId(String systemId) {
          this.systemId = systemId;
      }
  
  }
  
  
  
  1.8       +7 -0      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/TestXMLTags.java
  
  Index: TestXMLTags.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/TestXMLTags.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestXMLTags.java	30 Sep 2002 08:05:44 -0000	1.7
  +++ TestXMLTags.java	29 Oct 2002 09:10:15 -0000	1.8
  @@ -190,6 +190,13 @@
           assertEquals("Produces the correct output", "It works!", text);
       }
   
  +    public void testDoctype() throws Exception {
  +        String text = evaluteScriptAsText(
  +            "src/test/org/apache/commons/jelly/xml/testDoctype.jelly"
  +        );
  +        assertEquals("Produces the correct output", "<!DOCTYPE foo PUBLIC \"publicID\"
\"foo.dtd\">\n<foo></foo>", text);
  +    }
  +
       public void runUnitTest(String name) throws Exception {
           Document document = parseUnitTest(name);
   
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/testDoctype.jelly
  
  Index: testDoctype.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml">
  
  <x:doctype name="foo" publicId="publicID" systemId="foo.dtd"/>
  <foo/>
  
  </j:jelly>
  
  
  
  

--
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