Reads one BioC document from the XML file.

@return the BioC document
@throws XMLStreamException if an unexpected processing error occurs
977509
public BioCDocument readDocument()
      throws XMLStreamException {

    if (reader.document != null) {
      BioCDocument thisDocument = reader.document;
      reader.read();
      return thisDocument;
    } else {
      return null;
    }
  }
1004107
public final BELScriptWalker.document_return document() throws RecognitionException {
        BELScriptWalker.document_return retval = new BELScriptWalker.document_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        CommonTree _first_0 = null;
        CommonTree _last = null;

        CommonTree NEWLINE1=null;
        CommonTree DOCUMENT_COMMENT2=null;
        CommonTree EOF4=null;
        BELScriptWalker.record_return record3 = null;


        CommonTree NEWLINE1_tree=null;
        CommonTree DOCUMENT_COMMENT2_tree=null;
        CommonTree EOF4_tree=null;

        try {
            // BELScriptWalker.g:96:35: ( ( NEWLINE | DOCUMENT_COMMENT | record )+ EOF )
            // BELScriptWalker.g:97:5: ( NEWLINE | DOCUMENT_COMMENT | record )+ EOF
            {
            root_0 = (CommonTree)adaptor.nil();

            // BELScriptWalker.g:97:5: ( NEWLINE | DOCUMENT_COMMENT | record )+
            int cnt1=0;
            loop1:
            do {
                int alt1=4;
                switch ( input.LA(1) ) {
                case NEWLINE:
                    {
                    alt1=1;
                    }
                    break;
                case DOCUMENT_COMMENT:
                    {
                    alt1=2;
                    }
                    break;
                case 24:
                case 26:
                case 27:
                case 44:
                case 45:
                case 46:
                case 47:
                case 48:
                case 49:
                case 50:
                case 51:
                case 52:
                case 53:
                case 54:
                case 55:
                case 56:
                case 57:
                case 58:
                case 59:
                case 60:
                case 61:
                case 62:
                case 63:
                case 64:
                case 65:
                case 66:
                case 67:
                case 68:
                case 69:
                case 70:
                case 71:
                case 72:
                case 73:
                case 74:
                case 75:
                case 76:
                case 77:
                case 78:
                case 79:
                case 80:
                case 81:
                case 82:
                case 83:
                case 84:
                case 85:
                case 86:
                case 87:
                case 88:
                case 89:
                case 90:
                case 91:
                case 92:
                case 93:
                case 94:
                case 95:
                case 96:
                case 97:
                case 98:
                case 99:
                case 100:
                case 101:
                case 102:
                    {
                    alt1=3;
                    }
                    break;

                }

                switch (alt1) {
            	case 1 :
            	    // BELScriptWalker.g:97:6: NEWLINE
            	    {
            	    _last = (CommonTree)input.LT(1);
            	    NEWLINE1=(CommonTree)match(input,NEWLINE,FOLLOW_NEWLINE_in_document67); 
            	    NEWLINE1_tree = (CommonTree)adaptor.dupNode(NEWLINE1);

            	    adaptor.addChild(root_0, NEWLINE1_tree);


            	    }
            	    break;
            	case 2 :
            	    // BELScriptWalker.g:97:16: DOCUMENT_COMMENT
            	    {
            	    _last = (CommonTree)input.LT(1);
            	    DOCUMENT_COMMENT2=(CommonTree)match(input,DOCUMENT_COMMENT,FOLLOW_DOCUMENT_COMMENT_in_document71); 
            	    DOCUMENT_COMMENT2_tree = (CommonTree)adaptor.dupNode(DOCUMENT_COMMENT2);

            	    adaptor.addChild(root_0, DOCUMENT_COMMENT2_tree);


            	    }
            	    break;
            	case 3 :
            	    // BELScriptWalker.g:97:35: record
            	    {
            	    _last = (CommonTree)input.LT(1);
            	    pushFollow(FOLLOW_record_in_document75);
            	    record3=record();

            	    state._fsp--;

            	    adaptor.addChild(root_0, record3.getTree());

            	    }
            	    break;

            	default :
            	    if ( cnt1 >= 1 ) break loop1;
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                }
                cnt1++;
            } while (true);

            _last = (CommonTree)input.LT(1);
            EOF4=(CommonTree)match(input,EOF,FOLLOW_EOF_in_document79); 
            EOF4_tree = (CommonTree)adaptor.dupNode(EOF4);

            adaptor.addChild(root_0, EOF4_tree);


                    if (!docprop.containsKey(BELDocumentProperty.NAME)) {
                        addError(new DocumentNameException(lastDocumentPropertyLocation, 0));
                    } else if (!docprop.containsKey(BELDocumentProperty.DESCRIPTION)) {
                        addError(new DocumentDescriptionException(lastDocumentPropertyLocation, 0));
                    } else if (!docprop.containsKey(BELDocumentProperty.VERSION)) {
                        addError(new DocumentVersionException(lastDocumentPropertyLocation, 0));
                    } else {
                        if (documentStatementGroup.getStatements().isEmpty()) {
                            // statements are only contained in explicitly-defined statement groups
                            retval.doc = new BELDocument(BELDocumentHeader.create(docprop), adlist, nslist, statementGroups);
                        } else {
                            // statements are defined in the implicit document statement group and possibly child statement groups
                            documentStatementGroup.setChildStatementGroups(statementGroups);
                            retval.doc = new BELDocument(BELDocumentHeader.create(docprop), adlist, nslist, Arrays.asList(documentStatementGroup));
                        }
                    }
                

            }

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
909185
@SuppressWarnings("unchecked")
    public <T> T fromXml(String xml) {
        try {
            StringReader reader = new StringReader(xml);
            return (T) createUnmarshaller().unmarshal(reader);
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
734369
public Document getSchema() {

        Document result;

        if (m_schemaDocument == null) {
            result = DocumentHelper.createDocument();
            Element root = result.addElement(XSD_NODE_SCHEMA);
            root.addAttribute(XSD_ATTRIBUTE_ELEMENT_FORM_DEFAULT, XSD_ATTRIBUTE_VALUE_QUALIFIED);

            Element include = root.addElement(XSD_NODE_INCLUDE);
            include.addAttribute(XSD_ATTRIBUTE_SCHEMA_LOCATION, XSD_INCLUDE_OPENCMS);

            if (m_includes.size() > 0) {
                Iterator<CmsXmlContentDefinition> i = m_includes.iterator();
                while (i.hasNext()) {
                    CmsXmlContentDefinition definition = i.next();
                    root.addElement(XSD_NODE_INCLUDE).addAttribute(
                        XSD_ATTRIBUTE_SCHEMA_LOCATION,
                        definition.m_schemaLocation);
                }
            }

            String outerTypeName = createTypeName(getOuterName());
            String innerTypeName = createTypeName(getInnerName());

            Element content = root.addElement(XSD_NODE_ELEMENT);
            content.addAttribute(XSD_ATTRIBUTE_NAME, getOuterName());
            content.addAttribute(XSD_ATTRIBUTE_TYPE, outerTypeName);

            Element list = root.addElement(XSD_NODE_COMPLEXTYPE);
            list.addAttribute(XSD_ATTRIBUTE_NAME, outerTypeName);

            Element listSequence = list.addElement(XSD_NODE_SEQUENCE);
            Element listElement = listSequence.addElement(XSD_NODE_ELEMENT);
            listElement.addAttribute(XSD_ATTRIBUTE_NAME, getInnerName());
            listElement.addAttribute(XSD_ATTRIBUTE_TYPE, innerTypeName);
            listElement.addAttribute(XSD_ATTRIBUTE_MIN_OCCURS, XSD_ATTRIBUTE_VALUE_ZERO);
            listElement.addAttribute(XSD_ATTRIBUTE_MAX_OCCURS, XSD_ATTRIBUTE_VALUE_UNBOUNDED);

            Element main = root.addElement(XSD_NODE_COMPLEXTYPE);
            main.addAttribute(XSD_ATTRIBUTE_NAME, innerTypeName);

            Element mainSequence;
            if (m_sequenceType == SequenceType.SEQUENCE) {
                mainSequence = main.addElement(XSD_NODE_SEQUENCE);
            } else {
                mainSequence = main.addElement(XSD_NODE_CHOICE);
                if (getChoiceMaxOccurs() > 1) {
                    mainSequence.addAttribute(XSD_ATTRIBUTE_MAX_OCCURS, String.valueOf(getChoiceMaxOccurs()));
                } else {
                    mainSequence.addAttribute(XSD_ATTRIBUTE_MIN_OCCURS, XSD_ATTRIBUTE_VALUE_ZERO);
                    mainSequence.addAttribute(XSD_ATTRIBUTE_MAX_OCCURS, XSD_ATTRIBUTE_VALUE_ONE);
                }
            }

            Iterator<I_CmsXmlSchemaType> i = m_typeSequence.iterator();
            while (i.hasNext()) {
                I_CmsXmlSchemaType schemaType = i.next();
                schemaType.appendXmlSchema(mainSequence);
            }

            Element language = main.addElement(XSD_NODE_ATTRIBUTE);
            language.addAttribute(XSD_ATTRIBUTE_NAME, XSD_ATTRIBUTE_VALUE_LANGUAGE);
            language.addAttribute(XSD_ATTRIBUTE_TYPE, CmsXmlLocaleValue.TYPE_NAME);
            language.addAttribute(XSD_ATTRIBUTE_USE, XSD_ATTRIBUTE_VALUE_OPTIONAL);
        } else {
            result = (Document)m_schemaDocument.clone();
        }
        return result;
    }
338926
protected Map<String, Object> readDocument() throws IOException {
		ObjectCodec codec = getCodec();
		if (codec == null) {
			throw new IllegalStateException("Could not parse embedded document " +
					"because BSON parser has no codec");
		}
		_currToken = handleNewDocument(false);
		return codec.readValue(this, new TypeReference<Map<String, Object>>() {});
	}
107419
public Document read() {
        try {
            do {
                if (stream == null) {
                    // Open the stream to the next file ...
                    stream = openNextFile();
                    if (stream == null) {
                        // No more files to read ...
                        return null;
                    }
                    documents = Json.readMultiple(stream, false);
                }
                try {
                    Document doc = documents.nextDocument();
                    if (doc != null) return doc;
                } catch (IOException e) {
                    // We'll just continue ...
                }
                // Close the stream and try opening the next stream ...
                close(stream);
                stream = null;
            } while (true);
        } catch (IOException e) {
            problems.addError(JcrI18n.problemsWritingDocumentToBackup, currentFile.getAbsolutePath(), e.getMessage());
            return null;
        }
    }
1358745
@SuppressWarnings("unchecked")
	public static <T> T readObjectFromXml(InputSource source) throws IOException {
		Object result = null;
		XMLDecoder xmldec = null;
		try {
			xmldec = new XMLDecoder(source);
			result = xmldec.readObject();
		} finally {
			IoUtil.close(xmldec);
		}
		return (T) result;
	}
311172
private void readXmlDeclaration() throws IOException, KriptonRuntimeException {
		if (bufferStartLine != 0 || bufferStartColumn != 0 || position != 0) {
			checkRelaxed("processing instructions must not start with xml");
		}

		read(START_PROCESSING_INSTRUCTION);
		parseStartTag(true, true);

		if (attributeCount < 1 || !"version".equals(attributes[2])) {
			checkRelaxed("version expected");
		}

		version = attributes[3];

		int pos = 1;

		if (pos < attributeCount && "encoding".equals(attributes[2 + 4])) {
			encoding = attributes[3 + 4];
			pos++;
		}

		if (pos < attributeCount && "standalone".equals(attributes[4 * pos + 2])) {
			String st = attributes[3 + 4 * pos];
			if ("yes".equals(st)) {
				standalone = Boolean.TRUE;
			} else if ("no".equals(st)) {
				standalone = Boolean.FALSE;
			} else {
				checkRelaxed("illegal standalone value: " + st);
			}
			pos++;
		}

		if (pos != attributeCount) {
			checkRelaxed("unexpected attributes in XML declaration");
		}

		isWhitespace = true;
		text = null;
	}
146454
public XMLReader getXMLReader() throws SAXException
    {
        XMLFilter filter = _Verifier.getVerifierFilter();
        filter.setParent(_WrappedParser.getXMLReader());
        return filter;
    }
297851
@Override
    public <T> T read(final Class<T> projectionInterface) throws IOException {
        try {
            Document document = projector.config().createDocumentBuilder().parse(file);
            return projector.projectDOMNode(document, projectionInterface);
        } catch (SAXException e) {
            throw new XBDocumentParsingException(e);
        }
    }
1148530
public static Element parse(InputStream xmlStream) throws IOException
   {
      DocumentBuilder builder = getDocumentBuilder();
      return parse(xmlStream, builder);
   }
300306
private static void _readIBANDataFromXML ()
  {
    final IMicroDocument aDoc = MicroReader.readMicroXML (new ClassPathResource ("codelists/iban-country-data.xml"));
    if (aDoc == null)
      throw new InitializationException ("Failed to read IBAN country data [1]");
    if (aDoc.getDocumentElement () == null)
      throw new InitializationException ("Failed to read IBAN country data [2]");

    final DateTimeFormatter aDTPattern = DateTimeFormatter.ISO_DATE;

    for (final IMicroElement eCountry : aDoc.getDocumentElement ().getAllChildElements (ELEMENT_COUNTRY))
    {
      // get descriptive string
      final String sDesc = eCountry.getTextContent ();
      final String sCountryCode = sDesc.substring (0, 2);
      if (CountryCache.getInstance ().getCountry (sCountryCode) == null)
        if (LOGGER.isWarnEnabled ())
          LOGGER.warn ("IBAN country data: no such country code '" + sCountryCode + "' - be careful");

      LocalDate aValidFrom = null;
      if (eCountry.hasAttribute (ATTR_VALIDFROM))
      {
        // Constant format, conforming to XML date
        aValidFrom = PDTFromString.getLocalDateFromString (eCountry.getAttributeValue (ATTR_VALIDFROM), aDTPattern);
      }

      LocalDate aValidTo = null;
      if (eCountry.hasAttribute (ATTR_VALIDUNTIL))
      {
        // Constant format, conforming to XML date
        aValidTo = PDTFromString.getLocalDateFromString (eCountry.getAttributeValue (ATTR_VALIDUNTIL), aDTPattern);
      }

      final String sLayout = eCountry.getAttributeValue (ATTR_LAYOUT);

      final String sCheckDigits = eCountry.getAttributeValue (ATTR_CHECKDIGITS);

      // get expected length
      final String sLen = eCountry.getAttributeValue (ATTR_LEN);
      final int nExpectedLength = StringParser.parseInt (sLen, CGlobal.ILLEGAL_UINT);
      if (nExpectedLength == CGlobal.ILLEGAL_UINT)
        throw new InitializationException ("Failed to convert length '" + sLen + "' to int!");

      if (s_aIBANData.containsKey (sCountryCode))
        throw new IllegalArgumentException ("Country " + sCountryCode + " is already contained!");
      s_aIBANData.put (sCountryCode,
                       IBANCountryData.createFromString (sCountryCode,
                                                         nExpectedLength,
                                                         sLayout,
                                                         sCheckDigits,
                                                         aValidFrom,
                                                         aValidTo,
                                                         sDesc));
    }
  }
739406
public static Document toDocument(String xml) throws SAXException {
		try {
			return toDocument(new StringReader(xml));
		} catch (IOException e) {
			//reading from string
			throw new RuntimeException(e);
		}
	}
237772
public StringBuffer readFile(String filename) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(filename));
		StringBuffer xml = new StringBuffer();
		String line = null;
        while((line = reader.readLine()) != null){
            xml.append(line);
        }
		reader.close();
		return xml;
	}
102488
public static Document readXML(File file) {
		Assert.notNull(file, "Xml file is null !");
		if (false == file.exists()) {
			throw new UtilException("File [{}] not a exist!", file.getAbsolutePath());
		}
		if (false == file.isFile()) {
			throw new UtilException("[{}] not a file!", file.getAbsolutePath());
		}

		try {
			file = file.getCanonicalFile();
		} catch (IOException e) {
			// ignore
		}

		BufferedInputStream in = null;
		try {
			in = FileUtil.getInputStream(file);
			return readXML(in);
		} finally {
			IoUtil.close(in);
		}
	}
653146
private void readBioPolymer(String biopolymerFile) {
        try {
            // Read PDB file
            FileReader fileReader = new FileReader(biopolymerFile);
            ISimpleChemObjectReader reader = new ReaderFactory().createReader(fileReader);
            IChemFile chemFile = (IChemFile) reader.read((IChemObject) new ChemFile());
            // Get molecule from ChemFile
            IChemSequence chemSequence = chemFile.getChemSequence(0);
            IChemModel chemModel = chemSequence.getChemModel(0);
            IAtomContainerSet setOfMolecules = chemModel.getMoleculeSet();
            protein = (IBioPolymer) setOfMolecules.getAtomContainer(0);
        } catch (IOException | CDKException exc) {
            logger.error("Could not read BioPolymer from file>" + biopolymerFile + " due to: " + exc.getMessage());
            logger.debug(exc);
        }
    }
1290948
public <T> JSONAPIDocument<List<T>> readDocumentCollection(InputStream dataStream, Class<T> clazz) {
		try {
			resourceCache.init();

			JsonNode rootNode = objectMapper.readTree(dataStream);

			// Validate
			ValidationUtils.ensureNotError(objectMapper, rootNode);
			ValidationUtils.ensureValidResource(rootNode);

			JsonNode dataNode = rootNode.get(DATA);

			// Parse data node without handling relationships
			List<T> resourceList = new ArrayList<>();

			if (dataNode != null && dataNode.isArray()) {
				for (JsonNode element : dataNode) {
					T pojo = readObject(element, clazz, false);
					resourceList.add(pojo);
				}
			}

			// Parse all included resources
			resourceCache.cache(parseIncluded(rootNode));

			// Connect data node's relationships now that all resources have been parsed
			for (int i = 0; i < resourceList.size(); i++) {
				JsonNode source = dataNode != null && dataNode.isArray() ? dataNode.get(i) : null;
				T resourceObject = resourceList.get(i);
				if (source != null && resourceObject != null) {
					handleRelationships(source, resourceObject);
				}
			}

			JSONAPIDocument<List<T>> result = new JSONAPIDocument<>(resourceList, objectMapper);

			// Handle top-level meta
			if (rootNode.has(META)) {
				result.setMeta(mapMeta(rootNode.get(META)));
			}

			// Handle top-level links
			if (rootNode.has(LINKS)) {
				result.setLinks(new Links(mapLinks(rootNode.get(LINKS))));
			}

			return result;
		} catch (RuntimeException e) {
			throw e;
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			resourceCache.clear();
		}
	}