通过传入zealot xml文件对应的命名空间和zealot节点的ID来生成和获取sqlInfo信息(无参的SQL).

@param nameSpace xml命名空间
@param zealotId xml中的zealotId
@return 返回SqlInfo对象
7574
public static SqlInfo getSqlInfo(String nameSpace, String zealotId) {
        return getSqlInfo(nameSpace, zealotId, null);
    }
1125259
public static Document parseXmlString(String _xmlStr, boolean _validating, boolean _namespaceAware) throws IOException {

        DocumentBuilderFactory dbFac = DocumentBuilderFactory.newInstance();
        dbFac.setNamespaceAware(_namespaceAware);
        dbFac.setValidating(_validating);

        try {
            return dbFac.newDocumentBuilder().parse(new ByteArrayInputStream(_xmlStr.getBytes(StandardCharsets.UTF_8)));

        } catch (IOException _ex) {
            throw _ex;
        } catch (Exception _ex) {
            throw new IOException("Failed to parse " + StringUtil.abbreviate(_xmlStr, 500), _ex);
        }

    }
1019017
protected static function _namespaceIsset($namespace, $name = null)
    {
        if (self::$_readable === false) {
            /**
             * @see Zend_Session_Exception
             */
            require_once 'Zend/Session/Exception.php';
            throw new Zend_Session_Exception(self::_THROW_NOT_READABLE_MSG);
        }

        if ($name === null) {
            return ( isset($_SESSION[$namespace]) || isset(self::$_expiringData[$namespace]) );
        } else {
            return ( isset($_SESSION[$namespace][$name]) || isset(self::$_expiringData[$namespace][$name]) );
        }
    }
723378
def xpath(node, query, namespaces={}):
    """"""
    if namespaces and 'None' not in namespaces:
        return node.xpath(query, namespaces=namespaces)
    return node.xpath(query)
1069212
private int getHighestID(String namespace) {
        Integer i = (Integer) m_highestID.get(namespace);
        if (i == null) {
            return 0;
        }
        return i.intValue();
    }
761299
private void setNameSpaceID(File storage, String nsid)
      throws InconsistentFSStateException {
    if (nsid == null || nsid.equals("")) {
      throw new InconsistentFSStateException(storage, "file "
          + STORAGE_FILE_VERSION + " is invalid.");
    }
    int newNsId = Integer.parseInt(nsid);
    if (namespaceID > 0 && namespaceID != newNsId) {
      throw new InconsistentFSStateException(storage,
          "Unexepcted namespaceID " + nsid + " . Expected " + namespaceID);
    }
    namespaceID = newNsId;
  }
660960
public void xmlns(Map<String, String> definition) {
        Assert.notNull(namespaceHandlerResolver, "You cannot define a Spring namespace without a [namespaceHandlerResolver] set");
        if (definition.isEmpty()) {
            return;
        }

        for (Map.Entry<String, String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue() == null ? null : entry.getValue();

            Assert.notNull(uri, "Namespace definition cannot supply a null URI");

            final NamespaceHandler namespaceHandler = namespaceHandlerResolver.resolve(uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(
                      new Problem("No namespace handler found for URI: " + uri,
                            new Location(readerContext.getResource())));
            }
            namespaceHandlers.put(namespace, namespaceHandler);
            namespaces.put(namespace, uri);
        }
    }
805523
public static Map<String, String> getNamespaceMapping(final Document document) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("xmlns", "http://www.w3.org/2000/xmlns/");
        map.put("xml", "http://www.w3.org/XML/1998/namespace");
//      if (childName.equals("xmlns") || childName.startsWith("xmlns:")) {
//      return "http://www.w3.org/2000/xmlns/";
//  }
//  if (childName.startsWith("xml:")) {
//      return "http://www.w3.org/XML/1998/namespace";
//  }

        Element root = document.getDocumentElement();
        if (root == null) {
            // No document, no namespaces.
            return map;
        }

        fillNSMapWithPrefixesDeclaredInElement(map, root);
        return map;
    }
451845
public TagAttribute[] getAll(String namespace)
    {
        int idx = 0;
        if (namespace == null)
        {
            idx = Arrays.binarySearch(_namespaces, "");
        }
        else
        {
            idx = Arrays.binarySearch(_namespaces, namespace);
        }
        
        if (idx >= 0)
        {
            return _nsattrs.get(idx);
        }
        
        return EMPTY;
    }
1269744
private String readNamespaceAttr(Document doc) {

    	// lazy loading is mostly pointless but it keeps things together
    	if (namespaceExpr == null) {
    		namespaceExpr = initNamespaceAttrExpression();
    	}

		String s;
		try {
			s = namespaceExpr.evaluate(doc);
		} catch (XPathExpressionException e) {
			throw new PluginException("Error evaluating namespace XPath expression: " + e, e);
		}
		// xpath returns an empty string if not found, null is cleaner for callers
		return (s == null || s.length() == 0) ? null : s;
    }
1165816
public static String getNamespace(HasMetadata entity) {
    if (entity != null) {
      return getNamespace(entity.getMetadata());
    } else {
      return null;
    }
  }
1282194
public static Document string2Doc(String inputXMLString, boolean namespaceAwareness) {
        try {
            return XmlDocumentReader.parse(inputXMLString, false);
        } catch (IOException | SAXException e) {
            log.error("Cannot parse XML string.", e);
            return null;
        }
//        try {
//            DocumentBuilder builder = getDocumentBuilder(namespaceAwareness);
//            InputSource is = new InputSource(new StringReader(inputXMLString));
//            is.setEncoding("UTF-8");
//            return builder.parse(is);
//        } catch (SAXException | ParserConfigurationException | IOException e) {
//            log.error("cannot parse following content\n\n" + inputXMLString);
//            e.printStackTrace();
//            return null;
//        }
    }
523045
protected void validateNamespace(final SqlValidatorNamespace namespace,
		RelDataType targetRowType) {
		namespace.validate(targetRowType);
		if (namespace.getNode() != null) {
			setValidatedNodeType(namespace.getNode(), namespace.getType());
		}
	}
231491
function (namespace, schemaContent, cb) {
    var self = this;

    if (multivalue.hasValue(self.parsedSchemas, namespace, schemaContent)) {
      cb(null, {});
      return;
    }

    xml2js.parseString(schemaContent, function (err, result) {
      if (err) {
        cb(err);
        return;
      }

      // Only one root element expected
      if (!result || _.size(result) !== 1) {
        cb("Invalid schema for " + namespace + ": " + util.inspect(result, false, null));
        return;
      }

      parseNamespacePrefixes(result, function (err, defaultNamespace, namespaces, xsPrefix) {
        if (err) {
          cb(err);
          return;
        }

        assert(result[xsPrefix + 'schema'], result);

        var schema = result[xsPrefix + 'schema'];

        if (schema.$ && schema.$.targetNamespace && schema.$.targetNamespace !== namespace) {
          cb("Schema does not have expected target namespace " + namespace + ": " + util.inspect(result, false, null));
          return;
        }

        var schemaParser = new XsdSchema(self, namespace, defaultNamespace, namespaces, xsPrefix);

        var importsAndIncludes = schemaParser.parseImportsAndIncludes(namespace, schema);

        var newElements = schemaParser.parseElements(schema, null);
        // TODO: Check if we are overriding anything
        _.extend(self.elements, newElements);

        var newAttributes = schemaParser.parseAttributes(schema);
        // TODO: Check if we are overriding anything
        _.extend(self.attributes, newAttributes);

        var newTypes = schemaParser.parseTypes(schema);
        // TODO: Check if we are overriding anything
        _.extend(self.types, newTypes);

        // TODO: Add support for element and attribute groups
        delete schema[xsPrefix + 'group'];
        delete schema[xsPrefix + 'attributeGroup'];

        // Previous parsing calls are destructive and should consume schema so that it is empty now
        assert(_.isEmpty(schema), schema);

        multivalue.addValue(self.parsedSchemas, namespace, schemaContent);

        cb(null, importsAndIncludes);
      });
    });
  }
891201
public Document stringToDom(String xmlSource) throws S2SException {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            return builder.parse(new InputSource(new StringReader(xmlSource)));
        }
        catch (SAXException | IOException | ParserConfigurationException ex) {
            throw new S2SException(ex.getMessage(), ex);
        }
    }
415312
public static function create($namespace = null, $name = null)
    {
        if (null === $namespace) {
            return self::createNamespacelessUuid();
        }

        return self::createNamespacedUuid($namespace, $name);
    }
577558
@SuppressWarnings("unchecked")
    private void cachingXmlZealots() {
        Map<String, String> xmlMaps = XmlContext.INSTANCE.getXmlPathMap();

        // 遍历所有的xml文档，将每个zealot节点缓存到ConcurrentHashMap内存缓存中
        for (Map.Entry<String, String> entry: xmlMaps.entrySet()) {
            String nameSpace = entry.getKey();
            String filePath = entry.getValue();

            // 根据文件路径获取对应的dom4j Document对象.
            Document doc = XmlNodeHelper.getDocument(filePath);
            if (doc == null) {
                throw new ConfigNotFoundException("注意：未找到配置文件中xml对应的dom4j Document文档,nameSpace为:" + nameSpace);
            }

            // 获取该文档下所有的zealot元素,
            List<Node> zealotNodes = doc.selectNodes(ZealotConst.ZEALOT_TAG);
            for (Node zealotNode: zealotNodes) {
                String zealotId = XmlNodeHelper.getNodeText(zealotNode.selectSingleNode(ZealotConst.ATTR_ID));
                if (StringHelper.isBlank(zealotId)) {
                    throw new NodeNotFoundException("该xml文件中有zealot节点的zealotId属性为空，请检查！文件为:" + filePath);
                }

                // zealot节点缓存到Map中，key是由nameSpace和zealot id组成,用"@@"符号分隔,value是zealotNode
                String zealotKey = StringHelper.concat(nameSpace, ZealotConst.SP_AT, zealotId);
                AbstractZealotConfig.getZealots().put(zealotKey, zealotNode);
            }
        }
    }