You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/06/23 03:29:34 UTC

cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/validate validateRNG.jelly validateDTD.jelly address.rng address.dtd

jstrachan    2002/06/22 18:29:34

  Modified:    jelly    build.xml project.xml
               jelly/xdocs todo.xml
               jelly/src/java/org/apache/commons/jelly jelly.properties
  Added:       jelly/src/java/org/apache/commons/jelly/tags/validate
                        ValidateTagLibrary.java VerifierTag.java
                        package.html ValidateTag.java
               jelly/src/test/org/apache/commons/jelly/validate
                        validateRNG.jelly validateDTD.jelly address.rng
                        address.dtd
  Log:
  Added the first cut of the validate tag library.
  This tag library is used to perform XML validation using a variety of schema languages such as DTDs, XML Schema, RelaxNG, Relax or TREX.
  The tag library uses the JARV API which abstracts away the details of different validation libraries and schemas and uses the MSV library from Sun as the default runtime implementation.
  
  The RelaxNG demo works fine though DTDs are not currently working yet.
  More work is required to support neat filtering (indeed we need to be able to construct Jelly-SAX-Filters using XMLFilter from SAX).
  
  Revision  Changes    Path
  1.55      +11 -0     jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- build.xml	22 Jun 2002 23:55:42 -0000	1.54
  +++ build.xml	23 Jun 2002 01:29:34 -0000	1.55
  @@ -429,6 +429,17 @@
       </java>
      </target>   
   	
  +	<!-- Schema validation demos using JARV and MSV -->	
  +   <target name="demo.validate.dtd" depends="compile" 
  +      description="Runs demo validation which uses DTD">      
  +	<jelly file="src/test/org/apache/commons/jelly/validate/validateDTD.jelly"/>	
  +   </target>
  +
  +   <target name="demo.validate.rng" depends="compile" 
  +      description="Runs demo validation which uses RelaxNG">      
  +	<jelly file="src/test/org/apache/commons/jelly/validate/validateRNG.jelly"/>	
  +   </target>
  +
   	
   	<!-- 
   	  || JMS examples 
  
  
  
  1.24      +35 -2     jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- project.xml	22 Jun 2002 16:55:51 -0000	1.23
  +++ project.xml	23 Jun 2002 01:29:34 -0000	1.24
  @@ -187,10 +187,43 @@
       <dependency>
         <name>commons-messenger</name>
         <type>required</type>
  -      <version>1.0-dev</version>
  -      <jar>commons-messenger-1.0-dev.jar</jar>
  +      <version>1.0-dev-2</version>
  +      <jar>commons-messenger-1.0-dev-2.jar</jar>
       </dependency>
       
  +
  +	<!-- validate taglib -->
  +    <dependency>
  +      <name>isorelax</name>
  +      <type>required</type>
  +      <version>20020414</version>
  +      <jar>isorelax-20020414.jar</jar>
  +    </dependency>
  +
  +	<!-- runtime dependency for validate taglib -->
  +    <dependency>
  +      <name>msv</name>
  +      <type>required</type>
  +      <version>20020414</version>
  +      <jar>msv-20020414.jar</jar>
  +    </dependency>
  +
  +    <dependency>
  +      <name>xsdlib</name>
  +      <type>required</type>
  +      <version>20020414</version>
  +      <jar>xsdlib-20020414.jar</jar>
  +    </dependency>
  +
  +    <dependency>
  +      <name>relaxngDatatype</name>
  +      <type>required</type>
  +      <version>20020414</version>
  +      <jar>relaxngDatatype-20020414.jar</jar>
  +    </dependency>
  +
  +	
  +	
   	<!-- runtime dependencies for test programs -->
   	
       <dependency>
  
  
  
  1.16      +5 -1      jakarta-commons-sandbox/jelly/xdocs/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/xdocs/todo.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- todo.xml	22 Jun 2002 15:18:51 -0000	1.15
  +++ todo.xml	23 Jun 2002 01:29:34 -0000	1.16
  @@ -17,6 +17,11 @@
       <section name="Core tasks"> 
         <ul>
           <li>write a Cocoon JellyGenerator so that Jelly scripts can be used easily inside Cocoon</li>
  +		<li>consider implementing a Jelly Doclet so that Jelly can be used to code generate
  +			stuff from javadoc tags in a similar way to XDoclet but making use of the JSTL tags and
  +			the Velocity like expression language (Jexl) which will avoid the need to use huge numbers 
  +			of tags.				
  +		</li>
   		<li>Rename the DynaTag interface to be DynamicAttributes along with JSP1.3, 
   			also add a namespace URI parameter
   		</li>
  @@ -76,7 +81,6 @@
   		</li>
           <li>Develop a http tag library, probably based on commons-httpclient, that can be used for scripting web services</li>
           <li>A Betwixt tag library to make it easy to serialize beans to and from XML from within Jelly scripts.</li>
  -        <li>An XML validating tag library using MSV to validate XML against DTDs, RelaxNG, XML Schema etc</li>
           <li>Implement a Schematron tag library for validing XML using a path based approach, rather than schema based.</li>
           <li>
           	Provide support for running a piece of Jelly script remotely. This would be particularly useful for distributed
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/validate/ValidateTagLibrary.java
  
  Index: ValidateTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v 1.6 2002/05/17 18:04:00 jstrachan Exp $
   * $Revision: 1.6 $
   * $Date: 2002/05/17 18:04:00 $
   *
   * ====================================================================
   *
   * 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.6 2002/05/17 18:04:00 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.validate;
  
  import org.apache.commons.jelly.TagLibrary;
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.6 $
    */
  public class ValidateTagLibrary extends TagLibrary {
  
      public ValidateTagLibrary() {
          registerTag("validate", ValidateTag.class);
          registerTag("verifier", VerifierTag.class);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/validate/VerifierTag.java
  
  Index: VerifierTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/05/21 07:58:55 $
   *
   * ====================================================================
   *
   * 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: BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.validate;
  
  import java.io.ByteArrayInputStream;
  import java.io.InputStream;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.iso_relax.verifier.Schema;
  import org.iso_relax.verifier.Verifier;
  import org.iso_relax.verifier.VerifierFactory;
  
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.helpers.AttributesImpl;
  
  /** 
   * This tag creates a new Verifier of a schema as a variable
   * so that it can be used by a &lt;validate&gt; tag.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class VerifierTag extends TagSupport {
  
      /** the variable name to export the Verifier as */
      private String var;
      
      /** The URI to load the schema from */
      private String uri;
      
      /** The system ID to use when parsing the schema */
      private String systemId;
  
      /** The factory used to create new schema verifier objects */
      private VerifierFactory factory;
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(final XMLOutput output) throws Exception {    
          if ( var == null ) {
              throw new MissingAttributeException("var");
          }
  
          if ( factory == null ) {
              factory = new com.sun.msv.verifier.jarv.TheFactoryImpl();
          }
          InputStream in = null;
          if ( uri != null ) {
              in = context.getResourceAsStream( uri );
              if ( in == null ) {
                  throw new JellyException( "Could not find resource for uri: " + uri );
              }
          }
          else {
              String text = getBodyText();
              byte[] data = text.getBytes();
              in = new ByteArrayInputStream( text.getBytes() );
          }
  
          Schema schema = null;
          if (systemId != null) {
              schema = factory.compileSchema(in, systemId);
          }
          else {
              schema = factory.compileSchema(in);
          }
          if ( schema == null ) {
              throw new JellyException( "Could not create a valid schema" );
          }
          Verifier verifier = schema.newVerifier();
          context.setVariable(var, verifier);
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
  
      /** 
       * Sets the name of the variable that will be set to the new Verifier
       * 
       * @jelly:required
       */
      public void setVar(String var) {
          this.var = var;
      }
  
      /**
       * Sets the URI of the schema file to parse. If no URI is specified then the
       * body of this tag is used as the source of the schema
       * 
       * @jelly:optional
       */    
      public void setUri(String uri) {
          this.uri = uri;
      }
  
      /**
       * Sets the system ID used when parsing the schema
       * 
       * @jelly:optional
       */    
      public void setSystemId(String systemId) {
          this.systemId = systemId;
      }
  
      /** 
       * Sets the factory used to create new schema verifier objects.
       * If none is provided then the default MSV factory is used.
       * 
       * @jelly:optional
       */
      public void setFactory(VerifierFactory factory) {
          this.factory = factory;
      }
          
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/validate/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>A tag library for validating XML using various schema languages like DTD, XML Schema, 
    Relax NG as well as Relax and TREX. This tag library uses the 
    <a href="http://iso-relax.sourceforge.net/JARV/">JARV</a> API to perform the validation.
    By default we use the 
    <a href="http://wwws.sun.com/software/xml/developers/multischema/">MSV</a> 
    library by Kohsuke Kawaguchi as the implementation of JARV.
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/validate/ValidateTag.java
  
  Index: ValidateTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/taglibs/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/05/21 07:58:55 $
   *
   * ====================================================================
   *
   * 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: BeanShellExpressionFactory.java,v 1.1 2002/05/21 07:58:55 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.validate;
  
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.iso_relax.verifier.Verifier;
  import org.iso_relax.verifier.VerifierFilter;
  import org.iso_relax.verifier.VerifierHandler;
  
  import org.xml.sax.ContentHandler;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.helpers.AttributesImpl;
  
  /** 
   * This tag validates its body using a schema Verifier which can
   * validate against DTDs, XML Schema, RelaxNG, Relax or TREX.
   * Any JARV compliant Verifier could be used.
   * The error messages are output as XML events so that they can be styled by the parent tag.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class ValidateTag extends TagSupport {
  
      /** The verifier that this tag will use */
      private Verifier verifier;
  
      /** The SAX ErrorHandler */
      private ErrorHandler errorHandler;
      
      /** The boolean flag for whether the XML is valid */
      private String var;
         
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(final XMLOutput output) throws Exception {    
          if ( verifier == null ) {
              throw new MissingAttributeException("verifier");
          }
          boolean valid = false;
          
          // evaluate the body using the current Verifier 
          if ( errorHandler != null ) {
              // we are redirecting errors to another handler
              // so just filter the body
              VerifierFilter filter = verifier.getVerifierFilter();     
              
              // now install the current output in the filter chain...
              // ####
              
              ContentHandler handler = filter.getContentHandler();
              handler.startDocument();
              getBody().run(context, new XMLOutput( handler ) );
              handler.endDocument();
              valid = filter.isValid();            
          }
          else {
  	        // outputting the errors to the current output
  	        verifier.setErrorHandler(
  	            new ErrorHandler() {
  	                public void error(SAXParseException exception) throws SAXException {
  	                    outputException(output, "error", exception);
  	                }
  	                
  	                public void fatalError(SAXParseException exception) throws SAXException {
  	                    outputException(output, "fatalError", exception);
  	                }
  	                
  	                public void warning(SAXParseException exception) throws SAXException {
  	                    outputException(output, "warning", exception);
  	                }
  	            }
  	        );
  	
  	        VerifierHandler handler = verifier.getVerifierHandler();     
              handler.startDocument();
  	        getBody().run(context, new XMLOutput( handler ) );
              handler.endDocument();
              valid = handler.isValid();            
          }
          if (var != null ) {
              Boolean value = (valid) ? Boolean.TRUE : Boolean.FALSE;
              context.setVariable(var, value);
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
  
      /** 
       * Sets the schema Verifier that this tag will use to verify its body
       * 
       * @jelly:required
       */
      public void setVerifier(Verifier verifier) {
          this.verifier = verifier;
      }
      
      /** 
       * Sets the SAX ErrorHandler which is used to capture 
       * XML validation events. 
       * If an ErrorHandler is specified
       * then this tag will output its body and redirect all error messages
       * to the ErrorHandler.
       * If no ErrorHandler is specified then this tag will just output the
       * error messages as XML events
       * 
       * @jelly:optional
       */
      public void setErrorHandler(ErrorHandler errorHandler) {
          this.errorHandler = errorHandler;
      }
      
      /** 
       * Sets the name of the variable that will contain a boolean flag for whether or 
       * not the XML is valid. 
       * 
       * @jelly:optional
       */
      public void setVar(String var) {
          this.var = var;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------                    
      
      /**
       * Outputs the given validation exception as XML to the output
       */
      protected void outputException(XMLOutput output, String name, SAXParseException e) throws SAXException {
          AttributesImpl attributes = new AttributesImpl();
          String uri = "";
          String type = "CDATA";
          attributes.addAttribute( uri, "column", "column", type, Integer.toString( e.getColumnNumber() ) );
          attributes.addAttribute( uri, "line", "line", type, Integer.toString( e.getLineNumber() ) );
  
          String publicID = e.getPublicId();
          if ( publicID != null && publicID.length() > 0 ) {
              attributes.addAttribute( uri, "publicID", "publicID", type, publicID );
          }
          String systemID = e.getSystemId();
          if ( systemID != null && systemID.length() > 0 ) {
              attributes.addAttribute( uri, "systemID", "systemID", type, systemID );
          }
  
          output.startElement( uri, name, name, attributes );
          output.write( e.getMessage() );
          output.endElement( uri, name, name );
      }
      
  
  }
  
  
  
  1.14      +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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- jelly.properties	22 Jun 2002 16:55:51 -0000	1.13
  +++ jelly.properties	23 Jun 2002 01:29:34 -0000	1.14
  @@ -10,6 +10,7 @@
   
   # optional taglibs
   jms			= org.apache.commons.jelly.tags.jms.JMSTagLibrary
  +validate	= org.apache.commons.jelly.tags.validate.ValidateTagLibrary
   ojb			= org.apache.commons.jelly.tags.ojb.OjbTagLibrary
   beanshell   = org.apache.commons.jelly.tags.beanshell.BeanShellTagLibrary
   bsf         = org.apache.commons.jelly.tags.bsf.BSFTagLibrary
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/validate/validateRNG.jelly
  
  Index: validateRNG.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns:v="jelly:validate">
  
  Loading the verifier for Relax NG scheam
  
  <v:verifier uri="address.rng" var="addressSchema"/>
  
  Attempting to validate a valid address ...
  
  <v:validate var="flag" verifier="${addressSchema}">
    <addressBook>
      <card>
        <name>John Smith</name>
        <email>js@example.com</email>
      </card>
      <card>
        <name>Fred Bloggs</name>
        <email>fb@example.net</email>
      </card>
    </addressBook>
  </v:validate>
  
  Validation returned: ${flag}
  
  Attempting to validate a wrong address
  
  <v:validate var="flag" verifier="${addressSchema}">
    <addressBook>
      <card>
        <email>js@example.com</email>
      </card>
      <card>
        <name>Fred Bloggs</name>
      </card>
      <card>
        <wrongname>Fred Bloggs</wrongname>
      </card>
      <card>
      </card>
    </addressBook>
  </v:validate>
  
  Validation returned: ${flag}
  	
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/validate/validateDTD.jelly
  
  Index: validateDTD.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core" xmlns:v="jelly:validate">
  
  Loading the verifier for a DTD
  
  <v:verifier uri="address.dtd" var="addressSchema"/>
  
  Attempting to validate a valid address ...
  
  <v:validate var="flag" verifier="${addressSchema}">
    <addressBook>
      <card>
        <name>John Smith</name>
        <email>js@example.com</email>
      </card>
      <card>
        <name>Fred Bloggs</name>
        <email>fb@example.net</email>
      </card>
    </addressBook>
  </v:validate>
  
  Validation returned: ${flag}
  
  Attempting to validate a wrong address
  
  <v:validate var="flag" verifier="${addressSchema}">
    <addressBook>
      <card>
        <email>js@example.com</email>
      </card>
      <card>
        <name>Fred Bloggs</name>
      </card>
      <card>
        <wrongname>Fred Bloggs</wrongname>
      </card>
      <card>
      </card>
    </addressBook>
  </v:validate>
  
  Validation returned: ${flag}
  	
  </j:jelly>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/validate/address.rng
  
  Index: address.rng
  ===================================================================
  <element name="addressBook" xmlns="http://relaxng.org/ns/structure/0.9">

    <zeroOrMore>

      <element name="card">

        <element name="name">

          <text/>

        </element>

        <element name="email">

          <text/>

        </element>

      </element>

    </zeroOrMore>

  </element>

  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/validate/address.dtd
  
  Index: address.dtd
  ===================================================================
  <!ELEMENT addressBook (card*)>

  <!ELEMENT card (name, email)>

  <!ELEMENT name (#PCDATA)>

  <!ELEMENT email (#PCDATA)>
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>