List of usage examples for org.jdom2 Attribute Attribute
public Attribute(final String name, final String value)
Attribute
with the specified (local) name and value, and does not place the attribute in a Namespace
. From source file:com.sun.syndication.io.impl.Atom10Generator.java
License:Open Source License
protected Element generateGeneratorElement(Generator generator) { Element generatorElement = new Element("generator", getFeedNamespace()); if (generator.getUrl() != null) { Attribute urlAttribute = new Attribute("uri", generator.getUrl()); generatorElement.setAttribute(urlAttribute); }// ww w .ja v a2s . c o m if (generator.getVersion() != null) { Attribute versionAttribute = new Attribute("version", generator.getVersion()); generatorElement.setAttribute(versionAttribute); } if (generator.getValue() != null) { generatorElement.addContent(generator.getValue()); } return generatorElement; }
From source file:com.sun.syndication.io.impl.RSS091UserlandGenerator.java
License:Open Source License
protected Element createRootElement(Channel channel) { Element root = new Element("rss", getFeedNamespace()); Attribute version = new Attribute("version", getVersion()); root.setAttribute(version);//from w w w .ja v a 2 s .c o m root.addNamespaceDeclaration(getContentNamespace()); generateModuleNamespaceDefs(root); return root; }
From source file:com.sun.syndication.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateCloud(Cloud cloud) { Element eCloud = new Element("cloud", getFeedNamespace()); if (cloud.getDomain() != null) { eCloud.setAttribute(new Attribute("domain", cloud.getDomain())); }/*from w ww . j a va2s . c o m*/ if (cloud.getPort() != 0) { eCloud.setAttribute(new Attribute("port", String.valueOf(cloud.getPort()))); } if (cloud.getPath() != null) { eCloud.setAttribute(new Attribute("path", cloud.getPath())); } if (cloud.getRegisterProcedure() != null) { eCloud.setAttribute(new Attribute("registerProcedure", cloud.getRegisterProcedure())); } if (cloud.getProtocol() != null) { eCloud.setAttribute(new Attribute("protocol", cloud.getProtocol())); } return eCloud; }
From source file:com.sun.syndication.io.impl.RSS092Generator.java
License:Open Source License
protected Element generateSourceElement(Source source) { Element sourceElement = new Element("source", getFeedNamespace()); if (source.getUrl() != null) { sourceElement.setAttribute(new Attribute("url", source.getUrl())); }/*from w w w. j av a2 s . c o m*/ sourceElement.addContent(source.getValue()); return sourceElement; }
From source file:com.sun.syndication.io.impl.RSS094Generator.java
License:Open Source License
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())); }/*from w w w. ja v a2 s . com*/ eItem.removeChild("expirationDate", getFeedNamespace()); }
From source file:de.herm_detlef.java.application.io.Export.java
License:Apache License
private static Document createJdomDocument(ObservableList<ExerciseItem> exerciseItemList) { Namespace ns = Namespace.getNamespace(ApplicationConstants.XML_NAMESPACE); Element catalog = new Element(TAG.CATALOG.name(), ns); Document doc = new Document(catalog); Namespace xsi = Namespace.getNamespace("xsi", ApplicationConstants.XML_SCHEMA_INSTANCE); doc.getRootElement().addNamespaceDeclaration(xsi); doc.getRootElement().setAttribute("schemaLocation", ApplicationConstants.XML_SCHEMA_DEFINITION, xsi); int count = 0; for (ExerciseItem exItem : exerciseItemList) { Element item = new Element(TAG.ITEM.name(), ns); catalog.addContent(item);// ww w . j a v a 2 s. co m Element id = new Element(TAG.ID.name(), ns); id.addContent(String.valueOf(++count)); item.addContent(id); Element element = null; for (ItemPart itemPart : exItem.getExerciseItemParts()) { Object obj = itemPart.get(); if (obj == null) { // assert false : String.format( // "%s", // itemPart.getClass() ); // TODO continue; } if (itemPart instanceof QuestionText || itemPart instanceof QuestionText2) { isAnswerPart = false; if (!isQuestionPart) { element = new Element(TAG.QUESTION.name(), ns); item.addContent(element); isQuestionPart = true; } if (element == null) continue; if (itemPart instanceof QuestionText) { Element text = new Element(TAG.TEXT.name(), ns); element.addContent(text); text.addContent(((QuestionText) itemPart).getStr().get()); } if (itemPart instanceof QuestionText2) { Element text = new Element(TAG.TEXT2.name(), ns); element.addContent(text); text.addContent(((QuestionText2) itemPart).getStr().get()); } } else if (itemPart instanceof QuestionCode) { isAnswerPart = false; if (!isQuestionPart) { element = new Element(TAG.QUESTION.name(), ns); item.addContent(element); isQuestionPart = true; } if (element == null) continue; Element code = new Element(TAG.CODE.name(), ns); element.addContent(code); code.addContent(((QuestionCode) itemPart).getStr().get()); } else if (itemPart instanceof SingleChoiceAnswerText) { isQuestionPart = false; if (!isAnswerPart) { element = new Element(TAG.SINGLE_CHOICE_ANSWER.name(), ns); item.addContent(element); isAnswerPart = true; } if (element == null) continue; Element answer = new Element(TAG.TEXT.name(), ns); element.addContent(answer); if (((AnswerText) itemPart).isMarked()) { Attribute mark = new Attribute("mark", "true"); answer.setAttribute(mark); } answer.addContent(((SingleChoiceAnswerText) itemPart).getStr().get()); } else if (itemPart instanceof MultipleChoiceAnswerText) { isQuestionPart = false; if (!isAnswerPart) { element = new Element(TAG.MULTIPLE_CHOICE_ANSWER.name(), ns); item.addContent(element); isAnswerPart = true; } if (element == null) continue; Element answer = new Element(TAG.TEXT.name(), ns); element.addContent(answer); if (((AnswerText) itemPart).isMarked()) { Attribute mark = new Attribute("mark", "true"); answer.setAttribute(mark); } answer.addContent(((MultipleChoiceAnswerText) itemPart).getStr().get()); } else if (itemPart instanceof SolutionText) { isQuestionPart = false; isAnswerPart = false; element = new Element(TAG.SOLUTION.name(), ns); item.addContent(element); Element solution = new Element(TAG.TEXT.name(), ns); element.addContent(solution); solution.addContent(((SolutionText) itemPart).getStr().get()); } if (element == null) { assert false; return null; } } } return doc; }
From source file:de.knowwe.visualization.dot.DOTRenderer.java
License:Open Source License
/** * Adds the target-attribute to the element. * * @created 21.12.2013//from ww w . j av a2 s . co m */ private static void addTargetAttribute(Element element) { Attribute target = new Attribute("target", "_top"); element.setAttribute(target); }
From source file:devicemodel.conversions.XmlConversions.java
public static Element nodeToXml(DeviceNode node) { Element elem = new Element(node.getName()); if (node.getAttributes().size() > 0) { for (String key : node.getAttributes().keySet()) { elem.getAttributes().add(new Attribute(key, node.getAttribute(key))); }//from w w w.j av a2s .c o m } if (node.getValue() != null) { elem.setText(node.getValue()); } if (node.getChildren().size() > 0) { List<String> children = node.getChildrenNamesSorted(); for (String child : children) { elem.getChildren().add(nodeToXml(node.getChild(child))); } } return elem; }
From source file:edu.utep.cs.jasg.apiGenerator.APIGenerator.java
License:Open Source License
/** Creates JDom nodes of the terminals contained in the parser specification file. * Maps the name of the terminals contained in the Beaver specification file to the value * of the terminals extracted from a JFlex specification file */ private void createTerminalElements() { Element terminals = new Element("terminals"); for (String terminal : parserModel.getTerminals()) { Element terminalElement = new Element("terminal"); terminalElement.setAttribute("name", terminal); if (scannerModel.getTokens().containsKey(terminal)) { Element symbolSet = new Element("symbol_set"); Iterator<String> symbolList = scannerModel.getTokens().get(terminal).iterator(); while (symbolList.hasNext()) { String symbol = symbolList.next(); symbolSet.addContent(new Element("symbol").setAttribute(new Attribute("value", symbol))); }//from w w w .ja va 2s . c o m terminalElement.addContent(symbolSet); } terminals.addContent(terminalElement); } doc.getRootElement().addContent(terminals); }
From source file:edu.utep.cs.jasg.apiGenerator.APIGenerator.java
License:Open Source License
/** Creates JDom nodes of the parser rules */ private void createRuleElements() { Element ruleSet = new Element("rule_set"); Iterator<String> keys = parserModel.getRuleTypes().keySet().iterator(); while (keys.hasNext()) { Element rule = new Element("rule"); String key = keys.next(); rule.setAttribute(new Attribute("name", key)); rule.setAttribute(new Attribute("type", parserModel.getRuleTypes().get(key))); rule.addContent(createRuleDefinitions(key)); ruleSet.addContent(rule);// ww w . j av a 2 s . c om } doc.getRootElement().addContent(ruleSet); }