@Override
 public void handleNode(XNode nodeToHandler, List<SqlNode> targetContents) {
   List<SqlNode> contents = parseDynamicTags(nodeToHandler);
   MixedSqlNode mixedSqlNode = new MixedSqlNode(contents);
   String prefix = nodeToHandler.getStringAttribute("prefix");
   String prefixOverrides = nodeToHandler.getStringAttribute("prefixOverrides");
   String suffix = nodeToHandler.getStringAttribute("suffix");
   String suffixOverrides = nodeToHandler.getStringAttribute("suffixOverrides");
   TrimSqlNode trimSqlNode =
       new TrimSqlNode(
           configuration, mixedSqlNode, prefix, prefixOverrides, suffix, suffixOverrides);
   targetContents.add(trimSqlNode);
 }
 private void handleWhenOtherwiseNodes(
     XNode chooseSqlNode, List<SqlNode> ifSqlNodes, List<SqlNode> defaultSqlNodes) {
   List<XNode> children = chooseSqlNode.getChildren();
   for (XNode child : children) {
     String nodeName = child.getNode().getNodeName();
     NodeHandler handler = nodeHandlers.get(nodeName);
     if (handler instanceof IfHandler) {
       handler.handleNode(child, ifSqlNodes);
     } else if (handler instanceof OtherwiseHandler) {
       handler.handleNode(child, defaultSqlNodes);
     }
   }
 }
 @Override
 public void handleNode(XNode nodeToHandler, List<SqlNode> targetContents) {
   List<SqlNode> contents = parseDynamicTags(nodeToHandler);
   MixedSqlNode mixedSqlNode = new MixedSqlNode(contents);
   String test = nodeToHandler.getStringAttribute("test");
   IfSqlNode ifSqlNode = new IfSqlNode(mixedSqlNode, test);
   targetContents.add(ifSqlNode);
 }
 private List<SqlNode> parseDynamicTags(XNode node) {
   List<SqlNode> contents = new ArrayList<SqlNode>();
   NodeList children = node.getNode().getChildNodes(); // 直接通过w3c包获取NodeList
   int childrenLength = children.getLength();
   for (int i = 0; i < childrenLength; i++) {
     XNode child = node.newXNode(children.item(i));
     Node childNode = child.getNode();
     short nodeType = childNode.getNodeType();
     // <![CDATA[]]>中括着的纯文本,它没有子节点
     if (nodeType == Node.CDATA_SECTION_NODE || nodeType == Node.TEXT_NODE) {
       String data = child.getStringBody("");
       contents.add(new TextSqlNode(data));
     } else if (nodeType == Node.ELEMENT_NODE) {
       String nodeName = childNode.getNodeName();
       NodeHandler handler = nodeHandlers.get(nodeName);
       if (handler == null) {
         throw new BuilderException("Unknown element <" + nodeName + "> in SQL statement.");
       }
       handler.handleNode(child, contents);
     }
   }
   return contents;
 }
 @Override
 public void handleNode(XNode nodeToHandler, List<SqlNode> targetContents) {
   List<SqlNode> contents = parseDynamicTags(nodeToHandler);
   MixedSqlNode mixedSqlNode = new MixedSqlNode(contents);
   String collection = nodeToHandler.getStringAttribute("collection");
   String item = nodeToHandler.getStringAttribute("item");
   String index = nodeToHandler.getStringAttribute("index");
   String open = nodeToHandler.getStringAttribute("open");
   String close = nodeToHandler.getStringAttribute("close");
   String separator = nodeToHandler.getStringAttribute("separator");
   ForEachSqlNode forEachSqlNode =
       new ForEachSqlNode(
           configuration, mixedSqlNode, collection, index, item, open, close, separator);
   targetContents.add(forEachSqlNode);
 }