List of usage examples for org.jdom2 Element setAttribute
public Element setAttribute(final String name, final String value, final Namespace ns)
This sets an attribute value for this element.
From source file:cager.parser.test.SimpleTest3.java
License:Open Source License
private void TratarASTIfStatement(ASTStatement astStatement, Element actionElement) { //Namespace xmi = Namespace.getNamespace("xmi", "http://www.omg.org/XMI"); //<actionRelation xmi:id="id.26" xmi:type="action:Reads" to="id.20" from="id.25"/> Element actionRelation = new Element("actionRelation"); actionRelation.setAttribute("id", "id." + idCount, xmi); idCount++;/*from w w w . j a va 2 s. c om*/ actionRelation.setAttribute("type", "action:Reads", xmi); //actionRelation.setAttribute("to", "id."+(idAction+2));//TODO calcular a dnde va actionRelation.setAttribute("from", "id." + idAction); actionElement.addContent(actionRelation); //<actionRelation xmi:id="id.46" xmi:type="action:Writes" to="id.39"/> actionRelation = new Element("actionRelation"); actionRelation.setAttribute("id", "id." + idCount, xmi); idCount++; actionRelation.setAttribute("type", "action:TrueFlow", xmi); //actionRelation.setAttribute("to", "id."+(idAction+2));//TODO calcular a dnde va actionRelation.setAttribute("from", "id." + idAction); actionElement.addContent(actionRelation); actionRelation = new Element("actionRelation"); actionRelation.setAttribute("id", "id." + idCount, xmi); idCount++; actionRelation.setAttribute("type", "action:FalseFlow", xmi); //actionRelation.setAttribute("to", "id."+(idAction+1));//TODO calcular a dnde va actionRelation.setAttribute("from", "id." + idAction); actionElement.addContent(actionRelation); // <codeElement xmi:id="id.34" xmi:type="action:ActionElement" name="a3.1" kind="Condition"> // <actionRelation xmi:id="id.35" xmi:type="action:Reads" to="id.29" from="id.34"/> // <actionRelation xmi:id="id.36" xmi:type="action:TrueFlow" to="id.38" from="id.28"/> // <actionRelation xmi:id="id.37" xmi:type="action:FalseFlow" to="id.42" from="id.34"/> // </codeElement> // <codeElement xmi:id="id.111" xmi:type="action:ActionElement" name="p5.2" kind="GreaterThan"> // <actionRelation xmi:id="id.112" xmi:type="action:Reads" to="id.104" from="id.111"/> // <actionRelation xmi:id="id.113" xmi:type="action:TrueFlow" to="id.115" from="id.111"/> // <actionRelation xmi:id="id.114" xmi:type="action:FalseFlow" to="id.120" from="id.111"/> // </codeElement> /* <codeElement xmi:id="id.25" xmi:type="action:ActionElement" name="1.3" kind="Condition"> <actionRelation xmi:id="id.26" xmi:type="action:Reads" to="id.20" from="id.25"/> <actionRelation xmi:id="id.27" xmi:type="action:TrueFlow" to="id.29" from="id.25"/> <actionRelation xmi:id="id.28" xmi:type="action:FalseFlow" to="id.39" from="id.25"/> </codeElement> <codeElement xmi:id="id.75" xmi:type="action:ActionElement" name="a1" kind="Condition"> <actionRelation xmi:id="id.76" xmi:type="action:TrueFlow" to="id.77" from="id.75" /> <actionRelation xmi:id="id.77" xmi:type="action:FalseFlow" to="id.76" from="id.75" /> </codeElement> */ }
From source file:cager.parser.test.SimpleTest3.java
License:Open Source License
private Element inicializaDataTypes() { // Creamos el builder basado en SAX SAXBuilder builder = new SAXBuilder(); //Namespace xmi = Namespace.getNamespace("xmi", "http://www.omg.org/XMI"); Namespace code = Namespace.getNamespace("code", "http://kdm.omg.org/code"); Element model = new Element("model"); model.setAttribute("id", "id." + idCount, xmi); model.setAttribute("type", "code:CodeModel", xmi); idCount++;//from w w w . ja va2 s.c om Element codeElementP = new Element("codeElement"); codeElementP.setAttribute("id", "id." + idCount, xmi); codeElementP.setAttribute("type", "code:LanguageUnit", xmi); idCount++; Element codeElementI = new Element("codeElement"); for (int i = 0; i < dataTypes.length; i++) { codeElementI = new Element("codeElement"); codeElementI.setAttribute("id", "id." + idCount, xmi); if (dataTypes[i].equals("Double") || dataTypes[i].equals("Long") || dataTypes[i].equals("Short")) { codeElementI.setAttribute("type", "code:DecimalType", xmi); } else if (dataTypes[i].equals("Byte")) { codeElementI.setAttribute("type", "code:OctetType", xmi); } else { codeElementI.setAttribute("type", "code:" + dataTypes[i] + "Type", xmi); } codeElementI.setAttribute("name", dataTypes[i]); if (!hsmLanguajeUnitDataType.containsKey(dataTypes[i])) { hsmLanguajeUnitDataType.put(dataTypes[i], idCount); } idCount++; codeElementP.addContent(codeElementI); } //model.addContent(codeElementP); return codeElementP; }
From source file:com.rometools.modules.cc.io.CCModuleGenerator.java
License:Open Source License
private void generateRSS1(final CreativeCommons module, final Element element) { // throw new RuntimeException( "Generating RSS1 Feeds not currently Supported."); LOG.debug(element.getName());/* w w w .j av a 2s . c o m*/ if (element.getName().equals("channel")) { // Do all licenses list. final License[] all = module.getAllLicenses(); for (final License element2 : all) { final Element license = new Element("License", RSS1); license.setAttribute("about", element2.getValue(), RDF); final License.Behaviour[] permits = element2.getPermits(); for (int j = 0; permits != null && j < permits.length; j++) { final Element permit = new Element("permits", RSS1); permit.setAttribute("resource", permits[j].toString(), RDF); license.addContent(permit); } final License.Behaviour[] requires = element2.getPermits(); for (int j = 0; requires != null && j < requires.length; j++) { final Element permit = new Element("requires", RSS1); permit.setAttribute("resource", permits[j].toString(), RDF); license.addContent(permit); } LOG.debug("Is Root? {}", element.getParentElement()); element.getParentElement().addContent(license); } } // Do local licenses final License[] licenses = module.getLicenses(); for (final License license2 : licenses) { final Element license = new Element("license", RSS1); license.setAttribute("resource", license2.getValue(), RDF); element.addContent(license); } }
From source file:com.rometools.propono.atom.common.Categories.java
License:Apache License
public Element categoriesToElement() { final Categories cats = this; final Element catsElem = new Element("categories", AtomService.ATOM_PROTOCOL); catsElem.setAttribute("fixed", cats.isFixed() ? "yes" : "no", AtomService.ATOM_PROTOCOL); if (cats.getScheme() != null) { catsElem.setAttribute("scheme", cats.getScheme(), AtomService.ATOM_PROTOCOL); }/*from www . ja v a2 s. co m*/ if (cats.getHref() != null) { catsElem.setAttribute("href", cats.getHref(), AtomService.ATOM_PROTOCOL); } else { // Loop to create <atom:category> elements for (final Object element : cats.getCategories()) { final Category cat = (Category) element; final Element catElem = new Element("category", AtomService.ATOM_FORMAT); catElem.setAttribute("term", cat.getTerm(), AtomService.ATOM_FORMAT); if (cat.getScheme() != null) { // optional catElem.setAttribute("scheme", cat.getScheme(), AtomService.ATOM_FORMAT); } if (cat.getLabel() != null) { // optional catElem.setAttribute("label", cat.getLabel(), AtomService.ATOM_FORMAT); } catsElem.addContent(catElem); } } return catsElem; }
From source file:com.rometools.propono.atom.common.Workspace.java
License:Apache License
/** * Serialize an AtomService.DefaultWorkspace object into an XML element */// w ww .ja v a 2 s . c o m public Element workspaceToElement() { final Workspace space = this; final Element element = new Element("workspace", AtomService.ATOM_PROTOCOL); final Element titleElem = new Element("title", AtomService.ATOM_FORMAT); titleElem.setText(space.getTitle()); if (space.getTitleType() != null && !space.getTitleType().equals("TEXT")) { titleElem.setAttribute("type", space.getTitleType(), AtomService.ATOM_FORMAT); } element.addContent(titleElem); for (final Collection col : space.getCollections()) { element.addContent(col.collectionToElement()); } return element; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected Element createRootElement(final Feed feed) { final Element root = new Element("feed", getFeedNamespace()); root.addNamespaceDeclaration(getFeedNamespace()); // Attribute version = new Attribute("version", getVersion()); // root.setAttribute(version); final String xmlBase = feed.getXmlBase(); if (xmlBase != null) { root.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE); }//from w w w. j ava 2 s .co m generateModuleNamespaceDefs(root); return root; }
From source file:com.rometools.rome.io.impl.Atom10Generator.java
License:Open Source License
protected void addEntry(final Entry entry, final Element parent) throws FeedException { final Element eEntry = new Element("entry", getFeedNamespace()); final String xmlBase = entry.getXmlBase(); if (xmlBase != null) { eEntry.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE); }//from w w w. ja va2 s . c o m populateEntry(entry, eEntry); generateForeignMarkup(eEntry, entry.getForeignMarkup()); checkEntryConstraints(eEntry); generateItemModules(entry.getModules(), eEntry); parent.addContent(eEntry); }
From source file:com.rometools.rome.io.impl.RSS10Generator.java
License:Open Source License
@Override protected void populateChannel(final Channel channel, final Element eChannel) { super.populateChannel(channel, eChannel); final String channelUri = channel.getUri(); if (channelUri != null) { eChannel.setAttribute("about", channelUri, getRDFNamespace()); }//w w w.j av a 2 s. c om final List<Item> items = channel.getItems(); if (!items.isEmpty()) { final Element eItems = new Element("items", getFeedNamespace()); final Element eSeq = new Element("Seq", getRDFNamespace()); for (final Item item : items) { final Element lis = new Element("li", getRDFNamespace()); final String uri = item.getUri(); if (uri != null) { lis.setAttribute("resource", uri, getRDFNamespace()); } eSeq.addContent(lis); } eItems.addContent(eSeq); eChannel.addContent(eItems); } }
From source file:com.rometools.rome.io.impl.RSS10Generator.java
License:Open Source License
@Override protected void populateItem(final Item item, final Element eItem, final int index) { super.populateItem(item, eItem, index); final String link = item.getLink(); final String uri = item.getUri(); if (uri != null) { eItem.setAttribute("about", uri, getRDFNamespace()); } else if (link != null) { eItem.setAttribute("about", link, getRDFNamespace()); }/*w w w . jav a 2s. c o m*/ final Description description = item.getDescription(); if (description != null) { eItem.addContent(generateSimpleElement("description", description.getValue())); } if (item.getModule(getContentNamespace().getURI()) == null && item.getContent() != null) { final Element elem = new Element("encoded", getContentNamespace()); elem.addContent(item.getContent().getValue()); eItem.addContent(elem); } }
From source file:com.sun.syndication.io.impl.Atom10Generator.java
License:Open Source License
protected Element createRootElement(Feed feed) { Element root = new Element("feed", getFeedNamespace()); root.addNamespaceDeclaration(getFeedNamespace()); //Attribute version = new Attribute("version", getVersion()); //root.setAttribute(version); if (feed.getXmlBase() != null) { root.setAttribute("base", feed.getXmlBase(), Namespace.XML_NAMESPACE); }// w w w. ja v a 2 s . co m generateModuleNamespaceDefs(root); return root; }