Returns the NAACCR format of the given XML file.
@param xmlFile provided data file
@return the NAACCR format, null if it cannot be determined
323360
public static String getFormatFromXmlFile(File xmlFile) {
        if (xmlFile == null || !xmlFile.exists())
            return null;

        try (Reader reader = createReader(xmlFile)) {
            return getFormatFromXmlReader(reader);
        }
        catch (IOException | RuntimeException e) {
            return null;
        }
    }
497007
public static XslTransformer getTransformer(File xslFile) throws TransformerConfigurationException {
    	if (xslFile == null) {
    		throw new IllegalArgumentException("xslFile is null");
    	}
        return getTransformer(new StreamSource(xslFile));
    }
1182948
XMLReader getXmlReader(final String format) throws SAXException {
        if (format == null || format.equals(ATTR_FORMAT_VALUE_DITA)) {
            return reader;
        }
        for (final Map.Entry<String, String> e : parserMap.entrySet()) {
            if (format.equals(e.getKey())) {
                try {
                    // XMLReaderFactory.createXMLReader cannot be used
                    final XMLReader r = (XMLReader) Class.forName(e.getValue()).newInstance();
                    final Map<String, Boolean> features = parserFeatures.getOrDefault(e.getKey(), emptyMap());
                    for (final Map.Entry<String, Boolean> feature : features.entrySet()) {
                        try {
                            r.setFeature(feature.getKey(), feature.getValue());
                        } catch (final SAXNotRecognizedException ex) {
                            // Not Xerces, ignore exception
                        }
                    }
                    return r;
                } catch (final InstantiationException | ClassNotFoundException | IllegalAccessException ex) {
                    throw new SAXException(ex);
                }
            }
        }
        return reader;
    }
466776
public static String getJavadoc(@Nullable final Class<?> clazz) {
    try {
      if (null == clazz) return null;
      @Nullable final File source = com.simiacryptus.util.lang.CodeUtil.findFile(clazz);
      if (null == source) return clazz.getName() + " not found";
      final List<String> lines = IOUtils.readLines(new FileInputStream(source), Charset.forName("UTF-8"));
      final int classDeclarationLine = IntStream.range(0, lines.size())
        .filter(i -> lines.get(i).contains("class " + clazz.getSimpleName())).findFirst().getAsInt();
      final int firstLine = IntStream.rangeClosed(1, classDeclarationLine).map(i -> classDeclarationLine - i)
        .filter(i -> !lines.get(i).matches("\\s*[/\\*@].*")).findFirst().orElse(-1) + 1;
      final String javadoc = lines.subList(firstLine, classDeclarationLine).stream()
        .filter(s -> s.matches("\\s*[/\\*].*"))
        .map(s -> s.replaceFirst("^[ \t]*[/\\*]+", "").trim())
        .filter(x -> !x.isEmpty()).reduce((a, b) -> a + "\n" + b).orElse("");
      return javadoc.replaceAll("<p>", "\n");
    } catch (@javax.annotation.Nonnull final Throwable e) {
      e.printStackTrace();
      return "";
    }
  }
1314871
function (xmlNode) {
            if (!xmlNode) {
                return null;
            }

            var text = xmlNode.textContent;
            text = text.replace(/\n/gi, " ");
            text = text.replace(/\s+/gi, " ");
            text = text.trim();

            if (text.length === 0) {
                return null;
            }

            return text.split(" ");
        }
503915
public int resolveAndValidateElement()
        throws XMLStreamException
    {
        if (mDepth == 0) { // just a simple sanity check
            throw new IllegalStateException("Calling validate() on empty stack.");
        }
        AttributeCollector ac = mAttrCollector;

        // Any namespace declarations?
        {
            int nsCount = ac.getNsCount();
            if (nsCount > 0) {
                /* let's first invalidate old (possibly) shared ns ctxt too,
                 * if we had one; new one can be created at a later point
                 */
                mLastNsContext = null;

                boolean internNsUris = mConfig.willInternNsURIs();
                for (int i = 0; i < nsCount; ++i) {
                    Attribute ns = ac.resolveNamespaceDecl(i, internNsUris);
                    String nsUri = ns.mNamespaceURI;
                    // note: for namespaces, prefix is stored as local name
                    String prefix = ns.mLocalName;

                    /* 18-Jul-2004, TSa: Need to check that 'xml' and 'xmlns'
                     *   prefixes are not re-defined (and 'xmlns' not even
                     *   defined to its correct ns).
                     */
                    if (prefix == "xmlns") {
                        // xmlns can never be declared, even to its correct URI
                        mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XMLNS);
                    } else if (prefix == "xml") {
                        // whereas xml is ok, as long as it's same URI:
                        if (!nsUri.equals(XMLConstants.XML_NS_URI)) {
                            mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XML,
                                                      nsUri, null);
                        }
                        /* 09-Feb-2006, TSa: Hmmh. Now, should this explicit
                         *   xml declaration be visible to the app? SAX API
                         *   seem to ignore it.
                         */
                        //mNamespaces.addStrings(prefix, nsUri);
                    } else { // ok, valid prefix, so far
                        /* 17-Mar-2006, TSa: Unbinding default NS needs to
                         *    result in null being added:
                         */
                        if (nsUri == null || nsUri.length() == 0) {
                            nsUri = XmlConsts.DEFAULT_NAMESPACE_URI;
                        }
                        // The default ns binding needs special handling:
                        if (prefix == null) {
                            mCurrElement.mDefaultNsURI = nsUri;
                        }

                        /* But then let's ensure that URIs matching xml
                         * and xmlns are not being bound to anything else
                         */
                        if (internNsUris) { // identity comparison is ok:
                            if (nsUri == XMLConstants.XML_NS_URI) {
                                mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XML_URI, prefix, null);
                            } else if (nsUri == XMLConstants.XMLNS_ATTRIBUTE_NS_URI) {
                                mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XMLNS_URI);
                            }
                        } else { // need to check equals()
                            if (nsUri.equals(XMLConstants.XML_NS_URI)) {
                                mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XML_URI, prefix, null);
                            } else if (nsUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
                                mReporter.throwParseError(ErrorConsts.ERR_NS_REDECL_XMLNS_URI);
                            }
                        }
                        /* and at any rate, binding needs to be added, to
                         * be visible to the app (including def ns):
                         */
                        mNamespaces.addStrings(prefix, nsUri);
                    }
                }
            }
        }

        /* 20-Feb-2006, TSa: Any attribute defaults for namespace declaration
         *   pseudo-attributes?
         */
        if (mMayHaveNsDefaults) {
            mNsDefaultProvider.checkNsDefaults(this);
        }

        // Then, let's set element's namespace, if any:
        String prefix = mCurrElement.mPrefix;
        String ns;

        if (prefix == null) { // use default NS, if any
            ns = mCurrElement.mDefaultNsURI;
        } else if (prefix == "xml") {
            ns = XMLConstants.XML_NS_URI;
        } else {
            // Need to find namespace with the prefix:
            ns = mNamespaces.findLastFromMap(prefix);
            /* 07-Sep-2007, TSa: "no namespace" should now be indicated
             *   by an empty string, however, due to historical reasons
             *   let's be bit defensive and allow nulls for the same too
             */
            if (ns == null || ns.length() == 0) {
                mReporter.throwParseError(ErrorConsts.ERR_NS_UNDECLARED, prefix, null);
            }
        }
        mCurrElement.mNamespaceURI = ns;

        // And finally, resolve attributes' namespaces too:
        int xmlidIx = ac.resolveNamespaces(mReporter, mNamespaces);
        mIdAttrIndex = xmlidIx;

        XMLValidator vld = mValidator;
        /* If we have no validator(s), nothing more to do,
         * except perhaps little bit of Xml:id handling:
         */
        if (vld == null) { // no validator in use
            if (xmlidIx >= 0) { // need to normalize xml:id, still?
                ac.normalizeSpacesInValue(xmlidIx);
            }
            return XMLValidator.CONTENT_ALLOW_ANY_TEXT;
        }

        // Otherwise need to call relevant validation methods.

        /* First, a call to check if the element itself may be acceptable
         * within structure:
         */
        vld.validateElementStart
            (mCurrElement.mLocalName, mCurrElement.mNamespaceURI, mCurrElement.mPrefix);

        // Then attributes, if any:
        int attrLen = ac.getCount();
        if (attrLen > 0) {
            for (int i = 0; i < attrLen; ++i) {
                ac.validateAttribute(i, mValidator);
            }
        }

        /* And finally let's wrap things up to see what textual content
         * is allowed as child content, if any:
         */
        return mValidator.validateElementAndAttributes();
    }
12851
def XmlRawQuery(self, xml, dumpXml=None):
		

		if (dumpXml == None):
			dumpXml = self._dumpXml

		uri = self.Uri() + '/nuova'
		if (dumpXml in _AffirmativeList):
			print '%s ====> %s' % (self._ucs, xml)
		# req = urllib2.Request(url=uri,data=xml)
		# f = urllib2.urlopen(req)
		w = xml.dom.minidom.Document()

		if (self._noSsl):
			req = urllib2.Request(url=uri, data=w.toxml())
			opener = urllib2.build_opener(SmartRedirectHandler())
			f = opener.open(req)
			# print "##", f , "##"

			if type(f) is list:
				if (len(f) == 2 and f[0] == 302):
					# self._noSsl = False
					# uri = self.Uri() + '/nuova'
					uri = f[1]
					req = urllib2.Request(url=uri, data=w.toxml())
					f = urllib2.urlopen(req)
				# print "status code is:",f[0]
				# print "location is:", f[1]
		else:
			req = urllib2.Request(url=uri, data=w.toxml())
			f = urllib2.urlopen(req)

		rsp = f.read()
		if (dumpXml in _AffirmativeList):
			print '%s <==== %s' % (self._ucs, rsp)
		return rsp
730088
private int nextFromTreeCommentOrCData()
        throws XMLStreamException
    {
        char c = getNextCharFromCurrent(SUFFIX_IN_DOC);
        if (c == '[') {
            checkCData();
            /* Good enough; it is a CDATA section... but let's just also
             * parse the easy ("free") stuff:
             */
            c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++]
                : getNextCharFromCurrent(SUFFIX_IN_CDATA);
            readCDataPrimary(c); // sets token state appropriately...
            return CDATA;
        }
        if (c == '-' && getNextCharFromCurrent(SUFFIX_IN_DOC) == '-') {
            mTokenState = TOKEN_STARTED;
            return COMMENT;
        }
        throwParseError("Unrecognized XML directive; expected CDATA or comment ('<![CDATA[' or '<!--').");
        return 0; // never gets here, but compilers don't know it...
    }
510915
function (xmlNode) {

            var rawValues = this.getRawValues(xmlNode);
            if (!rawValues) {
                return null;
            }

            var len = rawValues.length;

            var bufferData = new Float32Array(len);
            for (var i = 0; i < len; i++) {
                bufferData[i] = parseFloat(rawValues[i]);
            }

            return bufferData;
        }
925242
private String formatXml(@Nullable Source xmlSource) {
    Transformer transformer = transformerSupplier.get();
    if (xmlSource != null && transformer != null) {
      try {
        StreamResult result = new StreamResult(new StringWriter());
        transformer.transform(xmlSource, result);
        return result.getWriter().toString();
      } catch (TransformerException e) {
        libLogger.warn("Unable to pretty print XML: {}", e);
      } catch (NullPointerException e) {
        libLogger.warn("Unable to pretty print XML: {}", e);
      } catch (ArrayIndexOutOfBoundsException e) {
        libLogger.warn("Unable to pretty print XML: {}", e);
      } catch (EmptyStackException e) {
        libLogger.warn("Unable to pretty print XML: {}", e);
      }
    }
    return null;
  }
189085
public Connector getStandardMetaData(File root) throws Exception
   {
      Connector result = null;
      File metadataFile = new File(root, "/META-INF/ra.xml");

      if (metadataFile.exists())
      {
         InputStream input = null;
         String url = metadataFile.getAbsolutePath();
         try
         {
            long start = System.currentTimeMillis();
            input = new FileInputStream(metadataFile);

            XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(input);

            result = (new RaParser()).parse(xsr);

            log.debugf("Total parse for %s took %d ms", url, (System.currentTimeMillis() - start));
         }
         catch (Exception e)
         {
            log.parsingErrorRaXml(url, e);
            throw e;
         }
         finally
         {
            if (input != null)
               input.close();
         }

      }
      else
      {
         log.tracef("metadata file %s does not exist", metadataFile.toString());
      }

      return result;
   }
533041
public String transform(File inputFile) {
		final String content;
		try (FileReader reader = new FileReader(inputFile)) {
			content = read(reader);
		} catch (IOException exception) {
			reportError(Messages.SarlDocumentationParser_0, exception);
			return null;
		}
		return transform(content, inputFile);
	}
883127
public static String getZealotXmlNameSpace(String xmlPath) {
        Document doc;
        try {
            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(xmlPath);
            doc = new SAXReader().read(is);
        } catch (Exception expected) {
            // 由于只是判断该文件是否能被正确解析，并不进行正式的解析，所有这里就不抛出和记录异常了.
            log.warn("解析路径为:'" + xmlPath + "'的xml文件出错，请检查其正确性");
            return null;
        }

        // 获取XML文件的根节点，判断其根节点是否为'zealots'，如果是则获取其属性nameSpace的值.
        Node root = doc.getRootElement();
        if (root != null && ROOT_NAME.equals(root.getName())) {
            String nameSpace = getNodeText(root.selectSingleNode(ZealotConst.ATTR_NAMESPACE));
            if (StringHelper.isBlank(nameSpace)) {
                log.warn("zealot xml文件:'" + xmlPath + "'的根节点nameSpace命名空间属性为配置，请配置，否则将被忽略!");
                return null;
            }
            return nameSpace;
        }

        return null;
    }
1075604
public function setXMLFile($XMLFile){
		if (file_exists($XMLFile)){
			$this->XMLFile = $XMLFile;
			$this->fileOK = true;
		}else{
			$this->fileOK = false;
		}
		return $this->fileOK;
	}
611970
public byte[] getAC() {

    Element acElement = (Element) xmlResponse.getElementsByTagName("ac")
      .item(0);

    byte[] ac = VOMSBase64Decoder.decode(acElement.getFirstChild()
      .getNodeValue());

    if (ac == null)
      ac = new GoodACDecodingStrategy().decode(acElement.getFirstChild()
        .getNodeValue());

    return ac;
  }
1014200
public static String format(String xml) throws CmsXmlException {

        return CmsXmlUtils.marshal((Node)CmsXmlUtils.unmarshalHelper(xml, null), CmsEncoder.ENCODING_UTF_8);
    }
890141
private Element parseDesc(final File descFile) {
        try {
            parser.setPluginDir(descFile.getParentFile());
            final Element root = parser.parse(descFile.getAbsoluteFile());
            final Features f = parser.getFeatures();
            final String id = f.getPluginId();
            validatePlugin(f);
            extensionPoints.addAll(f.getExtensionPoints().keySet());
            pluginTable.put(id, f);
            return root;
        } catch (final RuntimeException e) {
            throw e;
        } catch (final SAXParseException e) {
            final RuntimeException ex = new RuntimeException("Failed to parse " + descFile.getAbsolutePath() + ": " + e.getMessage(), e);
            throw ex;
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }