Create an xmltextReader for a preparsed document.
769780
def readerWalker(self):
        
        ret = libxml2mod.xmlReaderWalker(self._o)
        if ret is None:raise treeError('xmlReaderWalker() failed')
        __tmp = xmlTextReader(_obj=ret)
        return __tmp
857751
XMLReader newXMLReader() throws ParserConfigurationException, SAXException, FactoryConfigurationError {
		SAXParserFactory parserFactory = SAXParserFactory.newInstance();
		SAXParser saxParser = parserFactory.newSAXParser();
		XMLReader reader = saxParser.getXMLReader();
		reader.setContentHandler(this);
		return reader;
	}
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;
    }
1176994
def FromTextFormat(cls, text):
    """"""
    tmp = cls.protobuf()  # pylint: disable=not-callable
    text_format.Merge(text, tmp)

    return cls.FromSerializedString(tmp.SerializeToString())
413663
def _xmlTextReaderErrorFunc(xxx_todo_changeme,msg,severity,locator):
    """"""
    (f,arg) = xxx_todo_changeme
    return f(arg,msg,severity,xmlTextReaderLocator(locator))
199291
def pformat_xml(xml):
    """"""
    try:
        from lxml import etree  # delayed import
        if not isinstance(xml, bytes):
            xml = xml.encode('utf-8')
        xml = etree.parse(io.BytesIO(xml))
        xml = etree.tostring(xml, pretty_print=True, xml_declaration=True,
                             encoding=xml.docinfo.encoding)
        xml = bytes2str(xml)
    except Exception:
        if isinstance(xml, bytes):
            xml = bytes2str(xml)
        xml = xml.replace('><', '>\n<')
    return xml.replace('  ', ' ').replace('\t', ' ')
75900
private synchronized Document asXmlDocument() throws IOException {
    Document doc;
    try {
      doc =
        DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException pe) {
      throw new IOException(pe);
    }
    Element conf = doc.createElement("configuration");
    doc.appendChild(conf);
    conf.appendChild(doc.createTextNode("\n"));
    handleDeprecation(); //ensure properties is set and deprecation is handled
    for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
      String name = (String)e.nextElement();
      Object object = properties.get(name);
      String value = null;
      if (object instanceof String) {
        value = (String) object;
      }else {
        continue;
      }
      Element propNode = doc.createElement("property");
      conf.appendChild(propNode);

      Element nameNode = doc.createElement("name");
      nameNode.appendChild(doc.createTextNode(name));
      propNode.appendChild(nameNode);

      Element valueNode = doc.createElement("value");
      valueNode.appendChild(doc.createTextNode(value));
      propNode.appendChild(valueNode);

      if (updatingResource != null) {
        String[] sources = updatingResource.get(name);
        if(sources != null) {
          for(String s : sources) {
            Element sourceNode = doc.createElement("source");
            sourceNode.appendChild(doc.createTextNode(s));
            propNode.appendChild(sourceNode);
          }
        }
      }

      conf.appendChild(doc.createTextNode("\n"));
    }
    return doc;
  }
1013924
public static XMLReader createXMLReader() throws SAXException, ParserConfigurationException, FactoryConfigurationError {
        try {
            return (XMLReader) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws SAXException, ParserConfigurationException, FactoryConfigurationError {
                    Thread currThread = Thread.currentThread();
                    ClassLoader oldLoader = currThread.getContextClassLoader();
                    currThread.setContextClassLoader(ParserFactory.class.getClassLoader());
                    try {
                        /**
                         * Changed to use pluggable parser version. Needed for JDK 1.4.1
                         */
                        return SAXParserFactory.newInstance().newSAXParser().getXMLReader();
                        //return XMLReaderFactory.createXMLReader();
                    }
                                        finally {
                                            currThread.setContextClassLoader(oldLoader);
                                        }
                                    }
            });
        } catch (PrivilegedActionException pae) {
            Throwable t = pae.getCause();
            if (t instanceof SAXException) {
                throw (SAXException) t;
            } else if (t instanceof ParserConfigurationException) {
                throw (ParserConfigurationException) t;
            } else if (t instanceof FactoryConfigurationError) {
                throw (FactoryConfigurationError) t;
            }
        }
        return null;
    }
617900
private Document prepareTBXDocument() throws ParserConfigurationException {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder = factory.newDocumentBuilder();
		Document tbxDocument = builder.newDocument();

		Element martif = tbxDocument.createElement("martif");
		martif.setAttribute("type", "TBX");
		tbxDocument.appendChild(martif);

		Element header = tbxDocument.createElement("martifHeader");
		martif.appendChild(header);

		Element fileDesc = tbxDocument.createElement("fileDesc");
		header.appendChild(fileDesc);

		Element encodingDesc = tbxDocument.createElement("encodingDesc");
		header.appendChild(encodingDesc);

		Element encodingP = tbxDocument.createElement("p");
		encodingP.setAttribute("type", "XCSURI");
		encodingP.setTextContent("http://ttc-project.googlecode.com/files/ttctbx.xcs");
		encodingDesc.appendChild(encodingP);

		Element sourceDesc = tbxDocument.createElement("sourceDesc");
		Element p = tbxDocument.createElement("p");
//		p.setTextContent(workingDir.getAbsolutePath());
		sourceDesc.appendChild(p);
		fileDesc.appendChild(sourceDesc);

		Element text = tbxDocument.createElement("text");
		martif.appendChild(text);

        Element body = tbxDocument.createElement("body");
		text.appendChild(body);
		return tbxDocument;
    }
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);
		}
	}
95549
def htmlReadMemory(buffer, size, URL, encoding, options):
    
    ret = libxml2mod.htmlReadMemory(buffer, size, URL, encoding, options)
    if ret is None:raise treeError('htmlReadMemory() failed')
    return xmlDoc(_obj=ret)
81539
def __init_xml(self, rootElementTag):
        """"""
        xml_root = etree.Element(rootElementTag)
        key = etree.SubElement(xml_root, "Key")
        key.text = self.apikey
        return xml_root
96253
def fromxml(node):
        """"""
        if not isinstance(node,ElementTree._Element): #pylint: disable=protected-access
            node = parsexmlstring(node)
        if node.tag.lower() != 'meta':
            raise Exception("Expected meta tag but got '" + node.tag + "' instead")

        key = node.attrib['id']
        if node.text:
            value = node.text
        else:
            value = None
        operator = 'set'
        if 'operator' in node.attrib:
            operator= node.attrib['operator']
        if operator == 'set':
            cls = SetMetaField
        elif operator == 'unset':
            cls = UnsetMetaField
        elif operator == 'copy':
            cls = CopyMetaField
        elif operator == 'parameter':
            cls = ParameterMetaField
        return cls(key, value)
368599
private Document parseInputSource(InputSource s) throws JspException {
        try {
            DocumentBuilder db = XmlUtil.newDocumentBuilder();
            db.setEntityResolver(entityResolver);
            return db.parse(s);
        } catch (SAXException e) {
            throw new JspException(e);
        } catch (IOException e) {
            throw new JspException(e);
        }
    }
4604
def _create_text_node(self, root, name, value, cdata=False):
        '''
        
        '''
        if is_empty_or_none(value):
            return

        if type(value) == date:
            value = date_to_string(value)

        if type(value) == datetime:
            value = datetime_to_string(value)

        if isinstance(value, Decimal):
            value = "0" if not value else str(value)

        tag = root.ownerDocument.createElement(name)
        value = value.decode('utf-8')
        if cdata:
            tag.appendChild(root.ownerDocument.createCDATASection(value))
        else:
            tag.appendChild(root.ownerDocument.createTextNode(value))

        return root.appendChild(tag)
392800
def htmlCtxtReadFd(self, fd, URL, encoding, options):
        
        ret = libxml2mod.htmlCtxtReadFd(self._o, fd, URL, encoding, options)
        if ret is None:raise treeError('htmlCtxtReadFd() failed')
        __tmp = xmlDoc(_obj=ret)
        return __tmp
1088435
public String rawElementText(XMLStreamReader reader) throws XMLStreamException {
    String elementText = reader.getElementText();
    elementText = elementText == null || elementText.trim().length() == 0 ? null : elementText.trim();
    return elementText;
  }