cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation JXPathTemplate.java JexlTemplate.java
Date Tue, 15 Apr 2003 23:29:40 GMT
coliver     2003/04/15 16:29:40

  Modified:    src/scratchpad/src/org/apache/cocoon/generation
                        JXPathTemplate.java JexlTemplate.java
  Log:
  Fixed character data handling
  
  Revision  Changes    Path
  1.10      +41 -16    cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXPathTemplate.java
  
  Index: JXPathTemplate.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JXPathTemplate.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JXPathTemplate.java	15 Apr 2003 21:12:44 -0000	1.9
  +++ JXPathTemplate.java	15 Apr 2003 23:29:40 -0000	1.10
  @@ -821,15 +821,28 @@
           Event lastEvent;
           Stack stack = new Stack();
           Locator locator;
  +        Locator charLocation;
  +        StringBuffer charBuf;
   
           StartDocument getStartEvent() {
               return startEvent;
           }
           
  -        private void addEvent(Event ev) {
  +        private void addEvent(Event ev) throws SAXException {
               if (ev == null) {
                   throw new NullPointerException("null event");
               }
  +            if (charBuf != null) {
  +                char[] chars = new char[charBuf.length()];
  +                charBuf.getChars(0, charBuf.length(), chars, 0);
  +                Characters charEvent = new Characters(charLocation,
  +                                                      chars, 0, chars.length);
  +                                                      
  +                lastEvent.next = charEvent;
  +                lastEvent = charEvent;
  +                charLocation = null;
  +                charBuf = null;
  +            }
               if (lastEvent == null) {
                   lastEvent = startEvent = new StartDocument(locator);
               }
  @@ -839,12 +852,14 @@
   
           public void characters(char[] ch, int start, int length) 
               throws SAXException {
  -            Characters chars = new Characters(locator,
  -                                              ch, start, length);
  -            addEvent(chars);
  +            if (charBuf == null) {
  +                charBuf = new StringBuffer();
  +                charLocation = new LocatorImpl(locator);
  +            }
  +            charBuf.append(ch, start, length);
           }
   
  -        public void endDocument() {
  +        public void endDocument() throws SAXException {
               StartDocument startDoc = (StartDocument)stack.pop();
               EndDocument endDoc = new EndDocument(locator);
               startDoc.endDocument = endDoc;
  @@ -919,7 +934,7 @@
               addEvent(newEvent);
           }
           
  -        public void endPrefixMapping(String prefix) {
  +        public void endPrefixMapping(String prefix) throws SAXException {
               EndPrefixMapping endPrefixMapping = 
                   new EndPrefixMapping(locator, prefix);
               addEvent(endPrefixMapping);
  @@ -931,7 +946,8 @@
               addEvent(ev);
           }
   
  -        public void processingInstruction(String target, String data) {
  +        public void processingInstruction(String target, String data) 
  +            throws SAXException {
               Event pi = new ProcessingInstruction(locator, target, data);
               addEvent(pi);
           }
  @@ -940,12 +956,14 @@
               this.locator = locator;
           }
   
  -        public void skippedEntity(String name) {
  +        public void skippedEntity(String name) 
  +            throws SAXException {
               addEvent(new SkippedEntity(locator, name));
           }
   
   
  -        public void startDocument() {
  +        public void startDocument() 
  +            throws SAXException {
               startEvent = new StartDocument(locator);
               lastEvent = startEvent;
               stack.push(lastEvent);
  @@ -1103,7 +1121,8 @@
               addEvent(newEvent);
           }
           
  -        public void startPrefixMapping(String prefix, String uri) {
  +        public void startPrefixMapping(String prefix, String uri) 
  +            throws SAXException {
               addEvent(new StartPrefixMapping(locator, prefix, uri));
           }
   
  @@ -1112,27 +1131,33 @@
               addEvent(new Comment(locator, ch, start, length));
           }
   
  -        public void endCDATA() {
  +        public void endCDATA() 
  +            throws SAXException {
               addEvent(new EndCDATA(locator));
           }
   
  -        public void endDTD() {
  +        public void endDTD() 
  +            throws SAXException {
               addEvent(new EndDTD(locator));
           }
   
  -        public void endEntity(String name) {
  +        public void endEntity(String name) 
  +            throws SAXException {
               addEvent(new EndEntity(locator, name));
           }
   
  -        public void startCDATA() {
  +        public void startCDATA() 
  +            throws SAXException {
               addEvent(new StartCDATA(locator));
           }
   
  -        public void startDTD(String name, String publicId, String systemId) {
  +        public void startDTD(String name, String publicId, String systemId) 
  +            throws SAXException {
               addEvent(new StartDTD(locator, name, publicId, systemId));
           }
           
  -        public void startEntity(String name) {
  +        public void startEntity(String name) 
  +            throws SAXException {
               addEvent(new StartEntity(locator, name));
           }
       }
  
  
  
  1.3       +34 -17    cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JexlTemplate.java
  
  Index: JexlTemplate.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/scratchpad/src/org/apache/cocoon/generation/JexlTemplate.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JexlTemplate.java	15 Apr 2003 20:31:19 -0000	1.2
  +++ JexlTemplate.java	15 Apr 2003 23:29:40 -0000	1.3
  @@ -733,11 +733,10 @@
   
       class Characters extends TextEvent {
           Characters(Locator location, 
  -                  char[] chars, int start, int length) 
  +                   char[] chars, int start, int length) 
               throws SAXException {
               super(location, chars, start, length);
           }
  -
       }
   
       class StartDocument extends Event {
  @@ -1199,15 +1198,28 @@
           Event lastEvent;
           Stack stack = new Stack();
           Locator locator;
  +        Locator charLocation;
  +        StringBuffer charBuf;
   
           StartDocument getStartEvent() {
               return startEvent;
           }
           
  -        private void addEvent(Event ev) {
  +        private void addEvent(Event ev) throws SAXException {
               if (ev == null) {
                   throw new NullPointerException("null event");
               }
  +            if (charBuf != null) {
  +                char[] chars = new char[charBuf.length()];
  +                charBuf.getChars(0, charBuf.length(), chars, 0);
  +                Characters charEvent = new Characters(charLocation,
  +                                                      chars, 0, chars.length);
  +                                                      
  +                lastEvent.next = charEvent;
  +                lastEvent = charEvent;
  +                charLocation = null;
  +                charBuf = null;
  +            }
               if (lastEvent == null) {
                   lastEvent = startEvent = new StartDocument(locator);
               }
  @@ -1217,12 +1229,14 @@
   
           public void characters(char[] ch, int start, int length) 
               throws SAXException {
  -            Characters chars = new Characters(locator,
  -                                              ch, start, length);
  -            addEvent(chars);
  +            if (charBuf == null) {
  +                charBuf = new StringBuffer();
  +                charLocation = new LocatorImpl(locator);
  +            }
  +            charBuf.append(ch, start, length);
           }
   
  -        public void endDocument() {
  +        public void endDocument() throws SAXException {
               StartDocument startDoc = (StartDocument)stack.pop();
               EndDocument endDoc = new EndDocument(locator);
               startDoc.endDocument = endDoc;
  @@ -1296,7 +1310,7 @@
               addEvent(newEvent);
           }
           
  -        public void endPrefixMapping(String prefix) {
  +        public void endPrefixMapping(String prefix) throws SAXException {
               EndPrefixMapping endPrefixMapping = 
                   new EndPrefixMapping(locator, prefix);
               addEvent(endPrefixMapping);
  @@ -1308,7 +1322,8 @@
               addEvent(ev);
           }
   
  -        public void processingInstruction(String target, String data) {
  +        public void processingInstruction(String target, String data) 
  +            throws SAXException {
               Event pi = new ProcessingInstruction(locator, target, data);
               addEvent(pi);
           }
  @@ -1317,7 +1332,7 @@
               this.locator = locator;
           }
   
  -        public void skippedEntity(String name) {
  +        public void skippedEntity(String name) throws SAXException {
               addEvent(new SkippedEntity(locator, name));
           }
   
  @@ -1496,7 +1511,8 @@
               addEvent(newEvent);
           }
           
  -        public void startPrefixMapping(String prefix, String uri) {
  +        public void startPrefixMapping(String prefix, String uri) 
  +            throws SAXException {
               addEvent(new StartPrefixMapping(locator, prefix, uri));
           }
   
  @@ -1505,27 +1521,28 @@
               addEvent(new Comment(locator, ch, start, length));
           }
   
  -        public void endCDATA() {
  +        public void endCDATA() throws SAXException {
               addEvent(new EndCDATA(locator));
           }
   
  -        public void endDTD() {
  +        public void endDTD() throws SAXException {
               addEvent(new EndDTD(locator));
           }
   
  -        public void endEntity(String name) {
  +        public void endEntity(String name) throws SAXException {
               addEvent(new EndEntity(locator, name));
           }
   
  -        public void startCDATA() {
  +        public void startCDATA() throws SAXException {
               addEvent(new StartCDATA(locator));
           }
   
  -        public void startDTD(String name, String publicId, String systemId) {
  +        public void startDTD(String name, String publicId, String systemId) 
  +            throws SAXException {
               addEvent(new StartDTD(locator, name, publicId, systemId));
           }
           
  -        public void startEntity(String name) {
  +        public void startEntity(String name) throws SAXException {
               addEvent(new StartEntity(locator, name));
           }
       }
  
  
  

Mime
View raw message