com.google.gwt.xml.client.XMLParser Java Examples

The following examples show how to use com.google.gwt.xml.client.XMLParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlDebugPanel.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public XmlDebugPanel(TreeTableModel model) {
  this.model = model;
  nodes = new IdentityHashMap<Object, Element>();
  document = XMLParser.createDocument();
  root = document.createElement("debug-panel");
  initWidget(textArea = new TextArea());
  textArea.ensureDebugId("debug-panel-xml");
  textArea.setStyleName(Utils.style() + "-xml");

  // Build the XML document based on the current state.
  document.appendChild(root);
  nodes.put(model.getRoot(), root);
  build(model.getRoot());

  model.addTreeTableModelListener(this);
}
 
Example #2
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Dialog unmarshall(String xml)
{

    try {
        Document document = XMLParser.parse(xml);
        Element root = document.getDocumentElement();

        // model
        Builder builder = new Builder();
        dfsElement(builder, DOMUtils.getFirstChildElement(root));

        // dialog
        Dialog dialog = new Dialog(new QName(root.getNamespaceURI(), root.getAttribute("id")), builder.build());

        return dialog;
    } catch (RuntimeException e) {
        Window.alert("Faile to parse XML: "+e.getMessage());
        throw e;
    }
}
 
Example #3
Source File: YaBlocksEditor.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public Set<String> getBlockTypeSet() {
  Set<String> blockTypes = new HashSet<String>();
  String xmlString = blocksArea.getBlocksContent();
  Document blockDoc = XMLParser.parse(xmlString);
  NodeList blockElements = blockDoc.getElementsByTagName("block");
  for (int i = 0; i < blockElements.getLength(); ++i) {
    Element blockElem = (Element) blockElements.item(i);
    blockTypes.add(blockElem.getAttribute("type"));
  }
  return blockTypes;
}
 
Example #4
Source File: DefaultHtmlValidator.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
public String validate(String code) {
    try {
        XMLParser.parse(code);
        return null;
    } catch (Exception e) {
        return e.getMessage();
    }
}
 
Example #5
Source File: BookXmlSerdes.java    From requestor with Apache License 2.0 5 votes vote down vote up
@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];
}
 
Example #6
Source File: BookXmlSerdes.java    From requestor with Apache License 2.0 5 votes vote down vote up
@Override
public <C extends Collection<Book>> C deserialize(Class<C> collectionType, String response,
                                                  DeserializationContext context) {
    C col = context.getInstance(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;
}
 
Example #7
Source File: GwtMqlEditor.java    From mql-editor with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void loadOverlay( String xul ) {

    com.google.gwt.xml.client.Document gwtDoc = XMLParser.parse( xul );
    try {
      container.loadOverlay( gwtDoc );

    } catch ( Exception e ) {
      e.printStackTrace();
    }
    displayXulDialog();
  }
 
Example #8
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestRun read(String s) {

		Document doc = XMLParser.parse(s);
		TestRun tr = new TestRun();

		Element run = doc.getDocumentElement();

		NodeList runChildren = run.getChildNodes();
		for (int i = 0; i < runChildren.getLength(); i++) {
			Node runChild = runChildren.item(i);
			String name = runChild.getNodeName();

			switch (name) {
			case "desc":
				tr.description = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "precisionModel":
				tr.precisionModel = trim(((Element) runChild)
						.getAttribute("type"));
				break;
			case "resultMatcher":
				tr.resultMatcher = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "geometryOperation":
				tr.geometryOperation = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "case":
				TestCase tc = new TestCase();
				tr.testCases.add(tc);
				parseTestCase(runChild, tc);
				break;
			default:
				// sLogger.severe("-------" + name + "-------");
				break;
			}
		}

		return tr;
	}
 
Example #9
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
DMRMarshallRoutine(Dialog dialog) {
    this.dialog = dialog;
    this.document = XMLParser.createDocument();
}