本文整理了Java中org.jdom.Attribute
类的一些代码示例,展示了Attribute
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute
类的具体详情如下:
包路径:org.jdom.Attribute
类名称:Attribute
[英]An XML attribute. Methods allow the user to obtain the value of the attribute as well as namespace and type information.
[中]XML属性。方法允许用户获取属性值以及名称空间和类型信息。
代码示例来源:origin: kiegroup/optaplanner
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());
代码示例来源:origin: org.freemarker/freemarker
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());
}
}
代码示例来源:origin: org.freemarker/freemarker
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()));
代码示例来源:origin: jaxen/jaxen
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();
}
代码示例来源:origin: org.freemarker/freemarker
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("\"");
}
}
代码示例来源:origin: rome/rome
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;
}
代码示例来源:origin: rome/rome
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;
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-user
@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);
}
}
代码示例来源:origin: zhangdaiscott/jeewx-api
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();
代码示例来源:origin: pl.edu.icm.yadda/yadda-user
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);
代码示例来源:origin: qcadoo/mes
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;
}
代码示例来源:origin: kiegroup/optaplanner
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"));
代码示例来源:origin: rome/rome
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);
代码示例来源:origin: rome/rome
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;
}
代码示例来源:origin: org.openwfe/openwfe-applic
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;
}
代码示例来源:origin: org.codehaus.xfire/xfire-core
public void writeAttribute(String prefix, String namespace, String local, String value)
throws XMLStreamException
{
currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(prefix,
namespace)));
}
代码示例来源:origin: dragome/dragome-sdk
@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;
}
代码示例来源:origin: rome/rome
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());
}
代码示例来源:origin: info.magnolia/magnolia-module-workflow
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);
}
}
代码示例来源:origin: bcdev/beam
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;
}
内容来源于网络,如有侵权,请联系作者删除!