List of usage examples for com.google.gwt.dom.client Element getNodeValue
@Override
public String getNodeValue()
From source file:org.gwtopenmaps.demo.openlayers.client.examples.format.xml.XMLFormatExample.java
License:Apache License
@Override public void buildPanel() { contentPanel.add(new HTML("Shows the use of the OpenLayers XML format class<br/>" + "OpenLayers has a very simple XML format class (OpenLayers.Format.XML) " + "that can be used to read/write XML docs. The methods available on the " + "XML format (or parser if you like) allow for reading and writing of " + "the various XML flavors used by the library - in particular the vector " + "data formats. It is by no means intended to be a full-fledged XML toolset. " + "Additional methods will be added only as needed elsewhere in the library.<br/>" + "This page loads an XML document and demonstrates a few of the methods available in the parser.")); final Label outputValue = new Label(); HorizontalPanel panel = new HorizontalPanel(); Label statusLabel = new Label("Status : "); final InlineHTML statusLabelValue = new InlineHTML(); statusLabelValue.setHTML("<strong>XML document loaded</strong>."); panel.add(statusLabel);/*from w w w.j a va 2 s. c om*/ panel.add(statusLabelValue); contentPanel.add(panel); contentPanel.add(new HTML("<p>After the XML document loads, see the result " + "of a few of the methods below. Assume that you start with the " + "following code: <br/>" + "var format = new OpenLayers.Format.XML();</p>" + "Sample methods")); VerticalPanel vp = new VerticalPanel(); GwtOpenLayersULComponent uLComponent = new GwtOpenLayersULComponent(); HorizontalPanel wp = new HorizontalPanel(); Anchor write = new Anchor(); write.setHTML("format.write()"); wp.add(write); wp.add(new Label(" - write the XML doc as text")); write.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(wp); HorizontalPanel ebyTagNames = new HorizontalPanel(); Anchor tagNames = new Anchor(); tagNames.setHTML("format.getElementsByTagNameNS()"); ebyTagNames.add(tagNames); ebyTagNames.add(new Label(" - get all gml:MultiPolygon")); tagNames.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { NodeList elements = xmlFormat.getElementsByTagNameNS(baseEl.getDocumentElement(), "http://www.opengis.net/gml", "MultiPolygon"); StringBuilder builder = new StringBuilder(); for (int i = 0; i < elements.getLength(); i++) { builder.append(xmlFormat.write(elements.getItem(i))); } outputValue.setText(builder.toString()); } }); uLComponent.add(ebyTagNames); HorizontalPanel hasAttributePanel = new HorizontalPanel(); Anchor hasAttAnchor = new Anchor(); hasAttAnchor.setHTML("format.hasAttributeNS()"); hasAttributePanel.add(hasAttAnchor); hasAttributePanel.add(new Label(" - test to see schemaLocation " + "attribute exists in the http://www.w3.org/2001/XMLSchema-instance namespace")); hasAttAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(String.valueOf(xmlFormat.hasAttributeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"))); } }); uLComponent.add(hasAttributePanel); vp.add(uLComponent); HorizontalPanel getAttrNodeNSPanel = new HorizontalPanel(); Anchor getAttrNodeNSAnchor = new Anchor(); getAttrNodeNSAnchor.setHTML("format.getAttributeNodeNS()"); getAttrNodeNSPanel.add(getAttrNodeNSAnchor); getAttrNodeNSPanel.add(new Label( " - get schemaLocation attribute in " + "the http://www.w3.org/2001/XMLSchema-instance namespace")); getAttrNodeNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.getAttributeNodeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); outputValue.setText(e.getNodeName() + " = " + e.getNodeValue()); } }); uLComponent.add(getAttrNodeNSPanel); HorizontalPanel getAttrNSHorizontalPanel = new HorizontalPanel(); Anchor getAttrNSAnchor = new Anchor(); getAttrNSAnchor.setHTML("format.getAttributeNS()"); getAttrNSHorizontalPanel.add(getAttrNSAnchor); getAttrNSHorizontalPanel.add(new Label(" - get schemaLocation " + "attribute value in the http://www.w3.org/2001/" + "XMLSchema-instance namespace")); getAttrNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(xmlFormat.getAttributeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation")); } }); uLComponent.add(getAttrNSHorizontalPanel); HorizontalPanel createElNSPanel = new HorizontalPanel(); Anchor createElNSAnchor = new Anchor(); createElNSAnchor.setHTML("format.createElementNS()"); createElNSPanel.add(createElNSAnchor); createElNSPanel.add(new Label(" - create a foo:TestNode element" + " (and append it to the doc)")); createElNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.createElementNS("http://bar.com/foo", "foo:TestNode"); baseEl.getDocumentElement().appendChild(e); outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(createElNSPanel); HorizontalPanel createTextNodePanel = new HorizontalPanel(); Anchor createTextNodeAnchor = new Anchor(); createTextNodeAnchor.setHTML("format.createTextNode()"); createTextNodePanel.add(createTextNodeAnchor); createTextNodePanel.add(new Label(" - create a text node" + " (and append it to the doc)")); createTextNodeAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.createTextNode("test text "); baseEl.getDocumentElement().appendChild(e); outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(createTextNodePanel); contentPanel.add(vp); contentPanel.add(new InlineHTML("<strong>Output</strong> :")); contentPanel.add(outputValue); initWidget(contentPanel); }
From source file:org.primordion.xholon.service.svg.SvgViewBrowser.java
License:Open Source License
/** * Blank out the values of Tspan elements in a subtree. * @param svgElement The root element in the subtree. *//*ww w. ja v a2 s .c o m*/ protected void initNumericText(Object svgElement) { Element ele = (Element) svgElement; if ("tspan".equals(ele.getNodeName())) { String text = ele.getNodeValue(); if (!text.isEmpty() && Misc.isdigit(text.charAt(0) - '0')) { setText(ele, ""); } } Node node = ele.getFirstChild(); while (node != null) { initNumericText(node); node = node.getNextSibling(); } }