Returns the NAACCR format of the given XML reader.
@param xmlReader provided reader, cannot be null
@return the NAACCR format, null if it cannot be determined
482931
public static String getFormatFromXmlReader(Reader xmlReader) {
        Map<String, String> attributes = getAttributesFromXmlReader(xmlReader);
        String baseDictUri = attributes.get(NAACCR_XML_ROOT_ATT_BASE_DICT);
        String recordType = attributes.get(NAACCR_XML_ROOT_ATT_REC_TYPE);
        if (baseDictUri != null && recordType != null) {
            String version = NaaccrXmlDictionaryUtils.extractVersionFromUri(baseDictUri);
            if (NaaccrFormat.isVersionSupported(version) && NaaccrFormat.isRecordTypeSupported(recordType))
                return NaaccrFormat.getInstance(version, recordType).toString();
        }

        return null;
    }
789721
public static NaaccrDictionary readDictionary(Reader reader) throws IOException {
        try {
            NaaccrDictionary dictionary = (NaaccrDictionary)instanciateXStream().fromXML(reader);

            // default value for specifications
            if (dictionary.getSpecificationVersion() == null)
                dictionary.setSpecificationVersion(SpecificationVersion.SPEC_1_0);

            // default value for record types
            if (dictionary.getItems() != null)
                for (NaaccrDictionaryItem item : dictionary.getItems())
                    if (item.getRecordTypes() == null)
                        item.setRecordTypes(NaaccrFormat.ALL_RECORD_TYPES);

            // let's not validate the internal dictionaries, we know they are valid
            String uri = dictionary.getDictionaryUri();
            if (uri == null || uri.trim().isEmpty())
                throw new IOException("'dictionaryUri' attribute is required");
            else if (!BASE_DICTIONARY_URI_PATTERN.matcher(uri).matches() && !DEFAULT_USER_DICTIONARY_URI_PATTERN.matcher(uri).matches()) {
                List<String> errors = validateUserDictionary(dictionary);
                if (!errors.isEmpty())
                    throw new IOException(errors.get(0));
            }

            return dictionary;
        }
        catch (XStreamException ex) {
            throw new IOException("Unable to read dictionary", ex);
        }
    }
551056
public static Document parse(JsonReader reader) throws IOException, NotImplemented {
        reader.beginArray();
        int nodeType = reader.nextInt();


        CoreDocumentImpl doc = new DocumentImpl();

        if (nodeType == Node.ELEMENT_NODE) {
            addInitialElement(reader, doc);
        } else if (nodeType == Node.DOCUMENT_NODE) {
            addInitialDocNode(doc, reader);
        } else {
            throw new IllegalStateException("Don't know how to handle root node with type " + nodeType);
        }
        reader.endArray();
        return doc;
    }
1374359
@Override
    protected RDBMSEntityReader getReader()
    {
        if (reader == null)
        {
            reader = new RDBMSEntityReader(getJPAQuery(), kunderaQuery, kunderaMetadata);
        }
        return reader;
    }
611965
public String toCanonicalXml3(TransformerFactory factory, XMLReader resultParser, String inxml, boolean stripSpace)
			throws Exception {
		mStrip = stripSpace;
		mOut = new StringWriter();
		Transformer t = factory.newTransformer();
		SAXSource ss = new SAXSource(resultParser, new InputSource(new StringReader(inxml)));
		ss.setSystemId("http://localhost/string-input");
		t.setOutputProperty(OutputKeys.METHOD, "xml");
		t.setOutputProperty(OutputKeys.INDENT, "no");
		t.transform(ss, new SAXResult(this));
		return mOut.toString();
	}
719682
private Object readMetadataFromXML(InputSource source, Class target)
            throws MalformedURLException, ParserConfigurationException, SAXException, IOException
    {
        // TODO: make this configurable
        boolean validate = false;
        
        // get a xml reader instance:
        SAXParserFactory factory = SAXParserFactory.newInstance();
        log.info("RepositoryPersistor using SAXParserFactory : " + factory.getClass().getName());
        if (validate)
        {
            factory.setValidating(true);
        }
        SAXParser p = factory.newSAXParser();
        XMLReader reader = p.getXMLReader();
        if (validate)
        {
            reader.setErrorHandler(new OJBErrorHandler());
        }

        Object result;
        if (DescriptorRepository.class.equals(target))
        {
            // create an empty repository:
            DescriptorRepository repository = new DescriptorRepository();
            // create handler for building the repository structure
            ContentHandler handler = new RepositoryXmlHandler(repository);
            // tell parser to use our handler:
            reader.setContentHandler(handler);
            reader.parse(source);
            result = repository;
        }
        else if (ConnectionRepository.class.equals(target))
        {
            // create an empty repository:
            ConnectionRepository repository = new ConnectionRepository();
            // create handler for building the repository structure
            ContentHandler handler = new ConnectionDescriptorXmlHandler(repository);
            // tell parser to use our handler:
            reader.setContentHandler(handler);
            reader.parse(source);
            //LoggerFactory.getBootLogger().info("loading XML took " + (stop - start) + " msecs");
            result = repository;
        }
        else
            throw new MetadataException("Could not build a repository instance for '" + target +
                    "', using source " + source);
        return result;
    }
449898
public static Analysis readAnalysis(final Reader reader) throws IOException {
        checkNotNull(reader);
        try {
            JAXBContext context = JAXBContext.newInstance(Analysis.class);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            URL commonSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.common.xsd");
            URL analysisSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.analysis.xsd");
            Schema schema = schemaFactory.newSchema(new StreamSource[] { new StreamSource(commonSchemaURL.toString()), new StreamSource(analysisSchemaURL.toString()) });
            unmarshaller.setSchema(schema);
            return (Analysis) unmarshaller.unmarshal(reader);
        }
        catch (JAXBException | SAXException e) {
            throw new IOException("could not unmarshal Analysis", e);
        }
    }
305103
public byte[] getAC() {

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

    if (acElement == null || !acElement.hasChildNodes())
      return null;

    String acString = acElement.getFirstChild().getNodeValue();

    ACDecodingStrategy acDecodingStrategy = new GoodACDecodingStrategy();

    byte[] decodedAc = acDecodingStrategy.decode(acString);

    return decodedAc;
  }
1078934
public String toCanonicalXml2(XMLReader parser, InputSource inputSource, boolean stripSpace) throws Exception {
		mStrip = stripSpace;
		mOut = new StringWriter();
		parser.setContentHandler(this);
		parser.setErrorHandler(this);
		parser.parse(inputSource);
		return mOut.toString();
	}
81210
public static Reader getReader(String name) {
		InputStream inputStream = getInputStream(name);
		if (inputStream != null) {
			BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
			return reader;
		}
		return null;
	}
1239266
public static void parseCommonStoreAttributes(XMLExtendedStreamReader reader, int i,
                                                 StoreConfigurationBuilder<?, ?> builder) throws XMLStreamException {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      String value = reader.getAttributeValue(i);
      org.infinispan.tools.config.v6.Attribute attribute = org.infinispan.tools.config.v6.Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
         case FETCH_PERSISTENT_STATE:
            builder.fetchPersistentState(Boolean.parseBoolean(value));
            break;
         case IGNORE_MODIFICATIONS:
            builder.ignoreModifications(Boolean.parseBoolean(value));
            break;
         case PURGE_ON_STARTUP:
            builder.purgeOnStartup(Boolean.parseBoolean(value));
            break;
         default:
            throw ParseUtils.unexpectedAttribute(reader, i);
      }
   }
995686
public static function readerNode(XMLReader $reader)
    {
        switch ($reader->nodeType) {
            case XMLREADER::NONE:
                return '%(0)%';

            case XMLReader::ELEMENT:
                return XMLBuild::startTag($reader->name, new XMLAttributeIterator($reader));

            default:
                $node = new XMLReaderNode($reader);
                $nodeTypeName = $node->getNodeTypeName();
                $nodeType = $reader->nodeType;
                return sprintf('%%%s (%d)%%', $nodeTypeName, $nodeType);
        }
    }
1013051
public static String getAttribute(XMLStreamReader reader, String localName) {
        int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {
            String name = reader.getAttributeLocalName(i);
            if (localName.equals(name)) {
                return reader.getAttributeValue(i);
            }
        }
        return null;
    }
212955
public ItemReader<Chunk<T>> getOrCreateReader()
   {
      Node node = childNode.getOrCreate("reader");
      ItemReader<Chunk<T>> reader = new ItemReaderImpl<Chunk<T>>(this, "reader", childNode, node);
      return reader;
   }
1323148
public static Map<String, Object> toMap(String xml){
        xml = xml.replaceAll("(\\r|\\n)", "");
        if (Strings.isNullOrEmpty(xml)){
            return Collections.emptyMap();
        }
        XmlReaders readers = XmlReaders.create(xml);
        return toMap(readers);
    }
958934
public static function loadFromXML(ProtectedXMLReader $reader)
	{
		if($reader == null)
			return null;
		$group = new Group();
		$d = $reader->depth();
		while($reader->read($d))
		{
			if($reader->isElement(Database::XML_GROUP))
				$group->addGroup(Group::loadFromXML($reader));
			elseif($reader->isElement(Database::XML_ENTRY))
				$group->addEntry(Entry::loadFromXML($reader));
			elseif($reader->isElement(Database::XML_UUID))
				$group->uuid = $reader->readTextInside();
			elseif($reader->isElement(Database::XML_NAME))
				$group->name = $reader->readTextInside();
			elseif($reader->isElement(Database::XML_ICONID))
				$group->icon = $reader->readTextInside();
			elseif($reader->isElement(Database::XML_CUSTOMICONUUID))
				$group->customIcon = $reader->readTextInside();
		}
		return $group;
	}
364202
def readerForMemory(buffer, size, URL, encoding, options):
    
    ret = libxml2mod.xmlReaderForMemory(buffer, size, URL, encoding, options)
    if ret is None:raise treeError('xmlReaderForMemory() failed')
    return xmlTextReader(_obj=ret)