Parses a {@code <r>} Rich Text Run. Returns just the text and drops the formatting. See <a
href="https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.run.aspx">xmlschema
type {@code CT_RElt}</a>.
978621
private void parseCT_RElt(XMLEventReader xmlEventReader, StringBuilder buf) throws XMLStreamException {
    // Precondition: pointing to <r>;  Post condition: pointing to </r>
    XMLEvent xmlEvent;
    while((xmlEvent = xmlEventReader.nextTag()).isStartElement()) {
      switch(xmlEvent.asStartElement().getName().getLocalPart()) {
        case "t": // Text
          buf.append(xmlEventReader.getElementText());
          break;
        case "rPr": // Run Properties
          skipElement(xmlEventReader);
          break;
        default:
          throw new IllegalArgumentException(xmlEvent.asStartElement().getName().getLocalPart());
      }
    }
  }
410384
private void parseStartTag(boolean xmldecl, boolean throwOnResolveFailure) throws IOException, KriptonRuntimeException {
		if (!xmldecl) {
			read('<');
		}
		name = readName();
		attributeCount = 0;

		while (true) {
			skip();

			if (position >= limit && !fillBuffer(1)) {
				checkRelaxed(UNEXPECTED_EOF);
				return;
			}

			int c = buffer[position];

			if (xmldecl) {
				if (c == '?') {
					position++;
					read('>');
					return;
				}
			} else {
				if (c == '/') {
					degenerated = true;
					position++;
					skip();
					read('>');
					break;
				} else if (c == '>') {
					position++;
					break;
				}
			}

			String attrName = readName();

			int i = (attributeCount++) * 4;
			attributes = ensureCapacity(attributes, i + 4);
			attributes[i] = "";
			attributes[i + 1] = null;
			attributes[i + 2] = attrName;

			skip();
			if (position >= limit && !fillBuffer(1)) {
				checkRelaxed(UNEXPECTED_EOF);
				return;
			}

			if (buffer[position] == '=') {
				position++;

				skip();
				if (position >= limit && !fillBuffer(1)) {
					checkRelaxed(UNEXPECTED_EOF);
					return;
				}
				char delimiter = buffer[position];

				if (delimiter == '\'' || delimiter == '"') {
					position++;
				} else if (relaxed) {
					delimiter = ' ';
				} else {
					throw new KriptonRuntimeException("attr value delimiter missing!", true, this.getLineNumber(), this.getColumnNumber(), getPositionDescription(), null);
				}

				attributes[i + 3] = readValue(delimiter, true, throwOnResolveFailure, ValueContext.ATTRIBUTE);

				if (delimiter != ' ') {
					position++; // end quote
				}
			} else if (relaxed) {
				attributes[i + 3] = attrName;
			} else {
				checkRelaxed("Attr.value missing f. " + attrName);
				attributes[i + 3] = attrName;
			}
		}

		int sp = depth++ * 4;
		elementStack = ensureCapacity(elementStack, sp + 4);
		elementStack[sp + 3] = name;

		if (depth >= nspCounts.length) {
			int[] bigger = new int[depth + 4];
			System.arraycopy(nspCounts, 0, bigger, 0, nspCounts.length);
			nspCounts = bigger;
		}

		nspCounts[depth] = nspCounts[depth - 1];

		if (processNsp) {
			adjustNsp();
		} else {
			namespace = "";
		}

		// For consistency with Expat, add default attributes after fixing
		// namespaces.
		if (defaultAttributes != null) {
			Map<String, String> elementDefaultAttributes = defaultAttributes.get(name);
			if (elementDefaultAttributes != null) {
				for (Map.Entry<String, String> entry : elementDefaultAttributes.entrySet()) {
					if (getAttributeValue(null, entry.getKey()) != null) {
						continue; // an explicit value overrides the default
					}

					int i = (attributeCount++) * 4;
					attributes = ensureCapacity(attributes, i + 4);
					attributes[i] = "";
					attributes[i + 1] = null;
					attributes[i + 2] = entry.getKey();
					attributes[i + 3] = entry.getValue();
				}
			}
		}

		elementStack[sp] = namespace;
		elementStack[sp + 1] = prefix;
		elementStack[sp + 2] = name;
	}
392859
public static Geldbetrag parse(CharSequence text, MonetaryAmountFormat formatter) {
        return from(formatter.parse(text));
    }
1346242
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    int context = xctxt.getCurrentNode();
    DTM dtm = xctxt.getDTM(context);
    int docContext = dtm.getDocument();

    if (DTM.NULL == docContext)
      error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);

    XObject arg = m_arg0.execute(xctxt);
    int argType = arg.getType();
    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
    NodeSetDTM nodeSet = nodes.mutableNodeset();

    if (XObject.CLASS_NODESET == argType)
    {
      DTMIterator ni = arg.iter();
      StringVector usedrefs = null;
      int pos = ni.nextNode();

      while (DTM.NULL != pos)
      {
        DTM ndtm = ni.getDTM(pos);
        String refval = ndtm.getStringValue(pos).toString();

        pos = ni.nextNode();
        usedrefs = getNodesByID(xctxt, docContext, refval, usedrefs, nodeSet,
                                DTM.NULL != pos);
      }
      // ni.detach();
    }
    else if (XObject.CLASS_NULL == argType)
    {
      return nodes;
    }
    else
    {
      String refval = arg.str();

      getNodesByID(xctxt, docContext, refval, null, nodeSet, false);
    }

    return nodes;
  }
791777
@SuppressWarnings("unchecked")
    @Override
    public T parse(final String text) {
        
        try {
            return (T) parseMethod.invoke(type, text, formatter);
            
        } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new TextParseException(text, type, "Cannot suuport type.");
            
        } catch(DateTimeParseException e) {
            throw new TextParseException(text, type, e);
        }
        
    }
534813
def parse_style(document, xmlcontent):
    

    styles = etree.fromstring(xmlcontent)

    _r = styles.xpath('.//w:rPrDefault', namespaces=NAMESPACES)

    if len(_r) > 0:
        rpr = _r[0].find(_name('{{{w}}}rPr'))

        if rpr is not None:
            st = doc.Style()
            parse_previous_properties(document, st, rpr)
            document.default_style = st

    # rest of the styles
    for style in styles.xpath('.//w:style', namespaces=NAMESPACES):
        st = doc.Style()

        st.style_id = style.attrib[_name('{{{w}}}styleId')]

        style_type = style.attrib[_name('{{{w}}}type')]
        if style_type is not None:
            st.style_type = style_type

        if _name('{{{w}}}default') in style.attrib:
            is_default = style.attrib[_name('{{{w}}}default')]
            if is_default is not None:
                st.is_default = is_default == '1'

        name = style.find(_name('{{{w}}}name'))
        if name is not None:
            st.name = name.attrib[_name('{{{w}}}val')]

        based_on = style.find(_name('{{{w}}}basedOn'))

        if based_on is not None:
            st.based_on = based_on.attrib[_name('{{{w}}}val')]

        document.styles.styles[st.style_id] = st

        if st.is_default:
            document.styles.default_styles[st.style_type] = st.style_id

        rpr = style.find(_name('{{{w}}}rPr'))

        if rpr is not None:
            parse_previous_properties(document, st, rpr)

        ppr = style.find(_name('{{{w}}}pPr'))

        if ppr is not None:
            parse_paragraph_properties(document, st, ppr)
212784
protected String getFormattedDatatypeValue(ICompositeNode node, AbstractRule rule, String text) throws ValueConverterException {
		Object value = valueConverter.toValue(text, rule.getName(), node);
		text = valueConverter.toString(value, rule.getName());
		return text;
	}
407315
public XMLString xstr(XPathContext xctxt)
          throws javax.xml.transform.TransformerException
  {
    return execute(xctxt).xstr();
  }
621555
@POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
    public static Collection<Utterance> mapTextWithOptions(final AnalysisRequest r)
            throws IOException, InterruptedException, JAXBException, SQLException, ParserConfigurationException,
                   SAXException {

        System.out.println(r);

        // metamap options
        final Collection<Option> opts = new ArrayList<>();
        final Set<String> optionNames = new HashSet<>();
        for (final String o : r.getOptions()) {
            final Option opt = MetaMapOptions.strToOpt(o);
            if (opt != null) {
                optionNames.add(opt.name());
                if (!opt.useProcessorDefault()) opts.add(opt);
            }
        }
        // always make sure we have a restrict_to_sources option
        if (!optionNames.contains(new RestrictToSources().name())) opts.add(new RestrictToSources());

        // tmp files for metamap in/out
        final File infile = File.createTempFile("metamap-input-", ".txt");
        final File outfile = File.createTempFile("metamap-output-", ".xml");
        final String s = r.getText() + (r.getText().endsWith("\n") ? "" : "\n");
        final String ascii = MetaMap.decomposeToAscii(URLDecoder.decode(s, "UTF-8"));
        Files.write(ascii, infile, Charsets.UTF_8);
        // we don't want too much data for a free service
        if (infile.length() > MAX_DATA_BYTES) {
            throw new WebApplicationException(
                    Response.status(Responses.NOT_ACCEPTABLE)
                            .entity("Too much data, currently limited to " + MAX_DATA_BYTES + " bytes.")
                            .type("text/plain").build()
            );
        }

        // process the data with MetaMap
        final MetaMap metaMap = new MetaMap(PUBLIC_MM_DIR, opts);
        if (!metaMap.process(infile, outfile)) {
            throw new WebApplicationException(Response.status(INTERNAL_SERVER_ERROR)
                                                      .entity("Processing failed, aborting.")
                                                      .type("text/plain").build());
        }

        // look up the SNOMED codes from the UMLS CUI code/description combinations returned by MetaMap
        final MMOs root = JaxbLoader.loadXml(outfile);
        try (final SnomedLookup snomedLookup = new SnomedLookup(DB_PATH)) {
            snomedLookup.enrichXml(root);
        }

        //noinspection ResultOfMethodCallIgnored
        infile.delete();
        //noinspection ResultOfMethodCallIgnored
        outfile.delete();

        return destructiveFilter(root);
    }
880954
function( doc, text, textFormat ){
		   var node = modules.domUtils.createNodeWithText( 'div', text );
		   return this.parse( doc, node, textFormat );
		}
864123
def parse(node)
      node.xpath('*').each do |math_run_child|
        case math_run_child.name
        when 'rPr'
          @properties = MathRunProperties.new(parent: self).parse(math_run_child)
        when 't'
          @text = math_run_child.text
        end
      end
      self
    end
1053176
@SuppressWarnings("unchecked")
    public Collection<Emit> parseText(String text)
    {
        checkForConstructedFailureStates();

        int position = 0;
        State currentState = this.rootState;
        List<Emit> collectedEmits = new ArrayList<Emit>();
        for (int i = 0; i < text.length(); ++i)
        {
            currentState = getState(currentState, text.charAt(i));
            storeEmits(position, currentState, collectedEmits);
            ++position;
        }

        if (!trieConfig.isAllowOverlaps())
        {
            IntervalTree intervalTree = new IntervalTree((List<Intervalable>) (List<?>) collectedEmits);
            intervalTree.removeOverlaps((List<Intervalable>) (List<?>) collectedEmits);
        }

        if (trieConfig.remainLongest)
        {
            remainLongest(collectedEmits);
        }

        return collectedEmits;
    }
463878
public TextBuilder parStyledContent(final String text, final TextStyle ts) {
        return this.par().styledSpan(text, ts);
    }
1065769
public PackageDescr parse(final Resource resource, final String text) throws DroolsParserException {
        this.resource = resource;
        return parse(false, text);
    }
318979
public final void mRULE_RICH_TEXT_START() throws RecognitionException {
        try {
            int _type = RULE_RICH_TEXT_START;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // InternalSARL.g:16906:22: ( '\\'\\'\\'' ( RULE_IN_RICH_STRING )* ( '\\'' ( '\\'' )? )? '\\uFFFD' )
            // InternalSARL.g:16906:24: '\\'\\'\\'' ( RULE_IN_RICH_STRING )* ( '\\'' ( '\\'' )? )? '\\uFFFD'
            {
            match("'''"); 

            // InternalSARL.g:16906:33: ( RULE_IN_RICH_STRING )*
            loop12:
            do {
                int alt12=2;
                int LA12_0 = input.LA(1);

                if ( (LA12_0=='\'') ) {
                    int LA12_1 = input.LA(2);

                    if ( (LA12_1=='\'') ) {
                        int LA12_4 = input.LA(3);

                        if ( ((LA12_4>='\u0000' && LA12_4<='&')||(LA12_4>='(' && LA12_4<='\uFFFC')||(LA12_4>='\uFFFE' && LA12_4<='\uFFFF')) ) {
                            alt12=1;
                        }


                    }
                    else if ( ((LA12_1>='\u0000' && LA12_1<='&')||(LA12_1>='(' && LA12_1<='\uFFFC')||(LA12_1>='\uFFFE' && LA12_1<='\uFFFF')) ) {
                        alt12=1;
                    }


                }
                else if ( ((LA12_0>='\u0000' && LA12_0<='&')||(LA12_0>='(' && LA12_0<='\uFFFC')||(LA12_0>='\uFFFE' && LA12_0<='\uFFFF')) ) {
                    alt12=1;
                }


                switch (alt12) {
            	case 1 :
            	    // InternalSARL.g:16906:33: RULE_IN_RICH_STRING
            	    {
            	    mRULE_IN_RICH_STRING(); 

            	    }
            	    break;

            	default :
            	    break loop12;
                }
            } while (true);

            // InternalSARL.g:16906:54: ( '\\'' ( '\\'' )? )?
            int alt14=2;
            int LA14_0 = input.LA(1);

            if ( (LA14_0=='\'') ) {
                alt14=1;
            }
            switch (alt14) {
                case 1 :
                    // InternalSARL.g:16906:55: '\\'' ( '\\'' )?
                    {
                    match('\''); 
                    // InternalSARL.g:16906:60: ( '\\'' )?
                    int alt13=2;
                    int LA13_0 = input.LA(1);

                    if ( (LA13_0=='\'') ) {
                        alt13=1;
                    }
                    switch (alt13) {
                        case 1 :
                            // InternalSARL.g:16906:60: '\\''
                            {
                            match('\''); 

                            }
                            break;

                    }


                    }
                    break;

            }

            match('\uFFFD'); 

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
306985
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
  {

    XMLString s1 = m_arg0.execute(xctxt).xstr();
    double start = m_arg1.execute(xctxt).num();
    int lenOfS1 = s1.length();
    XMLString substr;

    if (lenOfS1 <= 0)
      return XString.EMPTYSTRING;
    else
    {
      int startIndex;

      if (Double.isNaN(start))
      {

        // Double.MIN_VALUE doesn't work with math below 
        // so just use a big number and hope I never get caught.
        start = -1000000;
        startIndex = 0;
      }
      else
      {
        start = Math.round(start);
        startIndex = (start > 0) ? (int) start - 1 : 0;
      }

      if (null != m_arg2)
      {
        double len = m_arg2.num(xctxt);
        int end = (int) (Math.round(len) + start) - 1;

        // Normalize end index.
        if (end < 0)
          end = 0;
        else if (end > lenOfS1)
          end = lenOfS1;

        if (startIndex > lenOfS1)
          startIndex = lenOfS1;

        substr = s1.substring(startIndex, end);
      }
      else
      {
        if (startIndex > lenOfS1)
          startIndex = lenOfS1;
        substr = s1.substring(startIndex);
      }
    }

    return (XString)substr; // cast semi-safe
  }
162970
String showScriptContextHTML( String s, int lineNo, int context )
    {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = new BufferedReader( new StringReader(s) );

        int beginLine = Math.max( 1, lineNo-context );
        int endLine = lineNo + context;
        for( int i=1; i<=lineNo+context+1; i++ )
        {
            if ( i < beginLine )
            {
                try {
                    br.readLine();
                } catch ( IOException e ) {
                    throw new RuntimeException( e.toString() );
                }
                continue;
            }
            if ( i > endLine )
                break;

            String line;
            try {
                line = br.readLine();
            } catch ( IOException e ) {
                throw new RuntimeException( e.toString() );
            }

            if ( line == null )
                break;
            if ( i == lineNo )
                sb.append( "<font color=\"red\">"+i+": "+line +"</font><br/>" );
            else
                sb.append( i+": " +line +"<br/>" );
        }

        return sb.toString();
    }