Package org.xmldb.xupdate.lexus.commands

Examples of org.xmldb.xupdate.lexus.commands.DefaultCommand


    /**
    * Execute the XUpdate commands against a document.
    */
   public void execute(Node contextNode) throws Exception {
      CommandObject currentCommand = new DefaultCommand(contextNode);
      Enumeration commands = _query[0].elements();
      Enumeration attributes = _query[1].elements();
      Enumeration characters = _query[2].elements();
      Node origNode = contextNode;
      CommandObject.getXPath().setNamespace(nsMap.getContextNode());

      while (commands.hasMoreElements()) {
         int id = ((Integer) commands.nextElement()).intValue();

         if ( id == CommandConstants.ATTRIBUTES ) {
            currentCommand.submitAttributes((Hashtable) attributes.nextElement());
         }
         else if ( id == CommandConstants.CHARACTERS ) {
            currentCommand.submitCharacters((String) characters.nextElement());
         }
         else if ( id > 0 ) {
            if ( ! currentCommand.submitInstruction(id) ) {
               _commands.setContextNode(contextNode);
               currentCommand = _commands.commandForID(id);
               if (currentCommand == null) {
                  throw new Exception("operation can not have any XUpdate-instruction !");
               }
               currentCommand.reset();
            }
         }
         else {
            if ( ! currentCommand.executeInstruction() ) {
               try {
               contextNode = currentCommand.execute();
         }
         catch(Exception e) {
          // while not ideal, CommandObject.execute throws
          // Exception("no nodes selected !") if nothing is
          // selected for modification we trap that case
          // and ignore allowing continued processing
          // of remaining xupdate instructions that may be present
            if( ! "no nodes selected !".equals(e.getMessage())) {
             throw e;
          }
         }
         // default do-nothing command will soak up anything
         // (characters, attributes, etc.) encountered until we
         // come across the next xupdate instruction
         // (e.g. remove, append, insert, etc.)
               currentCommand = new DefaultCommand(contextNode);
            }
         }
      }

      if ( origNode instanceof CompressedNode ) {
View Full Code Here


    /**
     * Execute the XUpdate commands against a document.
     */
    public void execute(Node contextNode) throws Exception {
        CommandObject currentCommand = new DefaultCommand(contextNode);
        Enumeration commands = _query[0].elements();
        Enumeration attributes = _query[1].elements();
        Enumeration characters = _query[2].elements();
        Node origNode = contextNode;
        CommandObject.getXPath().setNamespace(nsMap.getContextNode());

        while (commands.hasMoreElements()) {
            int id = ((Integer) commands.nextElement()).intValue();

            if (id == CommandConstants.ATTRIBUTES) {
                currentCommand.submitAttributes((Hashtable) attributes.nextElement());
            } else if (id == CommandConstants.CHARACTERS) {
                currentCommand.submitCharacters((String) characters.nextElement());
            } else if (id > 0) {
                if (!currentCommand.submitInstruction(id)) {
                    _commands.setContextNode(contextNode);
                    currentCommand = _commands.commandForID(id);
                    if (currentCommand == null) {
                        throw new Exception("operation can not have any XUpdate-instruction !");
                    }
                    currentCommand.reset();
                }
            } else {
                if (!currentCommand.executeInstruction()) {
                    try {
                        contextNode = currentCommand.execute();
                    } catch (Exception e) {
                        // while not ideal, CommandObject.execute throws
                        // Exception("no nodes selected !") if nothing is
                        // selected for modification we trap that case
                        // and ignore allowing continued processing
                        // of remaining xupdate instructions that may be present
                        if (!"no nodes selected !".equals(e.getMessage())) {
                            throw e;
                        }
                    }
                    // default do-nothing command will soak up anything
                    // (characters, attributes, etc.) encountered until we
                    // come across the next xupdate instruction
                    // (e.g. remove, append, insert, etc.)
                    currentCommand = new DefaultCommand(contextNode);
                }
            }
        }

        if (origNode instanceof CompressedNode) {
View Full Code Here

    /**
     * Execute the XUpdate commands against a document.
     */
    public void execute(Node contextNode) throws Exception {
        CommandObject currentCommand = new DefaultCommand(contextNode);
        Enumeration commands = super.query[0].elements();
        Enumeration attributes = super.query[1].elements();
        Enumeration characters = super.query[2].elements();
        Node origNode = contextNode;
        CommandObject.getXPath().setNamespace(nsMap.getContextNode());

        while (commands.hasMoreElements()) {
            int id = ((Integer) commands.nextElement()).intValue();

            if (id == CommandConstants.ATTRIBUTES) {
                currentCommand.submitAttributes((Hashtable) attributes.nextElement());
            } else if (id == CommandConstants.CHARACTERS) {
                currentCommand.submitCharacters((String) characters.nextElement());
            } else if (id > 0) {
                if (!currentCommand.submitInstruction(id)) {
                    super.commandConstants.setContextNode(contextNode);
                    currentCommand = super.commandConstants.commandForID(id);
                    if (currentCommand == null) {
                        throw new Exception("Operation can not have any XUpdate-instruction!");
                    }
                    currentCommand.reset();
                }
            } else {
                if (!currentCommand.executeInstruction()) {
                    try {
                        contextNode = currentCommand.execute();
                    } catch (Exception e) {
                        // While not ideal, CommandObject.execute throws
                        // Exception("no nodes selected !") if nothing is
                        // selected for modification we trap that case
                        // and ignore allowing continued processing
                        // of remaining xupdate instructions that may be present
                        if (!"no nodes selected !".equals(e.getMessage())) {
                            throw e;
                        }
                    }
                    // Default do-nothing command will soak up anything
                    // (characters, attributes, etc.) encountered until we
                    // come across the next xupdate instruction
                    // (e.g. remove, append, insert, etc.)
                    currentCommand = new DefaultCommand(contextNode);
                }
            }
        }

        if (origNode instanceof CompressedNode) {
View Full Code Here

  /**
   *
   */
  public void execute(Node contextNode) throws Exception {
    //log.error(".execute(): Starting XUpdate ...");
    CommandObject currentCommand = new DefaultCommand(contextNode);
    Enumeration commands = query[0].elements();
    Enumeration attributes = query[1].elements();
    Enumeration characters = query[2].elements();
    while (commands.hasMoreElements()) {
      //log.error(".execute(): Commands ...");
      int id = ((Integer) commands.nextElement()).intValue();
      if (id > 0) {
        //log.error(".execute(): switch(id) ...");
        switch (id) {
          case CommandConstants.ATTRIBUTES:
            currentCommand.submitAttributes((Hashtable) attributes.nextElement());
            break;
          case CommandConstants.CHARACTERS:
            currentCommand.submitCharacters((String) characters.nextElement());
            break;
          default:
            if (!currentCommand.submitInstruction(id)) {
              commandConstants.setContextNode(contextNode);
              currentCommand = commandConstants.commandForID(id);
              if (currentCommand == null) {
                throw new Exception("operation can not have any XUpdate-instruction !");
              }
              currentCommand.reset();
            }
        }
      } else {
        //log.error(".execute(): else ...");
        if (!currentCommand.executeInstruction()) {
          contextNode = currentCommand.execute();
          currentCommand = new DefaultCommand(contextNode);
        }

      }
    }
  //log.error(".execute(): Ending XUpdate ...");
View Full Code Here

   /**
    * Execute the XUpdate commands against a document.
    */
   public void execute(Node contextNode) throws Exception {
      CommandObject currentCommand = new DefaultCommand(contextNode);
      Enumeration commands = _query[0].elements();
      Enumeration attributes = _query[1].elements();
      Enumeration characters = _query[2].elements();

      while ( commands.hasMoreElements() ) {
         int id = ((Integer)commands.nextElement()).intValue();

         if ( id == CommandConstants.ATTRIBUTES ) {
            currentCommand.submitAttributes((Hashtable)attributes.nextElement());
         }
         else if ( id == CommandConstants.CHARACTERS ) {
            currentCommand.submitCharacters((String)characters.nextElement());
         }
         else if ( id > 0 ) {
            if ( !currentCommand.submitInstruction(id) ) {
               _commands.setContextNode(contextNode);
               currentCommand = _commands.commandForID(id);
               if ( currentCommand == null ) {
                  throw new Exception("operation can not have any XUpdate-instruction !");
               }
               currentCommand.reset();
            }
         }
         else {
            if ( !currentCommand.executeInstruction() ) {
               contextNode = currentCommand.execute();
               currentCommand = new DefaultCommand(contextNode);
            }
         }
      }
   }
View Full Code Here

    /**
     * Execute the XUpdate commands against a document.
     */
    public void execute(Node contextNode) throws Exception {
        CommandObject currentCommand = new DefaultCommand(contextNode);
        Enumeration commands = super.query[0].elements();
        Enumeration attributes = super.query[1].elements();
        Enumeration characters = super.query[2].elements();
        Node origNode = contextNode;
        CommandObject.getXPath().setNamespace(nsMap.getContextNode());

        while (commands.hasMoreElements()) {
            int id = ((Integer) commands.nextElement()).intValue();

            if (id == CommandConstants.ATTRIBUTES) {
                currentCommand.submitAttributes((Hashtable) attributes.nextElement());
            } else if (id == CommandConstants.CHARACTERS) {
                currentCommand.submitCharacters((String) characters.nextElement());
            } else if (id > 0) {
                if (!currentCommand.submitInstruction(id)) {
                    super.commandConstants.setContextNode(contextNode);
                    currentCommand = super.commandConstants.commandForID(id);
                    if (currentCommand == null) {
                        throw new Exception("Operation can not have any XUpdate-instruction!");
                    }
                    currentCommand.reset();
                }
            } else {
                if (!currentCommand.executeInstruction()) {
                    try {
                        contextNode = currentCommand.execute();
                    } catch (Exception e) {
                        // While not ideal, CommandObject.execute throws
                        // Exception("no nodes selected !") if nothing is
                        // selected for modification we trap that case
                        // and ignore allowing continued processing
                        // of remaining xupdate instructions that may be present
                        if (!"no nodes selected !".equals(e.getMessage())) {
                            throw e;
                        }
                    }
                    // Default do-nothing command will soak up anything
                    // (characters, attributes, etc.) encountered until we
                    // come across the next xupdate instruction
                    // (e.g. remove, append, insert, etc.)
                    currentCommand = new DefaultCommand(contextNode);
                }
            }
        }

        if (origNode instanceof CompressedNode) {
View Full Code Here

    /**
     * Execute the XUpdate commands against a document.
     */
    public void execute(Node contextNode) throws Exception {
        CommandObject currentCommand = new DefaultCommand(contextNode);
        Enumeration commands = super.query[0].elements();
        Enumeration attributes = super.query[1].elements();
        Enumeration characters = super.query[2].elements();
        Node origNode = contextNode;
        CommandObject.getXPath().setNamespace(nsMap.getContextNode());

        while (commands.hasMoreElements()) {
            int id = ((Integer) commands.nextElement()).intValue();

            if (id == CommandConstants.ATTRIBUTES) {
                currentCommand.submitAttributes((Hashtable) attributes.nextElement());
            } else if (id == CommandConstants.CHARACTERS) {
                currentCommand.submitCharacters((String) characters.nextElement());
            } else if (id > 0) {
                if (!currentCommand.submitInstruction(id)) {
                    super.commandConstants.setContextNode(contextNode);
                    currentCommand = super.commandConstants.commandForID(id);
                    if (currentCommand == null) {
                        throw new Exception("Operation can not have any XUpdate-instruction!");
                    }
                    currentCommand.reset();
                }
            } else {
                if (!currentCommand.executeInstruction()) {
                    try {
                        contextNode = currentCommand.execute();
                    } catch (Exception e) {
                        // While not ideal, CommandObject.execute throws
                        // Exception("no nodes selected !") if nothing is
                        // selected for modification we trap that case
                        // and ignore allowing continued processing
                        // of remaining xupdate instructions that may be present
                        if (!"no nodes selected !".equals(e.getMessage())) {
                            throw e;
                        }
                    }
                    // Default do-nothing command will soak up anything
                    // (characters, attributes, etc.) encountered until we
                    // come across the next xupdate instruction
                    // (e.g. remove, append, insert, etc.)
                    currentCommand = new DefaultCommand(contextNode);
                }
            }
        }

        if (origNode instanceof CompressedNode) {
View Full Code Here

TOP

Related Classes of org.xmldb.xupdate.lexus.commands.DefaultCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.