jstrachan    2002/12/19 07:03:51

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/html
                        ParseTag.java
  Log:
  Patch to allow the HTML tag library full control over NeckoHTML's ability to convert 
elements or attributes to upper or lowercase.
  
  You can now specify if you wish case conversion to be applied when parsing HTML. 
  
  e.g. to upper case the elements but lowercase the attributes you can do...
  
      <html:parse var="doc" html="index.html" element="upper" attribute="lower"/>
  
  or to make everything lower case
  
      <html:parse var="doc" html="index.html" element="lower" attribute="lower"/>
  
  
  The default is to leave case as it was but to match element case (so that open and 
close elements have the same case).
  
  Revision  Changes    Path
  1.5       +25 -3     
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/html/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/html/ParseTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParseTag.java     18 Dec 2002 22:48:01 -0000      1.4
  +++ ParseTag.java     19 Dec 2002 15:03:51 -0000      1.5
  @@ -87,6 +87,8 @@
   
       /** The HTML to parse, either a String URI, a Reader or InputStream */
       private Object html;
  +    private String element = "match";
  +    private String attribute = "no-change"; 
   
       public ParseTag() {
       }
  @@ -114,6 +116,26 @@
           this.html = html;
       }
   
  +    /**
  +     * Sets whether attributes should be converted to a different case.
  +     * Possible values are "upper", "lower" or "no-change"
  +     * 
  +     * @param attribute The processing mode of attributes
  +     */
  +    public void setAttribute(String attribute) {
  +        this.attribute = attribute;
  +    }
  +
  +    /**
  +     * Sets whether elements should be converted to a different case
  +     * Possible values are "upper", "lower" or "match"
  +     * 
  +     * @param element The processing mode of elements
  +     */
  +    public void setElement(String element) {
  +        this.element = element;
  +    }
  +
   
       // Implementation methods
       //-------------------------------------------------------------------------     
           
  @@ -122,15 +144,15 @@
        * Factory method to create a new SAXReader
        */    
       protected SAXReader createSAXReader() throws Exception {
  -        // installs the NekoHTML parser
  +        // installs the NeckHTML parser
           SAXParser parser = new SAXParser();
           parser.setProperty(
               "http://cyberneko.org/html/properties/names/elems";,
  -            "match"
  +            element
           );
           parser.setProperty(
               "http://cyberneko.org/html/properties/names/attrs";,
  -            "match"
  +            attribute
           );
           return new SAXReader( parser );
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to