本文整理汇总了Java中com.google.gwt.xml.client.XMLParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java XMLParser.parse方法的具体用法?Java XMLParser.parse怎么用?Java XMLParser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.xml.client.XMLParser
的用法示例。
在下文中一共展示了XMLParser.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: XmlDocument
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public XmlDocument(String url, DocumentLoadCallback<Document> callback) {
this.callback = callback;
this.url = url;
new TextDocument(this.url, new DocumentLoadCallback<String>() {
@Override
public void loadingError(String message) {
XmlDocument.this.callback.loadingError(message);
}
@Override
public void finishedLoading(String text, String baseUrl) {
try {
Document dom = XMLParser.parse(text);
XmlDocument.this.callback.finishedLoading(dom, baseUrl);
} catch (DOMParseException e) {
e.printStackTrace();
XmlDocument.this.callback.loadingError("Could not parse file: " + XmlDocument.this.url);
}
}
});
}
示例2: testXmlProcessing
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public void testXmlProcessing() {
Document doc = XMLParser
.parse("<nodes><responseDeclaration identifier='RESPONSE' cardinality='multiple' baseType='identifier'><correctResponse><value>ChoiceA</value></correctResponse></responseDeclaration></nodes>");
VariableManager<CustomVariable> vm = new VariableManager<CustomVariable>(doc.getDocumentElement().getChildNodes(),
new IVariableCreator<CustomVariable>() {
@Override
public CustomVariable createVariable(Node node) {
assertTrue(node.getNodeType() == Node.ELEMENT_NODE);
Element el = (Element) node;
String identifier = el.getAttribute("identifier");
assertEquals("RESPONSE", identifier);
return new CustomVariable();
}
}
);
assertTrue(vm.getVariableIdentifiers().size() == 1);
assertTrue(vm.getVariable("RESPONSE") instanceof CustomVariable);
}
示例3: parse
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
/**
* @param wadlXmlString
*/
public void parse(String wadlXmlString) {
// remove unnecessary whitespaces
wadlXmlString = wadlXmlString.replaceAll(">\\s*<", "><");
// remove <!-- comment nodes -->
wadlXmlString = wadlXmlString.replaceAll("<!--.*?-->", "");
try {
// reset the application
GuiFactory.resetApplication();
Document wadl = XMLParser.parse(wadlXmlString);
if (startParsing(wadl)) {
uploadDialogBox.setVisible(true);
uploadDialogBox.hide();
// if the parsing succeeded render a tree from the parsed wadl
WadlTreeRoot wadlTreeRoot = new WadlTreeRoot();
Tree wadlTree = wadlTreeRoot.buildTree(application);
WadlPanel.wadlArea.setWidget(wadlTree);
GuiFactory.toggleButtonsEnabled(true);
WadlPanel.fullscreenButton.click();
}
} catch (DOMParseException e) {
alertInvalidWadlAndRetry(GuiFactory.strings.invalidWadl());
}
}
示例4: deserializeAsCollection
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
/**
* Deserialize the plain text into an object of type T.
*
* @param collectionType The class of the collection
* @param response Http response body content
* @param context Context of deserialization
*
* @return The object deserialized
*/
@Override
public <C extends Collection<Book>> C deserializeAsCollection(Class<C> collectionType, String response,
DeserializationContext context) {
C col = context.getContainerInstance(collectionType);
Document xml;
try {
xml = XMLParser.parse(response);
} catch (DOMParseException e) {
throw new UnableToDeserializeException("Could not read response as xml.", e);
}
Collections.addAll(col, parseXmlDocumentAsBook(xml));
return col;
}
示例5: parse
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public void parse(InputStream is) throws SAXException {
StringBuilder sb = new StringBuilder();
byte[] buf = new byte[8192];
int read;
try {
while ((read = is.read(buf)) >= 0) {
if (read > 0)
sb.append(new String(buf, 0, read));
}
} catch (IOException e) {
e.printStackTrace();
}
Document d = XMLParser.parse(sb.toString());
handleElement(d.getFirstChild());
mHandler.endDocument();
}
示例6: processLoad
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
protected void processLoad(DataSourceManager dsm, String itemXml) {
String assessmentXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><assessmentTest xmlns=\"http://www.ydp.eu/empiria\" identifier=\"RTEST-13\" title=\"Show player supported functionality\"><testPart><assessmentSection identifier=\"sectionA\" title=\"Section A\" visible=\"true\"><assessmentItemRef identifier=\"inline_choice\" href=\"demo/inline_choice.xml\"/></assessmentSection></testPart></assessmentTest>";
Document assessmentDoc = XMLParser.parse(assessmentXml);
XmlData assessmentData = new XmlData(assessmentDoc, "");
Document itemDoc = XMLParser.parse(itemXml);
XmlData itemData = new XmlData(itemDoc, "");
XmlData[] itemDatas = new XmlData[1];
itemDatas[0] = itemData;
dsm.loadData(assessmentData, itemDatas);
}
示例7: getItemXMLDatas
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
protected XmlData[] getItemXMLDatas() {
Document itemDoc = XMLParser
.parse("<assessmentItem identifier=\"inlineChoice\" title=\"Interactive text\"><itemBody></itemBody><variableProcessing template=\"default\"/></assessmentItem>");
XmlData itemData = new XmlData(itemDoc, "");
XmlData[] itemDatas = new XmlData[1];
itemDatas[0] = itemData;
return itemDatas;
}
示例8: getItemXMLDatas
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
protected XmlData[] getItemXMLDatas() {
Document itemDoc = XMLParser
.parse("<assessmentItem identifier=\"inlineChoice\" title=\"Interactive text\"><itemBody></itemBody><variableProcessing template=\"default\"/></assessmentItem>");
XmlData itemData = new XmlData(itemDoc, "");
Document itemDoc2 = XMLParser
.parse("<assessmentItem identifier=\"inlineChoice2\" title=\"Interactive text 2\"><itemBody></itemBody><variableProcessing template=\"default\"/></assessmentItem>");
XmlData itemData2 = new XmlData(itemDoc2, "");
XmlData[] itemDatas = new XmlData[2];
itemDatas[0] = itemData;
itemDatas[1] = itemData2;
return itemDatas;
}
示例9: isExecutionCalendarGIDefined
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
private Boolean isExecutionCalendarGIDefined(String jobDescriptor) {
Document dom = XMLParser.parse(jobDescriptor);
Boolean exists = false;
Boolean executionCalendarDefined = false;
NodeList genericInfo = dom.getElementsByTagName("genericInformation");
// check if the job has genericInformation or not
if (genericInfo != null && genericInfo.getLength() > 0) {
// get the first item
Node root = genericInfo.item(0);
NodeList list = root.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeName().equals("info") && node.hasAttributes()) {
NamedNodeMap attributes = node.getAttributes();
for (int j = 0; j < attributes.getLength(); j++) {
Node attribute = attributes.item(j);
if (attribute.getNodeType() == Node.ATTRIBUTE_NODE && attribute.getNodeName().equals("name") &&
attribute.getNodeValue().equalsIgnoreCase("execution_calendars")) {
exists = true;
}
if (isAttributeExecCalendarValueDefined(attribute, "value") && exists) {
executionCalendarDefined = true;
if (!attribute.getNodeValue().isEmpty())
isExecCalendarValueNull = false;
}
}
}
}
}
return executionCalendarDefined;
}
示例10: parse
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public static GWT_GraphQuery parse(String xml) {
GWT_GraphQuery q = null;
Document doc = XMLParser.parse(xml);
NodeList list = doc.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node item = list.item(i);
if (item.getNodeName().equals(GRAPH_QUERY)) {
q = new GWT_GraphQuery();
parseSelectors(q, item);
}
}
return(q);
}
示例11: validate
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public String validate(String code) {
try {
XMLParser.parse(code);
return null;
} catch (Exception e) {
return e.getMessage();
}
}
示例12: parseServiceDataXml
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
public static void parseServiceDataXml(String serviceDataXmlString) {
errorStatuses.clear();
schemaLocations.clear();
defaultNamespace.clear();
otherNamespaces.clear();
Document response = XMLParser.parse(serviceDataXmlString);
NodeList namespaces = response.getElementsByTagName("namespace");
for (int i = 0; i < namespaces.getLength(); i++) {
Node namespace = namespaces.item(i);
if (namespace.hasChildNodes()) {
String namespaceString = namespace.getFirstChild().getNodeValue();
if ((!otherNamespaces.contains(namespaceString)) &&
(!namespaceString.equals(WadlXml.xmlns_xsd)) &&
(!namespaceString.equals(WadlXml.xmlns_xsi))) {
otherNamespaces.add(namespaceString);
}
}
}
NodeList requests = response.getElementsByTagName("requestData");
for (int i = 0; i < requests.getLength(); i++) {
Node request = requests.item(i);
NodeList requestChildren = request.getChildNodes();
for (int j = 0; j < requestChildren.getLength(); j++) {
Node requestChild = requestChildren.item(j);
if (requestChild.getNodeName().equals("validRequest")) {
treatValidRequests(requestChild);
}
else if (requestChild.getNodeName().equals("erroneousRequests")) {
treatErroneousRequests(requestChild);
}
}
}
show();
}
示例13: deserialize
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
/**
* Deserialize the plain text into an object of type T.
*
* @param response Http response body content
* @param context Context of deserialization
*
* @return The object deserialized
*/
@Override
public Book deserialize(String response, DeserializationContext context) {
Document xml;
try {
xml = XMLParser.parse(response);
} catch (DOMParseException e) {
throw new UnableToDeserializeException("Could not read response as xml.", e);
}
return parseXmlDocumentAsBook(xml)[0];
}
示例14: createElement
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
/**
* Creates a element with the given tagname and namespace.
* @param tagname The tagname of the new element.
* @param namespace The namespace of the new element.
* @return The newly created element.
*/
public static Element createElement(String tagname, String namespace) {
StringBuilder builder = new StringBuilder();
builder.append("<")
.append(tagname)
.append(" xmlns='")
.append(namespace)
.append("' />");
Document doc = XMLParser.parse(builder.toString());
return doc.getDocumentElement();
}
示例15: parseXMLStringToElement
import com.google.gwt.xml.client.XMLParser; //导入方法依赖的package包/类
/**
* Parses an xml-string to an element.
* @param docXML The xml-string.
* @return The new element.
*/
public static Element parseXMLStringToElement(String docXML) {
try {
Document doc = XMLParser.parse(docXML);
return doc.getDocumentElement();
} catch (Exception e) {
return null;
}
}