private void readEmployeeList(NurseRoster nurseRoster, Element employeesElement) throws JDOMException { List<Element> employeeElementList = (List<Element>) employeesElement.getChildren(); List<Employee> employeeList = new ArrayList<>(employeeElementList.size()); employeeMap = new HashMap<>(employeeElementList.size()); Employee employee = new Employee(); employee.setId(id); employee.setCode(element.getAttribute("ID").getValue()); employee.setName(element.getChild("Name").getText()); Element contractElement = element.getChild("ContractID"); Contract contract = contractMap.get(contractElement.getText());
public List operate(Object node) { if (node instanceof Element) { Element element = (Element) node; return Collections.singletonList(element.getNamespace().getURI() + element.getName()); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName()); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_cname can not be applied on " + node.getClass()); } }
Element e = (Element) node; if (localName == null) { result.addAll(e.getAttributes()); } else { Attribute attr = e.getAttribute(localName, Namespace.getNamespace("", namespaceUri)); if (attr != null) { result.add(attr); ProcessingInstruction pi = (ProcessingInstruction) node; if ("target".equals(localName)) { result.add(new Attribute("target", pi.getTarget())); } else if ("data".equals(localName)) { result.add(new Attribute("data", pi.getData())); } else { result.add(new Attribute(localName, pi.getValue(localName))); result.add(new Attribute("publicId", doctype.getPublicID())); } else if ("systemId".equals(localName)) { result.add(new Attribute("systemId", doctype.getSystemID())); } else if ("elementName".equals(localName)) { result.add(new Attribute("elementName", doctype.getElementName()));
public String getAttributeQName(Object obj) { Attribute attr = (Attribute) obj; String prefix = attr.getNamespacePrefix(); if ( prefix == null || "".equals( prefix ) ) { return attr.getName(); } return prefix + ":" + attr.getName(); }
public void output(Attribute attribute, Writer out) throws IOException { out.write(" "); out.write(attribute.getQualifiedName()); out.write("="); out.write("\""); out.write(escapeAttributeEntities(attribute.getValue())); out.write("\""); } }
public boolean isMyType(Document document) { boolean ok; Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) { ok = false; Attribute version = rssRoot.getAttribute("version"); if (version!=null) { ok = version.getValue().equals(getRSSVersion()); } } return ok; }
protected Element generateSourceElement(Source source) { Element sourceElement = new Element("source",getFeedNamespace()); if (source.getUrl() != null) { sourceElement.setAttribute(new Attribute("url", source.getUrl())); } sourceElement.addContent(source.getValue()); return sourceElement; }
@Override public String writeGroup(Group group) throws ExportException { Namespace ns = Namespace.getNamespace(USERCATALOG_NAMESPACE_PREFIX, USERCATALOG_NAMESPACE); Namespace nsXsi = Namespace.getNamespace(XSI_NAMESPACE_PREFIX, XSI_NAMESPACE); Document doc = new Document(dumpGroup(group, ns)); doc.getRootElement().setNamespace(ns); doc.getRootElement().addNamespaceDeclaration(nsXsi); doc.getRootElement().setAttribute( new Attribute("schemaLocation", USERCATALOG_NAMESPACE + " " + GROUP_SCHEMA_LOCATION, nsXsi)); XMLOutputter xmlOutputter = getOutputter(); String xml = xmlOutputter.outputString(doc); SAXBuilder saxBuilder = getBuilder(GROUP_SCHEMA_RESOURCE); try { saxBuilder.build(IOUtils.toInputStream(xml)); return xml; } catch (Exception e) { throw new ExportException("Error during validating output.", e); } }
SAXBuilder xmlBuilder = new SAXBuilder(); Document doc = xmlBuilder.build(is); Element objRoot = doc.getRootElement(); List<Element> lstMapping = objRoot.getChildren("req"); WeixinReqConfig objConfig = null; for(Element mapping :lstMapping){ String key = mapping.getAttribute("key").getValue(); String method = mapping.getAttribute("method").getValue(); String url = mapping.getAttribute("url").getValue(); String mappingHandler ="org.jeewx.api.core.handler.impl.WeixinReqDefaultHandler"; String datatype =WeiXinConstant.PARAM_DATA_TYPE; if(mapping.getAttribute("mappingHandler") != null){ mappingHandler = mapping.getAttribute("mappingHandler").getValue(); if(mapping.getAttribute("datatype") != null){ datatype = mapping.getAttribute("datatype").getValue();
Namespace ns = Namespace.getNamespace(USER_PROFILE_NAMESPACE_PREFIX, USER_PROFILE_NAMESPACE); Namespace nsXsi = Namespace.getNamespace(XSI_NAMESPACE_PREFIX, XSI_NAMESPACE); Element xUserProfile = new Element("userProfile", ns); Element xUserId = new Element("userId", ns); xUserId.setText(userProfileWithProfileParts.getUserId()); xUserProfile.addContent(xUserId); Document doc = new Document(xUserProfile); doc.getRootElement().setNamespace(ns); doc.getRootElement().addNamespaceDeclaration(nsXsi); doc.getRootElement().setAttribute( new Attribute("schemaLocation", USER_PROFILE_NAMESPACE + " " + USER_PROFILE_SCHEMA_LOCATION, nsXsi)); XMLOutputter xmlOutputter = getOutputter(); String xml = xmlOutputter.outputString(doc);
public Map<Integer, Map<String, String>> getColumnsAttributesFromXML(final String plugin, final String file) { LOG.info("Loading data from " + file + ".xml ..."); Map<Integer, Map<String, String>> columnsAttributes = Maps.newHashMap(); try { SAXBuilder builder = new SAXBuilder(); Document document = builder.build(getXmlFile(plugin, file)); Element rootNode = document.getRootElement(); @SuppressWarnings("unchecked") List<Element> listOfRows = rootNode.getChildren("row"); for (int rowNum = 0; rowNum < listOfRows.size(); rowNum++) { Element node = listOfRows.get(rowNum); @SuppressWarnings("unchecked") List<Attribute> listOfAtributes = node.getAttributes(); Map<String, String> columnAttribute = Maps.newHashMap(); for (int attributeNum = 0; attributeNum < listOfAtributes.size(); attributeNum++) { columnAttribute.put(listOfAtributes.get(attributeNum).getName().toLowerCase(Locale.ENGLISH), listOfAtributes .get(attributeNum).getValue()); } columnsAttributes.put(rowNum, columnAttribute); } } catch (IOException e) { LOG.error(e.getMessage(), e); } catch (JDOMException e) { LOG.error(e.getMessage(), e); } return columnsAttributes; }
Element schedulingPeriodElement = document.getRootElement(); assertElementName(schedulingPeriodElement, "SchedulingPeriod"); NurseRoster nurseRoster = new NurseRoster(); nurseRoster.setId(0L); nurseRoster.setCode(schedulingPeriodElement.getAttribute("ID").getValue()); schedulingPeriodElement.getChild("StartDate"), schedulingPeriodElement.getChild("EndDate")); generateNurseRosterInfo(nurseRoster); readSkillList(nurseRoster, schedulingPeriodElement.getChild("Skills"));
Attribute typeAttribute = new Attribute("type", content.getType()); contentElement.setAttribute(typeAttribute); Attribute modeAttribute = new Attribute("mode", content.getMode().toString()); contentElement.setAttribute(modeAttribute); contentElement.addContent(content.getValue()); } else if (mode.equals(Content.BASE64)) { contentElement.addContent(Base64.encode(content.getValue())); List children = tmpDoc.getRootElement().removeContent(); contentElement.addContent(children);
protected Element createRootElement(Channel channel) { Element root = new Element("rss",getFeedNamespace()); Attribute version = new Attribute("version", getVersion()); root.setAttribute(version); root.addNamespaceDeclaration(getContentNamespace()); generateModuleNamespaceDefs(root); return root; }
protected java.util.Map extractAttributes (org.jdom.Element elt) { java.util.Map result = new java.util.HashMap(); java.util.Iterator it = elt.getAttributes().iterator(); while (it.hasNext()) { org.jdom.Attribute a = (org.jdom.Attribute)it.next(); result.put(a.getName(), a.getValue()); } return result; }
public void writeAttribute(String prefix, String namespace, String local, String value) throws XMLStreamException { currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(prefix, namespace))); }
@SuppressWarnings("unchecked") static public void process_aput_object(Element element, InstructionUseInfo i) throws DataConversionException { i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj())); if (!i.requiresRetain.isEmpty()) { Element toAdd= new Element(cmd_a_release, vm); for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) { toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace()); } i.putRelease= toAdd; } i.isWrite= false; }
protected void populateItem(Item item, Element eItem, int index) { super.populateItem(item,eItem, index); Description description = item.getDescription(); if (description!=null && description.getType()!=null) { Element eDescription = eItem.getChild("description",getFeedNamespace()); eDescription.setAttribute(new Attribute("type",description.getType())); } eItem.removeChild("expirationDate",getFeedNamespace()); }
protected String extractWorkflowName(String definition) throws FlowDefinitionException { try { // jdom final org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(); Document doc = builder.build(new StringReader(definition)); Element process_definition = doc.getRootElement(); return process_definition.getAttribute("name").getValue(); } catch(Exception e){ throw new FlowDefinitionException("can't extract name out of the definition", e); } }
private static Element createFilterBandElement(String filterType) { final Element bandInfo = new Element(DimapProductConstants.TAG_SPECTRAL_BAND_INFO); final Element filterInfo = new Element(DimapProductConstants.TAG_FILTER_BAND_INFO); final Attribute bandType = new Attribute(DimapProductConstants.ATTRIB_BAND_TYPE, filterType); filterInfo.setAttribute(bandType); bandInfo.setContent(filterInfo); return bandInfo; }