List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeXml
public static final String unescapeXml(final String input)
Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
Supports only the five basic XML entities (gt, lt, quot, amp, apos).
From source file:org.darkstar.batch.utils.DarkstarUtils.java
/** * Method to Collapse a String into one line, and Format It By Removing Escaped Characters * @param xmlString String to Collapse & Format * @return// w ww .j av a 2 s.co m */ public static String collapseAndFormatXmlString(final String xmlString) { String newString = xmlString; newString = newString.replaceAll("(" + System.getProperty("line.separator") + ")", " "); newString = StringEscapeUtils.unescapeXml(newString); return newString; }
From source file:org.dice_research.topicmodeling.io.xml.BricsBasedXmlParser.java
private void parseEscapedCharachter(int startPos, int length) { // buffer.append(text.substring(lastPos, startPos)); lastPos = startPos + length;/*from www . j av a 2 s . c o m*/ buffer.append(StringEscapeUtils.unescapeXml(text.substring(startPos, lastPos))); }
From source file:org.dice_research.topicmodeling.io.xml.stream.SimpleReaderBasedXMLParser.java
@Override public void foundPattern(int patternId, String data, String patternMatch) { dataBuffer.append(data);//from www . jav a 2 s.co m if (patternId == ReaderBasedXMLTextMachine.XML_ENCODED_CHAR_PATTERN_ID) { dataBuffer.append(StringEscapeUtils.unescapeXml(patternMatch)); } else if (patternId == ReaderBasedXMLTextMachine.XML_TAG_PATTERN_ID) { if (dataBuffer.length() > 0) { observer.handleData(dataBuffer.toString()); dataBuffer.setLength(0); } if (patternMatch.startsWith("</")) { observer.handleClosingTag(patternMatch.substring(2, patternMatch.length() - 1)); } else { if (patternMatch.endsWith("/>")) { } else { observer.handleOpeningTag(patternMatch.substring(1, patternMatch.length() - 1)); } } } }
From source file:org.easyxml.xml.Attribute.java
/** * Get un-escaped value of this attribute. * * @return Original text value. */ public String getValue() { return StringEscapeUtils.unescapeXml(value); }
From source file:org.easyxml.xml.Element.java
/** * * Get the innerText of the element * * @return innerText un-escaped */ public String getValue() { return StringEscapeUtils.unescapeXml(value); }
From source file:org.eclipse.recommenders.jayes.io.XDSLReader.java
private void initializeNodeOutcomes(Document doc, BayesNet net) { NodeList nodelist = doc.getElementsByTagName(STATE); for (int i = 0; i < nodelist.getLength(); i++) { Node node = nodelist.item(i); BayesNode bNode = net.getNode(getId(node.getParentNode())); bNode.addOutcome(StringEscapeUtils.unescapeXml(getId(node))); }//from w w w . j a v a 2s .c o m }
From source file:org.eclipse.recommenders.jayes.io.XMLBIFReader.java
@SuppressWarnings("deprecation") //the Jayes 1.0.0 API is used here intentionally private void initializeNodes(Document doc, BayesNet net) { XPathEvaluator xpath = getXPathEvaluator(doc); NodeList nodelist = doc.getElementsByTagName(VARIABLE); for (int i = 0; i < nodelist.getLength(); i++) { Node node = nodelist.item(i); Node name = XPathUtil.evalXPath(xpath, NAME, node).next(); BayesNode bNode = new BayesNode(name.getTextContent()); for (Iterator<Node> it = XPathUtil.evalXPath(xpath, OUTCOME, node); it.hasNext();) { bNode.addOutcome(StringEscapeUtils.unescapeXml(it.next().getTextContent())); }// w ww. java 2 s . c om net.addNode(bNode); } }
From source file:org.jboss.dashboard.commons.xml.XMLNode.java
public void loadFromXMLNode(Node node) { objectName = node.getNodeName();/* w w w . j a v a 2 s . c o m*/ NamedNodeMap attributesMap = node.getAttributes(); if (attributesMap != null) for (int i = 0; i < attributesMap.getLength(); i++) { Node attribute = attributesMap.item(i); addAttribute(attribute.getNodeName(), StringEscapeUtils.unescapeXml(attribute.getNodeValue())); } NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeName().equals("#text")) { String content = child.getNodeValue(); if (content != null && content.trim().length() > 0) setContent(Base64.decode(child.getNodeValue().trim())); } else { XMLNode childNode = new XMLNode("?", this); childNode.loadFromXMLNode(child); addChild(childNode); } } }
From source file:org.jboss.dashboard.dataset.AbstractDataSet.java
public List<DataProperty> _parseXMLProperties(NodeList nodes, boolean update) throws Exception { List<DataProperty> result = new ArrayList<DataProperty>(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeName().equals("dataproperty")) { String idDataProperty = StringEscapeUtils .unescapeXml(node.getAttributes().getNamedItem("id").getNodeValue()); DataProperty property = getPropertyById(idDataProperty); if (property == null) { if (update) continue; // Be aware of deleted properties. else property = new DefaultDataProperty(idDataProperty); }// www . j a va 2 s . c o m result.add(property); NodeList dataProperties = node.getChildNodes(); for (int y = 0; y < dataProperties.getLength(); y++) { Node dataProperty = dataProperties.item(y); if (dataProperty.getNodeName().equals("domain")) { Domain domain = (Domain) Class .forName(StringEscapeUtils.unescapeXml(dataProperty.getFirstChild().getNodeValue())) .newInstance(); if (dataProperty.getAttributes().getNamedItem("convertedFromNumeric") != null) ((LabelDomain) domain).setConvertedFromNumeric(true); property.setDomain(domain); } if (dataProperty.getNodeName().equals("name")) { String lang = dataProperty.getAttributes().getNamedItem("language").getNodeValue(); String desc = StringEscapeUtils.unescapeXml(dataProperty.getFirstChild().getNodeValue()); property.setName(desc, new Locale(lang)); } } } } return result; }
From source file:org.jboss.dashboard.displayer.AbstractDataDisplayerXMLFormat.java
protected DomainConfiguration parseDomain(NodeList domainNodes) { DomainConfiguration domainConfig = new DomainConfiguration(); for (int k = 0; k < domainNodes.getLength(); k++) { Node item = domainNodes.item(k); if (item.getNodeName().equals("propertyid") && item.hasChildNodes()) { domainConfig.setPropertyId(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); }//from w w w. ja v a 2 s . com if (item.getNodeName().equals("name") && item.hasChildNodes()) { String name = item.getFirstChild().getNodeValue(); Locale locale = LocaleManager.currentLocale(); Node languageNode = item.getAttributes().getNamedItem("language"); if (languageNode != null) locale = new Locale(languageNode.getNodeValue()); domainConfig.setPropertyName(StringEscapeUtils.unescapeXml(name), locale); } if (item.getNodeName().equals("maxnumberofintervals") && item.hasChildNodes()) { domainConfig.setMaxNumberOfIntervals( StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } // Label domain. if (item.getNodeName().equals("intervalstohide") && item.hasChildNodes()) { String interval = item.getFirstChild().getNodeValue(); Locale locale = LocaleManager.currentLocale(); Node languageNode = item.getAttributes().getNamedItem("language"); if (languageNode != null) locale = new Locale(languageNode.getNodeValue()); domainConfig.setLabelIntervalsToHide(StringEscapeUtils.unescapeXml(interval), locale); } // Date domain. if (item.getNodeName().equals("taminterval") && item.hasChildNodes()) { domainConfig.setDateTamInterval(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } if (item.getNodeName().equals("mindate") && item.hasChildNodes()) { domainConfig.setDateMinDate(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } if (item.getNodeName().equals("maxdate") && item.hasChildNodes()) { domainConfig.setDateMaxDate(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } // Numeric domain. if (item.getNodeName().equals("taminterval") && item.hasChildNodes()) { domainConfig .setNumericTamInterval(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } if (item.getNodeName().equals("minvalue") && item.hasChildNodes()) { domainConfig.setNumericMinValue(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } if (item.getNodeName().equals("maxvalue") && item.hasChildNodes()) { domainConfig.setNumericMaxValue(StringEscapeUtils.unescapeXml(item.getFirstChild().getNodeValue())); } } return domainConfig; }