本文整理了Java中org.sakaiproject.util.Xml
类的一些代码示例,展示了Xml
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Xml
类的具体详情如下:
包路径:org.sakaiproject.util.Xml
类名称:Xml
[英]Xml is a DOM XML helper object with static functions to help with XML.
[中]Xml是一个DOM Xml助手对象,具有帮助处理Xml的静态函数。
代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-tool-lib
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");
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
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;
}
代码示例来源:origin: org.sakaiproject.assignment/sakai-assignment-impl
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");
代码示例来源:origin: org.sakaiproject.announcement/sakai-announcement-impl
Document doc = Xml.readDocumentFromString(xml);
doc = Xml.createDocument();
m.toXml(doc, new Stack());
xml = Xml.writeDocumentToString(doc);
代码示例来源:origin: org.sakaiproject.assignment/sakai-assignment-impl
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);
代码示例来源:origin: org.sakaiproject/sakai-chat-impl
doc = Xml.readDocumentFromString((String)xml);
doc = Xml.readDocumentFromStream(xmlClob.getAsciiStream());
String body = Xml.decodeAttribute(root, "body");
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
Document doc = Xml.readDocumentFromString(xml);
if (doc == null)
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
Document doc = Xml.createDocument();
Node results = doc.createElement("events");
doc.appendChild(results);
return Xml.writeDocumentToString(doc);
代码示例来源:origin: org.sakaiproject.common/archive-impl2
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");
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
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));
}
代码示例来源:origin: org.sakaiproject/sakai-chat-impl
doc = Xml.readDocumentFromString((String)xml);
doc = Xml.readDocumentFromStream(xmlClob.getAsciiStream());
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
/**
* @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);
}
代码示例来源:origin: sakaiproject/sakai
if (charset == null) charset = "UTF-8";
value = Xml.decode(charset,attributes.getValue("value"));
代码示例来源:origin: sakaiproject/sakai
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;
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
/**
* @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);
}
代码示例来源:origin: org.sakaiproject.assignment/sakai-assignment-impl
Document doc = Xml.readDocumentFromString(xml);
代码示例来源:origin: org.sakaiproject.common/archive-impl
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");
代码示例来源:origin: sakaiproject/sakai
/**
* 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;
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
/**
* {@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);
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
if (charset == null) charset = "UTF-8";
value = Xml.decode(charset, attributes.getValue("value"));
内容来源于网络,如有侵权,请联系作者删除!