jvanzyl     02/02/21 11:02:40

  Modified:    src/java/org/apache/stratum/xo Mapper.java
  Log:
  - add the capability to absorb <![CDATA[ ... ]]> elements which prevents
    the attempted mapping of any of any html markup.
  
  Revision  Changes    Path
  1.15      +12 -4     
jakarta-turbine-stratum/src/java/org/apache/stratum/xo/Mapper.java
  
  Index: Mapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/xo/Mapper.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Mapper.java       12 Feb 2002 21:09:57 -0000      1.14
  +++ Mapper.java       21 Feb 2002 19:02:40 -0000      1.15
  @@ -63,6 +63,7 @@
   
   import org.dom4j.Document;
   import org.dom4j.Element;
  +import org.dom4j.CDATA;
   import org.dom4j.Node;
   import org.dom4j.io.SAXReader;
   
  @@ -140,7 +141,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: Mapper.java,v 1.14 2002/02/12 21:09:57 jvanzyl Exp $
  + * @version $Id: Mapper.java,v 1.15 2002/02/21 19:02:40 jvanzyl Exp $
    */
   
   // How to use the resources package to pull in the
  @@ -449,7 +450,7 @@
                       // (3):   <city>Guelph</city>                +- (A)
                       // (4):   <country>Canada</country>          |
                       // (5): </address>                        ---+
  -                    if (hasChildren(node))
  +                    if (hasChildren(node) && !containsCDATA(node))
                       {
                           debug("Node " + node.getName() + " has children");
   
  @@ -564,6 +565,13 @@
           return bean;
       }
   
  +    private boolean containsCDATA(Node node)
  +    {
  +        boolean cdata = ((Element)node).node(1) instanceof CDATA;
  +        debug(node.getName() + "contains CDATA -> " + cdata);
  +        return cdata;
  +    }
  +
       /**
        * Set an inclusion rule which controls how external
        * XML documents are processed.
  @@ -606,8 +614,7 @@
           }
           catch (Exception noAttrib)
           {
  -            debug("Using " + className + " unsuccessful: " + 
  -                StringUtils.stackTrace(noAttrib));
  +            debug("Using " + className + " unsuccessful: " + noAttrib);
               
               // We assume here that the object that we are creating is
               // in the same package as the parent object.
  @@ -624,6 +631,7 @@
               // TODO: Check class name validity
               try
               {
  +                debug("Attempting to load " + className);
                   return Class.forName(className).newInstance();
               }
               catch (Exception unknownClass)
  
  
  

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

Reply via email to