sandygao    2002/12/13 09:31:12

  Modified:    java/src/org/apache/xerces/util DOMUtil.java
  Log:
  Now it works with both DTM nodes and Xerces DOM nodes.
  This enables the possibility that we support both DTM and DOM as schema
  source at the same time.
  
  Revision  Changes    Path
  1.7       +16 -7     xml-xerces/java/src/org/apache/xerces/util/DOMUtil.java
  
  Index: DOMUtil.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/DOMUtil.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DOMUtil.java      29 Jan 2002 01:15:18 -0000      1.6
  +++ DOMUtil.java      13 Dec 2002 17:31:12 -0000      1.7
  @@ -59,7 +59,6 @@
   
   import org.apache.xerces.dom.AttrImpl;
   import org.apache.xerces.dom.DocumentImpl;
  -import org.apache.xerces.dom.NodeImpl;
   
   import org.w3c.dom.Attr;
   import org.w3c.dom.Document;
  @@ -207,7 +206,7 @@
           Node child = parent.getFirstChild();
           while (child != null) {
               if (child.getNodeType() == Node.ELEMENT_NODE &&
  -                !((NodeImpl)child).getReadOnly()) {
  +                !isHidden(child)) {
                   return (Element)child;
               }
               child = child.getNextSibling();
  @@ -242,7 +241,7 @@
           Node child = parent.getLastChild();
           while (child != null) {
               if (child.getNodeType() == Node.ELEMENT_NODE &&
  -                    ((NodeImpl)child).getReadOnly()) {
  +                !isHidden(child)) {
                   return (Element)child;
               }
               child = child.getPreviousSibling();
  @@ -277,7 +276,7 @@
           Node sibling = node.getNextSibling();
           while (sibling != null) {
               if (sibling.getNodeType() == Node.ELEMENT_NODE &&
  -                !((NodeImpl)sibling).getReadOnly()) {
  +                !isHidden(sibling)) {
                   return (Element)sibling;
               }
               sibling = sibling.getNextSibling();
  @@ -290,17 +289,27 @@
   
       // set this Node as being hidden
       public static void setHidden(Node node) {
  -        ((NodeImpl)node).setReadOnly(true, false);
  +        if (node instanceof org.apache.xerces.impl.xs.opti.NodeImpl)
  +            ((org.apache.xerces.impl.xs.opti.NodeImpl)node).setReadOnly(true, 
false);
  +        else if (node instanceof org.apache.xerces.dom.NodeImpl)
  +            ((org.apache.xerces.dom.NodeImpl)node).setReadOnly(true, false);
       } // setHidden(node):void
   
       // set this Node as being visible
       public static void setVisible(Node node) {
  -        ((NodeImpl)node).setReadOnly(false, false);
  +        if (node instanceof org.apache.xerces.impl.xs.opti.NodeImpl)
  +            ((org.apache.xerces.impl.xs.opti.NodeImpl)node).setReadOnly(false, 
false);
  +        else if (node instanceof org.apache.xerces.dom.NodeImpl)
  +            ((org.apache.xerces.dom.NodeImpl)node).setReadOnly(false, false);
       } // setVisible(node):void
   
       // is this node hidden?
       public static boolean isHidden(Node node) {
  -        return ((NodeImpl)node).getReadOnly();
  +        if (node instanceof org.apache.xerces.impl.xs.opti.NodeImpl)
  +            return ((org.apache.xerces.impl.xs.opti.NodeImpl)node).getReadOnly();
  +        else if (node instanceof org.apache.xerces.dom.NodeImpl)
  +            return ((org.apache.xerces.dom.NodeImpl)node).getReadOnly();
  +        return false;
       } // isHidden(Node):boolean
   
       /** Finds and returns the first child node with the given name. */
  
  
  

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

Reply via email to