List of usage examples for org.w3c.dom Element getTagName
public String getTagName();
From source file:net.sourceforge.dita4publishers.impl.ditabos.DitaTreeWalkerBase.java
/** * @param bos//ww w .j av a 2s.c om * @param member * @throws Exception */ protected void walkMemberGetDependencies(BoundedObjectSet bos, BosMember member) throws Exception { if (!(member instanceof XmlBosMember)) { // Nothing to do for now. At some point should be able // to delegate to walker for non-XML objects. } else { Element elem = ((XmlBosMember) member).getElement(); this.walkedMembers.add(member); if (DitaUtil.isDitaMap(elem)) { walkMapGetDependencies(bos, (DitaMapBosMember) member); } else if (DitaUtil.isDitaTopic(elem) || DitaUtil.isDitaBase(elem)) { walkTopicGetDependencies(bos, (DitaTopicBosMember) member); } else { log.warn("XML Managed object of type \"" + elem.getTagName() + "\" is not recognized as a map or topic. Not examining for dependencies"); } } }
From source file:io.hummer.util.ws.WebServiceClient.java
private SOAPMessage createSOAPMessage(Element request, List<Element> headers, String protocol) throws Exception { MessageFactory mf = MessageFactory.newInstance(protocol); SOAPMessage message = mf.createMessage(); SOAPBody body = message.getSOAPBody(); // check if we have a complete soap:Envelope as request.. String ns = request.getNamespaceURI(); if (request.getTagName().contains("Envelope")) { if (ns.equals("http://schemas.xmlsoap.org/soap/envelope/")) message = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage( new MimeHeaders(), new ByteArrayInputStream(xmlUtil.toString(request).getBytes())); if (ns.equals("http://www.w3.org/2003/05/soap-envelope")) message = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage( new MimeHeaders(), new ByteArrayInputStream(xmlUtil.toString(request).getBytes())); } else {/*from ww w. j ava2s. c om*/ xmlUtil.appendChild(body, request); } for (Element h : headers) { xmlUtil.appendChild(message.getSOAPHeader(), h); } for (Element h : eprParamsAndProps) { xmlUtil.appendChild(message.getSOAPHeader(), h); } xmlUtil.appendChild(message.getSOAPHeader(), xmlUtil.toElement( "<wsa:To xmlns:wsa=\"" + EndpointReference.NS_WS_ADDRESSING + "\">" + endpointURL + "</wsa:To>")); message.saveChanges(); return message; }
From source file:com.bluexml.xforms.controller.mapping.MappingToolClassFormsToAlfresco.java
/** * Fill alfresco class./*w w w. ja v a 2 s . co m*/ * * @param login * the login * @param alfrescoClass * the alfresco class * @param xformsNode * the xforms node * @param isServletRequest */ private void fillAlfrescoClass(GenericClass alfrescoClass, Node xformsNode, boolean isServletRequest, Map<String, String> initParams) { Element element = null; if (xformsNode instanceof Document) { element = ((Document) xformsNode).getDocumentElement(); } else { element = (Element) xformsNode; } List<Element> children = DOMUtil.getAllChildren(element); ClassType classType = null; Element sideDataType = DOMUtil.getOneElementByTagName(children, MsgId.INT_INSTANCE_SIDE_DATATYPE.getText()); if (sideDataType != null) { classType = getClassType(sideDataType.getTextContent()); } else { classType = getClassType(element.getTagName()); } alfrescoClass.setQualifiedName(classType.getAlfrescoName()); List<ClassType> classTypes = getParentClassTypes(classType); GenericAttributes attributes = alfrescoObjectFactory.createGenericAttributes(); GenericAssociations associations = alfrescoObjectFactory.createGenericAssociations(); associations.setAction("replace"); for (ClassType subClassType : classTypes) { xformsAttributesToAlfresco(attributes, children, subClassType, isServletRequest, initParams); xformsAssociationsToAlfresco(associations, children, subClassType); } alfrescoClass.setAttributes(attributes); alfrescoClass.setAssociations(associations); String elementId = xformsIdToAlfresco(children); if (elementId != null) { alfrescoClass.setId(elementId); } }
From source file:com.hp.saas.agm.core.entity.EntityQuery.java
public synchronized void fromElement(Element element) { setName(element.getAttribute("name")); Element filter = null;/* ww w. ja va 2 s . c om*/ Element cross = null; Element orderBy = null; Element viewing = null; for (Element child : (List<Element>) element.getChildNodes()) { if (child.getLocalName() == "filter") { filter = child; } if (child.getLocalName() == "crossFilter") { cross = child; } if (child.getLocalName() == "order") { orderBy = child; } if (child.getLocalName() == "view") { viewing = child; } } if (filter != null) { super.fromElement(filter); } if (cross != null) { this.cross.clear(); for (Element child : (List<Element>) cross.getChildNodes()) { EntityCrossFilter cf = new EntityCrossFilter(child.getTagName()); cf.fromElement(child); String alias = child.getAttribute("alias"); if (alias == null) { alias = child.getLocalName(); } this.cross.put(alias, cf); } } //Element orderBy = element.getChild("order"); if (orderBy != null) { order.clear(); for (Element child : (List<Element>) orderBy.getChildNodes()) { order.put(child.getLocalName(), SortOrder.valueOf(child.getAttribute("dir"))); } } if (viewing != null) { view.clear(); for (Element child : (List<Element>) viewing.getChildNodes()) { if (child.getLocalName() == "column") { view.put(child.getAttribute("name"), Integer.valueOf(child.getAttribute("width"))); } } } }
From source file:com.pari.nm.modules.jobs.PcbImportJob.java
private void populateVoIPPhones(String voipPhoneList) { try {/*w w w . jav a 2 s . c o m*/ InputStream fin = new ByteArrayInputStream(voipPhoneList.getBytes()); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = docBuilder.parse(fin); Element docRoot = doc.getDocumentElement(); if (!docRoot.getTagName().equals("VoipPhoneList")) { throw new Exception("Invalid format. Expecting: VoipPhoneList, found " + docRoot.getTagName()); } HashMap<Integer, ArrayList<VoipPhone>> phonesMap = new HashMap<Integer, ArrayList<VoipPhone>>(); ConcurrentHashMap<String, Integer> custIpMap = CustomerManager.getInstance() .getCustomerIpMap(customerId); List<Element> phoneElementList = XMLUtil.getFirstLevelChildElementsByTagName(docRoot, "VoipPhone"); if ((phoneElementList != null) && (phoneElementList.size() > 0) && (custIpMap != null) && (custIpMap.size() > 0)) { for (Element voipPhoneElem : phoneElementList) { VoipPhone phone = new VoipPhone(); String ipAddress = XMLUtil.getChildText(voipPhoneElem, "IpAddress"); if (ipAddress != null) { phone.setIpAddress(ipAddress.trim()); } String phoneModel = XMLUtil.getChildText(voipPhoneElem, "PhoneModel"); if (phoneModel != null) { phone.setModel(phoneModel.trim()); } String vendorName = XMLUtil.getChildText(voipPhoneElem, "VendorName"); if (vendorName != null) { phone.setVendorName(vendorName.trim()); } String macAddress = XMLUtil.getChildText(voipPhoneElem, "MACAddress"); if (macAddress != null) { phone.setMacAddress(macAddress.trim()); } String switchInterface = XMLUtil.getChildText(voipPhoneElem, "SwitchInterface"); if (switchInterface != null) { phone.setSwitchInterface(switchInterface.trim()); } String serialNumber = XMLUtil.getChildText(voipPhoneElem, "SerialNumber"); if (serialNumber != null) { phone.setSerialNumber(serialNumber.trim()); } String userName = XMLUtil.getChildText(voipPhoneElem, "UserName"); if (userName != null) { phone.setUserName(userName.trim()); } String extension = XMLUtil.getChildText(voipPhoneElem, "UserName"); if (extension != null) { phone.setPhoneNumber(extension.trim()); } String switchIpAddress = XMLUtil.getChildText(voipPhoneElem, "SwitchIpAddress"); Integer deviceId = custIpMap.get(switchIpAddress); if ((deviceId != null) && (deviceId.intValue() != -1)) { phone.setSwitchNodeId(deviceId); ArrayList<VoipPhone> phonesList = phonesMap.get(deviceId); if (phonesList == null) { phonesList = new ArrayList<VoipPhone>(); phonesMap.put(deviceId, phonesList); } phonesList.add(phone); } } } if (phonesMap.size() > 0) { try { VOIPDBHelper.saveVOIPPhones(customerId, instanceId, phonesMap); } catch (Exception ex) { logger.warn("Error while saving VOIP Phones for the customer: " + customerId + " instance=" + instanceId, ex); } } } catch (Exception ex) { logger.warn( "Error while saving VOIP Phones for the customer: " + customerId + " instance=" + instanceId, ex); } }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
/** * Used to add address to Veterinarian, Origin and Destination * @param e//w ww .jav a 2 s . c o m * @param sStreet * @param sCity * @param sState * @param sZip * @return */ public Element setAddress(Element e, String sStreet, String sCity, String sState, String sZip) { if (!isValidDoc()) return null; Element address = null; if (e != null) { address = getAddress(e, sStreet, sCity, sState, sZip); if (address != null) return address; address = childElementByName(e, "Address"); if (address == null) { String sElement = e.getTagName(); Node nPerson = null; if (!"Veterinarian".equals(sElement)) { nPerson = childNodeByName(e, "Person"); } address = doc.createElement("Address"); e.insertBefore(address, nPerson); } Node line1 = childNodeByName(address, "Line1"); if (line1 == null) { line1 = doc.createElement("Line1"); address.appendChild(line1); } if (sStreet != null) { line1.setTextContent(sStreet.trim()); } else { line1.setTextContent(""); } Node town = childNodeByName(address, "Town"); if (town == null) { town = doc.createElement("Town"); address.appendChild(town); } if (sCity != null) { town.setTextContent(sCity.trim()); } else { town.setTextContent("Not Provided"); } Node state = childNodeByName(address, "State"); if (state == null) { state = doc.createElement("State"); address.appendChild(state); } if (sState != null) { state.setTextContent(sState.trim()); } else { logger.error("Attempt to add address with no state.", new Exception()); state.setTextContent("ERROR"); } Node zip = childNodeByName(address, "ZIP"); if (zip == null) { zip = doc.createElement("ZIP"); address.appendChild(zip); } if (sZip != null && sZip.trim().length() > 0) { zip.setTextContent(sZip.trim()); } else { zip.setTextContent("00000"); } Node country = childNodeByName(address, "Country"); if (country == null) { country = doc.createElement("Country"); address.appendChild(country); } country.setTextContent("USA"); } return address; }
From source file:jp.co.acroquest.jsonic.Formatter.java
public boolean format(final JSON json, final Context context, final Object src, final Object o, final OutputSource out) throws Exception { Element elem = (Element) o; out.append('['); StringFormatter.serialize(context, elem.getTagName(), out); out.append(','); if (context.isPrettyPrint()) { out.append('\n'); for (int j = 0; j < context.getDepth() + 1; j++) out.append('\t'); }/*from w w w. j av a 2 s.c om*/ out.append('{'); if (elem.hasAttributes()) { NamedNodeMap names = elem.getAttributes(); for (int i = 0; i < names.getLength(); i++) { if (i != 0) { out.append(','); } if (context.isPrettyPrint() && names.getLength() > 1) { out.append('\n'); for (int j = 0; j < context.getDepth() + 2; j++) out.append('\t'); } Node node = names.item(i); if (node instanceof Attr) { StringFormatter.serialize(context, node.getNodeName(), out); out.append(':'); if (context.isPrettyPrint()) out.append(' '); StringFormatter.serialize(context, node.getNodeValue(), out); } } if (context.isPrettyPrint() && names.getLength() > 1) { out.append('\n'); for (int j = 0; j < context.getDepth() + 1; j++) out.append('\t'); } } out.append('}'); if (elem.hasChildNodes()) { NodeList nodes = elem.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Object value = nodes.item(i); if ((value instanceof Element) || (value instanceof CharacterData && !(value instanceof Comment))) { out.append(','); if (context.isPrettyPrint()) { out.append('\n'); for (int j = 0; j < context.getDepth() + 1; j++) out.append('\t'); } context.enter(i + 2); value = json.preformatInternal(context, value); json.formatInternal(context, value, out); context.exit(); if (out instanceof Flushable) ((Flushable) out).flush(); } } } if (context.isPrettyPrint()) { out.append('\n'); for (int j = 0; j < context.getDepth(); j++) out.append('\t'); } out.append(']'); return true; }
From source file:com.bluexml.xforms.controller.mapping.MappingToolClassFormsToAlfresco.java
/** * Removes the reference.//w w w . j a v a 2s .c o m * * @param node * the node * @param elementId * the element id */ public void removeReference(Node node, String elementId) { String relementId = controller.patchDataId(elementId); Element element = null; if (node instanceof Document) { element = ((Document) node).getDocumentElement(); } else { if (node instanceof Element) { element = (Element) node; } else { throw new RuntimeException("Unknow type of DOM node element"); } } List<Element> children = DOMUtil.getAllChildren(element); ClassType classType = null; Element dataType = DOMUtil.getOneElementByTagName(children, MsgId.INT_INSTANCE_SIDE_DATATYPE.getText()); if (dataType != null) { classType = getClassType(dataType.getTextContent()); } else { classType = getClassType(element.getTagName()); } List<ClassType> classTypes = getParentClassTypes(classType); List<Element> elementsToRemove = new ArrayList<Element>(); for (ClassType subClassType : classTypes) { List<AssociationType> xformsAssociations = subClassType.getAssociation(); for (AssociationType associationType : xformsAssociations) { Element associationElement = DOMUtil.getOneElementByTagName(children, associationType.getName()); if (associationElement != null) { List<Element> associationElements = DOMUtil.getAllChildren(associationElement); for (Element association : associationElements) { processRemoveReference(relementId, elementsToRemove, associationType, association, isMultiple(associationType)); } } } } for (Element elementToRemove : elementsToRemove) { element.removeChild(elementToRemove); } }
From source file:com.bluexml.xforms.controller.navigation.NavigationManager.java
/** * Adds the actions.// w ww . j a v a 2s . co m * * @param actionsDocument * the actions document * @param classes * the classes * @deprecated */ @Deprecated @SuppressWarnings("unused") private void addActions(Document actionsDocument, List<Class<?>> classes) { NodeList actionNodes = actionsDocument.getDocumentElement().getChildNodes(); for (int i = 0; i < actionNodes.getLength(); i++) { Node item = actionNodes.item(i); if (item instanceof Element) { Element action = (Element) item; if (action.getTagName().equals("action")) { String className = null; NodeList childNodes = action.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); if (childNode instanceof Element) { Element subElement = (Element) childNode; if (subElement.getTagName().equals("class")) { className = StringUtils.trimToNull(subElement.getTextContent()); } } } if (className != null) { try { Class<?> actionClassName = Class.forName(className); classes.add(actionClassName); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error(e); } } } } } } }
From source file:com.bluexml.xforms.controller.navigation.NavigationManager.java
/** * Removes a specific submit button from the group of submit buttons. * /*from w w w . j a v a2 s .c o m*/ * @param docElt * @param buttonId */ private void removeSubmitButton(Element docElt, MsgId buttonId) { String realCaption = MsgPool.getMsg(buttonId); Element button = null; // find the group of submits String groupId = MsgId.INT_SUBMIT_BUTTONS_GROUP_ID.getText(); Element submitGroup = DOMUtil.getEltInDescentByAttrValue(docElt, "id", groupId); // find the "xf:submit" node that has the right caption in its // "xf:label" List<Element> listOfSubmits = DOMUtil.getAllChildren(submitGroup); for (Element aSubmit : listOfSubmits) { if (StringUtils.equals(aSubmit.getTagName(), "xf:submit")) { Element label = DOMUtil.getChild(aSubmit, "xf:label"); if (StringUtils.equals(label.getTextContent(), realCaption)) { button = aSubmit; break; } } } if (button != null) { submitGroup.removeChild(button); } }