/** * @return the XML tag associated with this XMLNode */ protected XMLElement getXMLRootTag() { return new XMLElement(RuntimeTagNames.S1AS_APPCLIENT_RUNTIME_TAG); }
/** * register this node as a root node capable of loading entire DD files * * @param publicIDToDTD is a mapping between xml Public-ID to DTD * @return the doctype tag name */ public static String registerBundle(Map publicIDToDTD) { return tag.getQName(); }
/** * receives notification of the value for a particular tag * * @param element the xml element * @param value it's associated value */ public void setElementValue(XMLElement element, String value) { descriptor.addElement(element.getCompleteName(), value); }
<?xml version="1.0"?> <people> <person time="45.6" x="6.5" y="10.3"></person> ... </people> XMLElement xml; void setup() { size(200, 200); int size = 10; //just a default size for the ellipse, maybe you want to pull this value from your data as well though xml = new XMLElement(this, "people.xml"); int numPeople = xml.getChildCount(); for (int i = 0; i < numPeople; i++) { XMLElement person = xml.getChild(i); float time = person.getFloat("time"); float xPos = person.getFloat("x"); float yPos = person.getFloat("y"); int personColor = map(time, 0, 100, 0, 255); //you will need some way of mapping your time values (i have no idea what the scale is, to a range of 0-255 fill(personColor); ellipse(xPos, yPos, size, size); } }
/** * SAX Parser API implementation, we don't really care for now. */ public void startElement(XMLElement element, Attributes attributes) { //DOLUtils.getDefaultLogger().finer("STARTELEMENT : " + "in " + getXMLRootTag() + " Node, startElement " + element.getQName()); if (!this.getXMLRootTag().equals(element)) return; if (attributes.getLength()>0) { for (int i=0;i<attributes.getLength();i++) { if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) { DOLUtils.getDefaultLogger().finer("With attribute " + attributes.getQName(i)); DOLUtils.getDefaultLogger().finer("With value " + attributes.getValue(i)); } // we try the setAttributeValue first, if not processed then the setElement if (!setAttributeValue(element, new XMLElement(attributes.getQName(i)), attributes.getValue(i))) { setElementValue(new XMLElement(attributes.getQName(i)), attributes.getValue(i)); } } } }
/** * receives notification of the end of an XML element by the Parser * * @param element the xml tag identification * @return true if this node is done processing the XML sub tree */ public boolean endElement(XMLElement element) { boolean allDone = element.getCompleteName().equals(getXMLRootTag().getCompleteName()) || element.getQName().equals(TagNames.EXTENSION_ELEMENT); if (allDone) { postParsing(); ((DeploymentDescriptorNode) getParentNode()).addNodeDescriptor(this); } return allDone; }
/** * @return the handler registered for the subtag element of the curent XMLNode */ public XMLNode getHandlerFor(XMLElement element) { ExtensionElementNode subNode = new ExtensionElementNode(); subNode.setParentNode(this); subNode.setXMLRootTag(new XMLElement(element.getCompleteName())); return subNode; }
/** * receives notification of the end of an XML element by the Parser * * @param element the xml tag identification * @return true if this node is done processing the XML sub tree */ public boolean endElement(XMLElement element) { return element.equals(getXMLRootTag()); }
/** * Resolve a QName prefix to its corresponding Namespace URI by * searching up node chain starting with child. */ public String resolvePrefix(XMLElement element, String prefix) { // If prefix is empty string, returned namespace URI // is the default namespace. return element.getPrefixURIMapping(prefix); }
/** * SAX Parser API implementation, we don't really care for now. */ public void startElement(XMLElement element, Attributes attributes) { //DOLUtils.getDefaultLogger().finer("STARTELEMENT : " + "in " + getXMLRootTag() + " Node, startElement " + element.getQName()); if (!this.getXMLRootTag().equals(element)) return; if (attributes.getLength()>0) { for (int i=0;i<attributes.getLength();i++) { if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) { DOLUtils.getDefaultLogger().finer("With attribute " + attributes.getQName(i)); DOLUtils.getDefaultLogger().finer("With value " + attributes.getValue(i)); } // we try the setAttributeValue first, if not processed then the setElement if (!setAttributeValue(element, new XMLElement(attributes.getQName(i)), attributes.getValue(i))) { setElementValue(new XMLElement(attributes.getQName(i)), attributes.getValue(i)); } } } }
String value, Object o) { if (SCHEMA_LOCATION_TAG.equals(element.getCompleteName())) { } else if (element.getQName().equals(TagNames.METADATA_COMPLETE)) { if (o instanceof BundleDescriptor) { ((BundleDescriptor) o).setFullAttribute(value);
@Override public boolean endElement(XMLElement element) { return element.equals(getXMLRootTag()); }
/** * Resolve a QName prefix to its corresponding Namespace URI by * searching up node chain starting with child. */ public String resolvePrefix(XMLElement element, String prefix) { // If prefix is empty string, returned namespace URI // is the default namespace. return element.getPrefixURIMapping(prefix); }
/** * @return the XML tag associated with this XMLNode */ protected XMLElement getXMLRootTag() { return new XMLElement(RuntimeTagNames.S1AS_APPLICATION_RUNTIME_TAG); }
@Override public boolean equals(Object other ) { if (other instanceof XMLElement) { return qName.equals(((XMLElement) other).getQName()); } return false; }
if (SCHEMA_LOCATION_TAG.equals(element.getCompleteName())) { } else if (element.getQName().equals(TagNames.METADATA_COMPLETE)) { Object o = getDescriptor(); if (o instanceof BundleDescriptor) {
/** * receives notification of the value for a particular tag * * @param element the xml element * @param value it's associated value */ public void setElementValue(XMLElement element, String value) { if (element.equals(getXMLRootTag())) { localizedValue=value; } else super.setElementValue(element, value); }
/** * Adds a new DOL descriptor instance to the descriptor associated with this * XMLNode * * @param XMLNode the sub-node adding the descriptor; * @param descriptor the new descriptor */ protected void addNodeDescriptor(DeploymentDescriptorNode node) { // nodes are added upon creation ExtensionElementDescriptor dad = (ExtensionElementDescriptor) node.getDescriptor(); Iterator itr = dad.getElementNames(); // jump over first element; if (itr.hasNext()) itr.next(); if (itr.hasNext() && !dad.hasAttributes()) { descriptor.addElement(node.getXMLRootTag().getCompleteName(), dad); } else { descriptor.addElement(node.getXMLRootTag().getCompleteName(), dad.getElement(node.getXMLRootTag().getCompleteName())); } }
/** * @return the XML tag associated with this XMLNode */ protected XMLElement getXMLRootTag() { return new XMLElement(RuntimeTagNames.GF_APPCLIENT_RUNTIME_TAG); }
/** * @return true if the element tag can be handled by any registered sub nodes of the * current XMLNode */ public boolean handlesElement(XMLElement element) { if (TagNames.EXTENSION_ELEMENT.equals(element.getQName())) { return false; } return true; }