You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/01/17 13:56:08 UTC

cvs commit: xml-fop/test/java/org/apache/fop/layoutengine LayoutEngineTester.java

jeremias    2005/01/17 04:56:08

  Modified:    test/java/org/apache/fop/layoutengine
                        LayoutEngineTester.java
  Log:
  Using only DOM elements to create checks. This should help avoid errors due to comment nodes being passed to the factory method.
  
  Revision  Changes    Path
  1.3       +10 -7     xml-fop/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
  
  Index: LayoutEngineTester.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LayoutEngineTester.java	6 Jan 2005 08:39:19 -0000	1.2
  +++ LayoutEngineTester.java	17 Jan 2005 12:56:07 -0000	1.3
  @@ -44,6 +44,7 @@
   import org.apache.fop.fo.Constants;
   import org.apache.fop.render.xml.XMLRenderer;
   import org.w3c.dom.Document;
  +import org.w3c.dom.Element;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   
  @@ -130,17 +131,17 @@
       }
       
       /**
  -     * Factory method to create checks from DOM nodes.
  -     * @param node DOM node to create the check from
  +     * Factory method to create checks from DOM elements.
  +     * @param el DOM element to create the check from
        * @return The newly create check
        */
  -    protected LayoutEngineCheck createCheck(Node node) {
  -        String name = node.getLocalName();
  +    protected LayoutEngineCheck createCheck(Element el) {
  +        String name = el.getLocalName();
           Class clazz = (Class)CHECK_CLASSES.get(name);
           if (clazz != null) {
               try {
                   Constructor c = clazz.getDeclaredConstructor(new Class[] {Node.class});
  -                LayoutEngineCheck instance = (LayoutEngineCheck)c.newInstance(new Object[] {node});
  +                LayoutEngineCheck instance = (LayoutEngineCheck)c.newInstance(new Object[] {el});
                   return instance;
               } catch (Exception e) {
                   throw new RuntimeException("Error while instantiating check '" 
  @@ -168,7 +169,9 @@
           NodeList nodes = doc.getDocumentElement().getChildNodes();
           for (int i = 0; i < nodes.getLength(); i++) {
               Node node = nodes.item(i);
  -            checks.add(createCheck(node));
  +            if (node instanceof Element) {
  +                checks.add(createCheck((Element)node));
  +            }
           }
           
           Iterator i = checks.iterator();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org