List of usage examples for org.jdom2 Comment Comment
public Comment(String text)
From source file:com.cybernostics.jsp2thymeleaf.JSP2Thymeleaf.java
private List<Content> rootContentFor(JspTree jspTree) { List<Content> contents = new ArrayList<>(); if (showBanner) { contents.add(new Comment("Created with JSP2Thymeleaf")); contents.add(new Text(NEWLINE)); }/*from www . j av a 2 s. c o m*/ contents.addAll(contentFor(jspTree, this)); final Optional<Content> foundHtmlElement = contents.stream().filter(JSP2Thymeleaf::isHtmlElement) .findFirst(); if (foundHtmlElement.isPresent()) { final Element htmlElement = (Element) foundHtmlElement.get(); contents.remove(htmlElement); trimTrailingWhitespace(contents); htmlElement.addContent(contents); htmlElement.setNamespace(xmlns); ActiveNamespaces.get().forEach(ns -> htmlElement.addNamespaceDeclaration(ns)); return Arrays.asList(new DocType("html", THYMELEAF_DTD), htmlElement); } else { Element thFragment = createFragmentDef(contents); return Arrays.asList(new DocType("html", THYMELEAF_DTD), thFragment); } }
From source file:es.upm.dit.xsdinferencer.generation.generatorimpl.schemageneration.XMLSchemaDocumentGenerator.java
License:Apache License
/** * Method that generates a complexType tag, wherever it has to be generated and in the correct way * @param configuration the inference configuration * @param complexType the complex type to which the tag will be generated * @param anonymous whether this complex type must be anonymous (i.e. it must not have a 'name' attribute) * @param targetNamespace the target namespace which is currently being generated * @param namespaceURIToPrefixMappings solved mappings between namespace URIs and prefixes * @param mainNamespace main namespace// w ww . ja v a 2 s .c om * @param xsdNamespace namespace of the XML Schema * @return a JDOM2 {@link Element} which describes the complex type */ private Element generateComplexType(XSDInferenceConfiguration configuration, ComplexType complexType, boolean anonymous, String targetNamespace, Map<String, String> namespaceURIToPrefixMappings, String mainNamespace, Namespace xsdNamespace) { Element complexTypeElement = new Element("complexType", xsdNamespace); for (String commentOnComplexType : ImmutableSortedSet.copyOf(complexType.getComments())) { complexTypeElement.addContent(new Comment(commentOnComplexType)); } if (!anonymous) { Attribute complexTypeNameAttr = new Attribute("name", ""); complexTypeNameAttr.setValue(complexType.getName()); complexTypeElement.setAttribute(complexTypeNameAttr); } SimpleType simpleType = complexType.getTextSimpleType(); boolean hasChildren = !complexType.getRegularExpression().equals(new EmptyRegularExpression()); boolean hasNonWhitespaceSimpleContent = !simpleType.isEmpty() && !simpleType.consistOnlyOfWhitespaceCharacters(); if (hasChildren) { //Mixed complex type. As far as I know, XSD does not allow to constraint simple content on mixed types if (hasNonWhitespaceSimpleContent) { Attribute mixedAttr = new Attribute("mixed", ""); mixedAttr.setValue("true"); complexTypeElement.setAttribute(mixedAttr); } Element childrenContent = generateRegexpRepresentation(complexType.getRegularExpression(), configuration, targetNamespace, mainNamespace, complexType, namespaceURIToPrefixMappings, xsdNamespace); if (childrenContent.getName().equals("element")) { Element unwrappedChildrenContent = childrenContent; childrenContent = new Element("sequence", xsdNamespace); childrenContent.addContent(unwrappedChildrenContent); } complexTypeElement.addContent(childrenContent); List<Element> attributesInfo = generateAttributeList(complexType, targetNamespace, mainNamespace, configuration, namespaceURIToPrefixMappings, xsdNamespace); complexTypeElement.addContent(attributesInfo); } else if (complexType.getAttributeList().size() > 0 && !simpleType.isEmpty()) { Element simpleContentElement = new Element("simpleContent", xsdNamespace); Element extensionElement = new Element("extension", xsdNamespace); Attribute extensionBaseAttr = new Attribute("base", ""); String simpleTypeRepresentationName = complexType.getTextSimpleType() .getRepresentationName(configuration.getTypeNamesAncestorsSeparator()); if (!simpleTypeRepresentationName.contains(XSD_NAMESPACE_PREFIX) && !namespaceURIToPrefixMappings.get(mainNamespace).equals("")) { simpleTypeRepresentationName = namespaceURIToPrefixMappings.get(mainNamespace) + ":" + simpleTypeRepresentationName; } extensionBaseAttr.setValue(simpleTypeRepresentationName); extensionElement.setAttribute(extensionBaseAttr); List<Element> attributesInfo = generateAttributeList(complexType, targetNamespace, mainNamespace, configuration, namespaceURIToPrefixMappings, xsdNamespace); extensionElement.addContent(attributesInfo); simpleContentElement.addContent(extensionElement); complexTypeElement.addContent(simpleContentElement); } else if (complexType.getAttributeList().size() > 0) { List<Element> attributesInfo = generateAttributeList(complexType, targetNamespace, mainNamespace, configuration, namespaceURIToPrefixMappings, xsdNamespace); complexTypeElement.addContent(attributesInfo); } //If the complex type consists of a non empty simple type without either children or attributes, no complexType tag would be generated, so it is not handled here return complexTypeElement; }
From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsChipSeq.java
License:Open Source License
public void exportToXML(File output) throws IOException { Document configurationFile = new Document(); Comment comment = new Comment(COMMENT_CHIPSEQ); configurationFile.addContent(comment); Element configData = new Element(CONFIG_DATA); configurationFile.setRootElement(configData); Element bwaPath = new Element(BWA_PATH); bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(bwaPath); Element samtoolsPath = new Element(SAMTOOLS_PATH); samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(samtoolsPath); Element picardPath = new Element(PICARD_PATH); picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(picardPath); Element MACSPath = new Element(MACS_PATH); MACSPath.addContent(this.getMacsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(MACSPath); Element PythonPath = new Element(PYTHON_PATH); PythonPath.addContent(this.getPythonPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(PythonPath); Element BEDToolsPath = new Element(BED_TOOLS_PATH); BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BEDToolsPath); Element CCATPath = new Element(CCAT_PATH); CCATPath.addContent(this.getCcatPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(CCATPath); Element BedgraphtoWigPath = new Element(BGTW_PATH); BedgraphtoWigPath.addContent(this.getBedgraphtobigwigPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BedgraphtoWigPath); Element IDRPath = new Element(IDR_PATH); IDRPath.addContent(this.getIdrPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(IDRPath); Element PeakAnnotatorPath = new Element(PEAKANNOTATOR_PATH); PeakAnnotatorPath.addContent(this.getPeakannotatorPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(PeakAnnotatorPath); Element fastqcPath = new Element(FASTQC_PATH); fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(fastqcPath); if (!this.getNthr().equals(nthr_DV)) { Element nthr = new Element(NTHR); nthr.addContent(String.valueOf(this.getNthr())); configurationFile.getRootElement().addContent(nthr); }//from w ww .j a v a2s.c o m if (!this.getJavaRam().equals(javaRam_DV)) { Element javaRam = new Element(JAVA_RAM); javaRam.addContent(this.getJavaRam()); configurationFile.getRootElement().addContent(javaRam); } Element queueSystem = new Element(QUEUE_SYSTEM); queueSystem.addContent(this.getQueueSystem().getDisplayName()); configurationFile.getRootElement().addContent(queueSystem); if (!this.getQueueName().equals(queueName_DV)) { Element queueName = new Element(QUEUE_NAME); queueName.addContent(this.getQueueName()); configurationFile.getRootElement().addContent(queueName); } if (!this.getMulticoreName().equals(multicoreName_DV)) { Element multicoreName = new Element(MULTICORE_NAME); multicoreName.addContent(this.getMulticoreName()); configurationFile.getRootElement().addContent(multicoreName); } if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) { Element multicoreNumber = new Element(MULTICORE_NUMBER); multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber())); configurationFile.getRootElement().addContent(multicoreNumber); } XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(configurationFile, new FileWriter(output)); // xmlOutput.output(configurationFile, new FileWriter(new File(output.getAbsolutePath()+".test"))); }
From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsCNV.java
License:Open Source License
public void exportToXML(File output) throws IOException { Document configurationFile = new Document(); Comment comment = new Comment(COMMENT_VARIANT_CALLER); configurationFile.addContent(comment); Element configData = new Element(CONFIG_DATA); configurationFile.setRootElement(configData); Element bwaPath = new Element(BWA_PATH); bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(bwaPath); Element samtoolsPath = new Element(SAMTOOLS_PATH); samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(samtoolsPath); Element gatkpath = new Element(GATK_PATH); gatkpath.addContent(this.getGatkpath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(gatkpath); Element picardPath = new Element(PICARD_PATH); picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(picardPath); Element BFASTPath = new Element(BFAST_PATH); BFASTPath.addContent(this.getBfastPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BFASTPath); Element BEDToolsPath = new Element(BED_TOOLS_PATH); BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BEDToolsPath); Element CONTRAPath = new Element(CONTRA_PATH); CONTRAPath.addContent(this.getContraPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(CONTRAPath); Element fastqcPath = new Element(FASTQC_PATH); fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(fastqcPath); if (!this.getNthr().equals(nthr_DV)) { Element nthr = new Element(NTHR); nthr.addContent(String.valueOf(this.getNthr())); configurationFile.getRootElement().addContent(nthr); }// w ww .ja v a 2 s .co m if (!this.getJavaRam().equals(javaRam_DV)) { Element javaRam = new Element(JAVA_RAM); javaRam.addContent(this.getJavaRam()); configurationFile.getRootElement().addContent(javaRam); } Element queueSystem = new Element(QUEUE_SYSTEM); queueSystem.addContent(this.getQueueSystem().getDisplayName()); configurationFile.getRootElement().addContent(queueSystem); if (!this.getQueueName().equals(queueName_DV)) { Element queueName = new Element(QUEUE_NAME); queueName.addContent(this.getQueueName()); configurationFile.getRootElement().addContent(queueName); } if (!this.getMulticoreName().equals(multicoreName_DV)) { Element multicoreName = new Element(MULTICORE_NAME); multicoreName.addContent(this.getMulticoreName()); configurationFile.getRootElement().addContent(multicoreName); } if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) { Element multicoreNumber = new Element(MULTICORE_NUMBER); multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber())); configurationFile.getRootElement().addContent(multicoreNumber); } XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(configurationFile, new FileWriter(output)); }
From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsMethylation.java
License:Open Source License
public void exportToXML(File output) throws IOException { Document configurationFile = new Document(); Comment comment = new Comment(COMMENT_METHYLATION); configurationFile.addContent(comment); Element configData = new Element(CONFIG_DATA); configurationFile.setRootElement(configData); Element bismarkPath = new Element(BISMARK_PATH); bismarkPath.addContent(this.getBismarkPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(bismarkPath); Element bowtiePath = new Element(BOWTIE_PATH); bowtiePath.addContent(this.getBowtiePath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(bowtiePath); Element picardPath = new Element(PICARD_PATH); picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(picardPath); Element BEDToolsPath = new Element(BED_TOOLS_PATH); BEDToolsPath.addContent(this.getBedtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BEDToolsPath); Element fastxPath = new Element(FASTX_PATH); fastxPath.addContent(this.getFastxPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(fastxPath); Element filoPath = new Element(FILO_PATH); filoPath.addContent(this.getFiloPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(filoPath); Element fastqcPath = new Element(FASTQC_PATH); fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(fastqcPath); if (!this.getNthr().equals(nthr_DV)) { Element nthr = new Element(NTHR); nthr.addContent(String.valueOf(this.getNthr())); configurationFile.getRootElement().addContent(nthr); }//from ww w . j av a 2 s . co m if (!this.getJavaRam().equals(javaRam_DV)) { Element javaRam = new Element(JAVA_RAM); javaRam.addContent(this.getJavaRam()); configurationFile.getRootElement().addContent(javaRam); } Element queueSystem = new Element(QUEUE_SYSTEM); queueSystem.addContent(this.getQueueSystem().getDisplayName()); configurationFile.getRootElement().addContent(queueSystem); if (!this.getQueueName().equals(queueName_DV)) { Element queueName = new Element(QUEUE_NAME); queueName.addContent(this.getQueueName()); configurationFile.getRootElement().addContent(queueName); } if (!this.getMulticoreName().equals(multicoreName_DV)) { Element multicoreName = new Element(MULTICORE_NAME); multicoreName.addContent(this.getMulticoreName()); configurationFile.getRootElement().addContent(multicoreName); } if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) { Element multicoreNumber = new Element(MULTICORE_NUMBER); multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber())); configurationFile.getRootElement().addContent(multicoreNumber); } XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(configurationFile, new FileWriter(output)); }
From source file:es.uvigo.ei.sing.rubioseq.gui.view.models.configuration.ConfigProgramPathsSNV.java
License:Open Source License
public void exportToXML(File output) throws IOException { Document configurationFile = new Document(); Comment comment = new Comment(COMMENT_VARIANT_CALLER); configurationFile.addContent(comment); Element configData = new Element(CONFIG_DATA); configurationFile.setRootElement(configData); Element bwaPath = new Element(BWA_PATH); bwaPath.addContent(this.getBwaPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(bwaPath); Element samtoolsPath = new Element(SAMTOOLS_PATH); samtoolsPath.addContent(this.getSamtoolsPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(samtoolsPath); Element gatkpath = new Element(GATK_PATH); gatkpath.addContent(this.getGatkpath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(gatkpath); Element picardPath = new Element(PICARD_PATH); picardPath.addContent(this.getPicardPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(picardPath); Element BFASTPath = new Element(BFAST_PATH); BFASTPath.addContent(this.getBfastPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(BFASTPath); Element fastqcPath = new Element(FASTQC_PATH); fastqcPath.addContent(this.getFastqcPath().getFile().getAbsolutePath()); configurationFile.getRootElement().addContent(fastqcPath); if (!this.getNthr().equals(nthr_DV)) { Element nthr = new Element(NTHR); nthr.addContent(String.valueOf(this.getNthr())); configurationFile.getRootElement().addContent(nthr); }/* w w w . j a va 2 s . com*/ if (!this.getJavaRam().equals(javaRam_DV)) { Element javaRam = new Element(JAVA_RAM); javaRam.addContent(this.getJavaRam()); configurationFile.getRootElement().addContent(javaRam); } Element queueSystem = new Element(QUEUE_SYSTEM); queueSystem.addContent(this.getQueueSystem().getDisplayName()); configurationFile.getRootElement().addContent(queueSystem); if (!this.getQueueName().equals(queueName_DV)) { Element queueName = new Element(QUEUE_NAME); queueName.addContent(this.getQueueName()); configurationFile.getRootElement().addContent(queueName); } if (!this.getMulticoreName().equals(multicoreName_DV)) { Element multicoreName = new Element(MULTICORE_NAME); multicoreName.addContent(this.getMulticoreName()); configurationFile.getRootElement().addContent(multicoreName); } if (!this.getMulticoreNumber().equals(multicoreNumber_DV)) { Element multicoreNumber = new Element(MULTICORE_NUMBER); multicoreNumber.addContent(String.valueOf(this.getMulticoreNumber())); configurationFile.getRootElement().addContent(multicoreNumber); } XMLOutputter xmlOutput = new XMLOutputter(); xmlOutput.setFormat(Format.getPrettyFormat()); xmlOutput.output(configurationFile, new FileWriter(output)); }
From source file:eu.himeros.hocr.FlatXml.java
License:Open Source License
private void init(File inFile, File outFile) throws Exception { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(inFile); Element root = doc.getRootElement(); Namespace oldns = root.getNamespace(); Element newRoot = new Element("html", "http://www.w3.org/1999/xhtml"); Namespace xmlns = newRoot.getNamespace(); Element head = root.getChild("head", oldns); head.setNamespace(xmlns);//from w ww. java2 s .co m for (Element child : head.getChildren()) child.setNamespace(xmlns); Element title = new Element("title", xmlns); title.addContent("ocr"); if (head != null) head.addContent(title); Element body = root.getChild("body", oldns); body.setNamespace(xmlns); /*Element oldPage; try{ oldPage=body.getChild("div",xmlns); }catch(Exception ex){ oldPage=new Element("div",xmlns); }*/ Element page = new Element("div", xmlns); page.setAttribute("class", "ocr_page"); page.setAttribute("id", "i" + inFile.getName().substring(1).replace(".html", ".png")); XPathExpression<Element> xpath = XPathFactory.instance().compile("//*[@class='ocr_carea']", Filters.element(), null, Namespace.getNamespace("ns", "http://www.w3.org/1999/xhtml")); List<Element> careaElL = xpath.evaluate(body); for (Element careaEl : careaElL) { page.addContent(new Comment("<div class=\"" + careaEl.getAttributeValue("class") + "\" title=\"" + careaEl.getAttributeValue("title") + "\">")); for (Element pEl : careaEl.getChildren()) { page.addContent(new Comment("<p>")); for (Element lineEl : pEl.getChildren()) { lineEl.removeAttribute("id"); lineEl.setNamespace(xmlns); for (Element child : lineEl.getChildren()) { child.removeAttribute("id"); child.removeAttribute("lang"); child.removeAttribute("lang", xmlns); child.setNamespace(xmlns); } page.addContent(lineEl.clone()); } page.addContent(new Comment("</p>")); } page.addContent(new Comment("</div>")); } //oldPage.detach(); if (body != null) { body.removeContent(); body.addContent(page); } newRoot.addContent(root.removeContent()); doc.detachRootElement(); doc.setRootElement(newRoot); XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); xmlOutputter.output(doc, new BufferedWriter(new FileWriter(outFile))); }
From source file:jodtemplate.pptx.preprocessor.ShortListPreprocessor.java
License:Apache License
@Override public Document process(final Map<String, Object> context, final Document document, final Slide slide, final Resources resources, final Configuration configuration) throws JODTemplateException { final IteratorIterable<Element> parentElements = document .getDescendants(Filters.element(parentElement, getNamespace())); final List<Element> parentElementsList = new ArrayList<>(); while (parentElements.hasNext()) { parentElementsList.add(parentElements.next()); }/* ww w .j a v a 2s . c o m*/ for (final Element parent : parentElementsList) { final IteratorIterable<Element> atElements = parent .getDescendants(Filters.element(PPTXDocument.T_ELEMENT, getNamespace())); final List<Element> atElementsList = new ArrayList<>(); while (atElements.hasNext()) { atElementsList.add(atElements.next()); } final ExpressionHandler expressionHandler = configuration.getExpressionHandler(); boolean isLoop = false; InlineListExpression expression = null; for (final Element at : atElementsList) { final String text = at.getText(); if (configuration.getExpressionHandler().isInlineList(text)) { expression = expressionHandler.createInlineListExpression(text); at.setText(expressionHandler.createVariable(expression.getVariable())); isLoop = true; } } if (isLoop) { int apIndex = parent.getParent().indexOf(parent); final String beginList = expressionHandler.createBeginList(expression.getWhat(), expression.getAs()); final String endList = expressionHandler.createEndList(); parent.getParent().addContent(apIndex, new Comment(beginList)); apIndex++; parent.getParent().addContent(apIndex + 1, new Comment(endList)); } } return document; }
From source file:lu.list.itis.dkd.assess.cloze.template.Template.java
License:Apache License
private Element layer() { Element layerElement = new Element("layer"); Comment layerComment = new Comment( "this section represents an XML-QTI item with placeholders for variables"); layerElement.addContent(layerComment); Namespace xmlnsNamespace = Namespace.getNamespace("http://www.imsglobal.org/xsd/imsqti_v2p0"); Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); // Namespace schemaLocation = Namespace.getNamespace("xsi:schemaLocation", "http://www.imsglobal.org/xsd/imsqti_v2p0 imsqti_v2p0.xsd"); Element assessmentItem = new Element("assessmentItem", xmlnsNamespace); layerElement.addContent(assessmentItem); assessmentItem.addNamespaceDeclaration(xsi); // assessmentItem.addNamespaceDeclaration(schemaLocation); assessmentItem.setAttribute("identifier", "ModalFeedback"); assessmentItem.setAttribute("title", title); assessmentItem.setAttribute("adaptive", "false"); assessmentItem.setAttribute("timeDependent", "false"); assessmentItem.addContent(clozeItem.getCorrectResponseBlocks()); if (useFeedback) { outcomeDeclarationFeedback(doc, assessmentItem); }/*from ww w. j ava 2 s. co m*/ //outcomeScoreDeclaration Score Element Element outcomeScoreDeclaration = new Element("outcomeDeclaration"); assessmentItem.addContent(outcomeScoreDeclaration); outcomeScoreDeclaration.setAttribute("identifier", "SCORE"); outcomeScoreDeclaration.setAttribute("cardinality", "single"); outcomeScoreDeclaration.setAttribute("baseType", "float"); //defaultScoreValue Element Element defaultScoreValue = new Element("defaultValue"); outcomeScoreDeclaration.addContent(defaultScoreValue); //scoreValue element Element scoreValue = new Element("value"); scoreValue.setText("0"); defaultScoreValue.addContent(scoreValue); Element itemBody = new Element("itemBody"); assessmentItem.addContent(itemBody); Element blockquote = new Element("blockquote"); itemBody.addContent(blockquote); //Add qti cloze text blockquote.addContent(clozeItem.getClozeBlock()); Element responseProcessing = new Element("responseProcessing"); assessmentItem.addContent(responseProcessing); //Add feedback if (useFeedback) { for (ClozeSentence clozeSentence : clozeItem.getClozeSentences()) { int keyIndex = 1; for (Key key : clozeSentence.getKeys()) { Element correctModalFeedback = new Element("modalFeedback"); correctModalFeedback.setAttribute("outcomeIdentifier", "FEEDBACK_CORRECT" + keyIndex); correctModalFeedback.setAttribute("showHide", "show"); correctModalFeedback.setAttribute("identifier", "correctFeedback"); correctModalFeedback.setText(key.getFeedback()); assessmentItem.addContent(correctModalFeedback); int distractorIndex = 2; for (Distractor distractor : key.getDistractors()) { Element incorrectModalFeedback = new Element("modalFeedback"); incorrectModalFeedback.setAttribute("outcomeIdentifier", "FEEDBACK_INCORRECT" + (distractorIndex)); incorrectModalFeedback.setAttribute("showHide", "show"); incorrectModalFeedback.setAttribute("identifier", "incorrectFeedback"); incorrectModalFeedback.setText(distractor.getFeedback()); assessmentItem.addContent(incorrectModalFeedback); distractorIndex++; } distractorIndex++; } } } return layerElement; }
From source file:org.artifactory.webapp.wicket.page.home.settings.ivy.IvySettingsPanel.java
License:Open Source License
@Override public String generateSettings() { Document document = new Document(); Element rootNode = new Element("ivy-settings"); Element settingsElement = new Element("settings"); settingsElement.setAttribute("defaultResolver", "main"); rootNode.addContent(settingsElement); if (!authorizationService.isAnonymous() || !authorizationService.isAnonAccessEnabled()) { rootNode.addContent(/* www.j av a 2 s . co m*/ new Comment("Authentication required for publishing (deployment). 'Artifactory Realm' is " + "the realm used by Artifactory so don't change it.")); Element credentialsElement = new Element("credentials"); try { credentialsElement.setAttribute("host", new URL(servletContextUrl).getHost()); } catch (MalformedURLException e) { String errorMessage = "An error occurred while decoding the servlet context URL for the credentials host attribute: "; error(errorMessage + e.getMessage()); log.error(errorMessage, e); } credentialsElement.setAttribute("realm", "Artifactory Realm"); FilteredResourcesWebAddon filteredResourcesWebAddon = addonsManager .addonByType(FilteredResourcesWebAddon.class); credentialsElement.setAttribute("username", filteredResourcesWebAddon.getGeneratedSettingsUsernameTemplate()); credentialsElement.setAttribute("passwd", "@PASS_ATTR_PLACEHOLDER@"); rootNode.addContent(credentialsElement); } Element resolversElement = new Element("resolvers"); Element chainElement = new Element("chain"); chainElement.setAttribute("name", "main"); String resolverName = resolverPanel.getResolverName(); resolverName = StringUtils.isNotBlank(resolverName) ? resolverName : "public"; if (resolverPanel.useIbiblioResolver()) { Element ibiblioElement = new Element("ibiblio"); ibiblioElement.setAttribute("name", resolverName); ibiblioElement.setAttribute("m2compatible", Boolean.TRUE.toString()); ibiblioElement.setAttribute("root", resolverPanel.getFullRepositoryUrl()); chainElement.addContent(ibiblioElement); } else { Element urlElement = new Element("url"); urlElement.setAttribute("name", resolverName); urlElement.setAttribute("m2compatible", Boolean.toString(resolverPanel.isM2Compatible())); Element artifactPatternElement = new Element("artifact"); artifactPatternElement.setAttribute("pattern", resolverPanel.getFullArtifactPattern()); urlElement.addContent(artifactPatternElement); Element ivyPatternElement = new Element("ivy"); ivyPatternElement.setAttribute("pattern", resolverPanel.getFullDescriptorPattern()); urlElement.addContent(ivyPatternElement); chainElement.addContent(urlElement); } resolversElement.addContent(chainElement); rootNode.addContent(resolversElement); document.setRootElement(rootNode); String result = new XMLOutputter(Format.getPrettyFormat()).outputString(document); // after the xml is generated replace the password placeholder with the template placeholder (otherwise jdom // escapes this string) FilteredResourcesWebAddon filteredResourcesWebAddon = addonsManager .addonByType(FilteredResourcesWebAddon.class); return result.replace("@PASS_ATTR_PLACEHOLDER@", filteredResourcesWebAddon.getGeneratedSettingsUserCredentialsTemplate(false)); }