/** * @return the handler registered for the subtag element of the curent XMLNode */ public XMLNode getHandlerFor(XMLElement element) { ExtensionElementNode subNode = new ExtensionElementNode(); DeploymentExtensionDescriptor o = (DeploymentExtensionDescriptor) getDescriptor(); o.addElement((ExtensionElementDescriptor) subNode.getDescriptor()); subNode.setXMLRootTag(new XMLElement(TagNames.EXTENSION_ELEMENT)); subNode.setParentNode(this); return subNode; }
/** * <p> * Append a new text child * </p> * @param parent for the new child element * @param elementName is the new element tag name * @param text the text for the new element * @result the newly create child node */ public Node appendTextChildNS(Node parent, String elementName, String text, Descriptor descriptor) { if (text == null || text.length()==0) return null; Node child = appendChildNS(parent, elementName, descriptor); child.appendChild(getOwnerDocument(child).createTextNode(text)); return child; }
/** * @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; }
Element node = appendChildNS(parentNode, tagName, descriptor); if (descriptor.hasAttributes()) { Map attributes = descriptor.getAttributes().getExtraAttributes(); if (key.indexOf(':')!=-1) { String prefix = key.substring(0, key.indexOf(':')); namespace = getNamespaceFor(descriptor, parentNode, prefix); addNamespaceDeclaration(node, descriptor); for (Iterator itr = descriptor.getElementNames();itr.hasNext();) { String elementName = (String) itr.next(); Object value = descriptor.getElement(elementName); if (value instanceof ExtensionElementDescriptor) { writeDescriptor(node, elementName, (ExtensionElementDescriptor) value); } else if (value instanceof String) { appendTextChildNS(node, elementName, (String) value, descriptor);
/** * 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; }
/** * <p> * Append a new element child to the current node * </p> * @param parentNode is the parent node for the new child element * @param elementName is new element tag name * @return the newly created child node */ public Element appendChildNS(Node parent, String elementName, Descriptor descriptor) { if (elementName.indexOf(':')!=-1) { String prefix = elementName.substring(0, elementName.indexOf(':')); elementName = elementName.substring(elementName.indexOf(':')+1); String namespace = getNamespaceFor(descriptor, parent, prefix); Element child = getOwnerDocument(parent).createElementNS(namespace, elementName); child.setPrefix(prefix); parent.appendChild(child); return child; } return super.appendChild(parent, elementName); }
/** * write the deployment extensions nodes associated with this node * * @param parent node for the DOM tree * @param iterator of deployment extension descriptor */ protected void writeDescriptor(Node parentNode, Iterator itr) { ExtensionElementNode subNode = new ExtensionElementNode(); do { DeploymentExtensionDescriptor descriptor = (DeploymentExtensionDescriptor) itr.next(); Element extensionNode = appendChild(parentNode, TagNames.DEPLOYMENT_EXTENSION); setAttribute(extensionNode, TagNames.NAMESPACE, descriptor.getNameSpace()); if (descriptor.getMustUnderstand()) { setAttribute(extensionNode, TagNames.MUST_UNDERSTAND, "true"); } for (Iterator elements = descriptor.elements();elements.hasNext();) { ExtensionElementDescriptor element = (ExtensionElementDescriptor) elements.next(); subNode.writeDescriptor(extensionNode, TagNames.EXTENSION_ELEMENT, element ); } } while(itr.hasNext()); } }