public static NodeList loopCounter(int start, int end) { Document doc = Xml.createDocument(); Element parent = doc.createElement("parent"); for (int i=start;i<=end;i++) { Element data = doc.createElement("data"); data.appendChild(doc.createTextNode(i + "")); parent.appendChild(data); } return parent.getElementsByTagName("data"); }
public String decodeFormattedTextAttribute(Element element, String baseAttributeName) { String ret; // first check if an HTML-encoded attribute exists, for example "foo-html", and use it if available ret = StringUtils.trimToNull(Xml.decodeAttribute(element, baseAttributeName + "-html")); if (ret != null) return ret; // next try the older kind of formatted text like "foo-formatted", and convert it if found ret = StringUtils.trimToNull(Xml.decodeAttribute(element, baseAttributeName + "-formatted")); ret = convertOldFormattedText(ret); if (ret != null) return ret; // next try just a plaintext attribute and convert the plaintext to formatted text if found // convert from old plaintext instructions to new formatted text instruction ret = Xml.decodeAttribute(element, baseAttributeName); ret = convertPlaintextToFormattedText(ret); return ret; }
creatorId = Xml.decodeAttribute(element4, "CHEF:creator"); if (newCreatorId != null) Xml.encodeAttribute(element4, "CHEF:creator", newCreatorId); element4.setAttribute("enc", "BASE64"); modifierId = Xml.decodeAttribute(element4, "CHEF:modifiedby"); if (newModifierId != null) Xml.encodeAttribute(element4, "CHEF:modifiedby", newModifierId); element4.setAttribute("enc", "BASE64");
Document doc = Xml.readDocumentFromString(xml); doc = Xml.createDocument(); m.toXml(doc, new Stack()); xml = Xml.writeDocumentToString(doc);
public String toXml() Document doc = Xml.createDocument(); Element submission = doc.createElement("submission"); doc.appendChild(submission); Xml.encodeAttribute(propElement, "value", (String) value); propElement.setAttribute("enc", "BASE64"); properties.appendChild(propElement); propElement.setAttribute("name", key); Xml.encodeAttribute(propElement, "value", (String) val); propElement.setAttribute("enc", "BASE64"); propElement.setAttribute("list", "list"); return Xml.writeDocumentToString(doc);
doc = Xml.readDocumentFromString((String)xml); doc = Xml.readDocumentFromStream(xmlClob.getAsciiStream()); String body = Xml.decodeAttribute(root, "body");
Document doc = Xml.readDocumentFromString(xml); if (doc == null)
Document doc = Xml.createDocument(); Node results = doc.createElement("events"); doc.appendChild(results); return Xml.writeDocumentToString(doc);
if (!service.willArchiveMerge()) continue; Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, fileName); Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, fileName); Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, m_storagePath + siteId + "-archive/site.xml"); doc = Xml.createDocument(); stack = new Stack(); root = doc.createElement("archive"); Xml.writeDocument(doc, m_storagePath + siteId + "-archive/user.xml");
public void encodeFormattedTextAttribute(Element element, String baseAttributeName, String value) { // store the formatted text in an attribute called baseAttributeName-html Xml.encodeAttribute(element, baseAttributeName + "-html", value); // Store the non-formatted (plaintext) version as well Xml.encodeAttribute(element, baseAttributeName, convertFormattedTextToPlaintext(value)); }
doc = Xml.readDocumentFromString((String)xml); doc = Xml.readDocumentFromStream(xmlClob.getAsciiStream());
/** * @inheritDoc */ public void register(File toolXmlFile, ServletContext context) { String path = toolXmlFile.getAbsolutePath(); if (!path.endsWith(".xml")) { log.info("register: skiping non .xml file: " + path); return; } log.info("register: file: " + path); Document doc = Xml.readDocument(path); register(doc, context); }
if (charset == null) charset = "UTF-8"; value = Xml.decode(charset,attributes.getValue("value"));
public static Document callTurnitinReturnDocument(String apiURL, Map<String,Object> parameters, String secretKey, int timeout, Proxy proxy, boolean isMultipart) throws TransientSubmissionException, SubmissionException { InputStream inputStream = callTurnitinReturnInputStream(apiURL, parameters, secretKey, timeout, proxy, isMultipart); BufferedReader in; in = new BufferedReader(new InputStreamReader(inputStream)); Document document = null; try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); document = parser.parse(new org.xml.sax.InputSource(in)); } catch (ParserConfigurationException pce){ log.error("parser configuration error: " + pce.getMessage()); throw new TransientSubmissionException ("Parser configuration error", pce); } catch (Exception t) { throw new TransientSubmissionException ("Cannot parse Turnitin response. Assuming call was unsuccessful", t); } if (log.isDebugEnabled()) { log.debug(" Result from call: " + Xml.writeDocumentToString(document)); } return document; }
/** * @inheritDoc */ public List<Tool> parseTools(InputStream toolXmlStream) { Document doc = Xml.readDocumentFromStream(toolXmlStream); try { toolXmlStream.close(); } catch (Exception e) { } if ( doc == null ) return null; return parseTools(doc); }
Document doc = Xml.readDocumentFromString(xml);
if (!service.willArchiveMerge()) continue; Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, fileName); Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, fileName); Document doc = Xml.createDocument(); Stack stack = new Stack(); Element root = doc.createElement("archive"); Xml.writeDocument(doc, m_storagePath + siteId + "-archive/site.xml"); doc = Xml.createDocument(); stack = new Stack(); root = doc.createElement("archive"); Xml.writeDocument(doc, m_storagePath + siteId + "-archive/user.xml");
/** * Serialize the properties into XML, adding an element to the doc under the top of the stack element. * * @param propsToSerialize * The properties to serialize. * @param doc * The DOM doc to contain the XML (or null for a string return). * @param stack * The DOM elements, the top of which is the containing element of the new "resource" element. * @return The newly added element. */ public static Element propertiesToXml(Properties propsToSerialize, Document doc, Stack<Element> stack) { Element properties = doc.createElement("properties"); ((Element) stack.peek()).appendChild(properties); Enumeration<?> props = propsToSerialize.propertyNames(); while (props.hasMoreElements()) { String name = (String) props.nextElement(); String value = propsToSerialize.getProperty(name); Element propElement = doc.createElement("property"); properties.appendChild(propElement); propElement.setAttribute("name", name); // encode to allow special characters in the value Xml.encodeAttribute(propElement, "value", (String) value); propElement.setAttribute("enc", "BASE64"); } return properties; }
/** * {@inheritDoc} */ public void register(File toolXmlFile) { String path = toolXmlFile.getAbsolutePath(); if (!path.endsWith(".xml")) { log.info("register: skipping non .xml file: " + path); return; } log.info("register: file: " + path); Document doc = Xml.readDocument(path); register(doc); }
if (charset == null) charset = "UTF-8"; value = Xml.decode(charset, attributes.getValue("value"));