当前位置: 首页>>代码示例>>Java>>正文


Java Element.setAttribute方法代码示例

本文整理汇总了Java中org.jdom2.Element.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.setAttribute方法的具体用法?Java Element.setAttribute怎么用?Java Element.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.Element的用法示例。


在下文中一共展示了Element.setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeInvalidChildReturnsError

import org.jdom2.Element; //导入方法依赖的package包/类
@Test
void decodeInvalidChildReturnsError() {
	Context context = new Context();
	TestHelper.mockDecoder(context, TestChildDecodeError.class, new ComponentKey(TemplateId.CONTINUOUS_VARIABLE_MEASURE_VALUE_CMS, Program.ALL));
	TestHelper.mockDecoder(context, TestChildNoAction.class, new ComponentKey(TemplateId.PLACEHOLDER, Program.ALL));

	Element testElement = new Element("testElement");
	Element testChildElement = new Element("templateId");
	testChildElement.setAttribute("root", TemplateId.CONTINUOUS_VARIABLE_MEASURE_VALUE_CMS.getRoot());

	testElement.getChildren().add(testChildElement);
	Node testNode = new Node();

	QrdaXmlDecoder objectUnderTest = new DefaultQrdaXmlDecoder(context);
	objectUnderTest.decode(testElement, testNode);

	assertWithMessage("Child Node was not encountered")
			.that(errorDecode)
			.isTrue();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:21,代码来源:QrdaXmlDecoderTest.java

示例2: createResumptionTokenAndElement

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * 
 * @param totalHits
 * @param cursor
 * @param xmlns
 * @param handler
 * @return
 */
private Element createResumptionTokenAndElement(long totalHits, int cursor, Namespace xmlns, RequestHandler handler) {
    long now = System.currentTimeMillis();
    long time = now + expiration;
    ResumptionToken token = new ResumptionToken("oai_" + System.currentTimeMillis(), totalHits, cursor, time, handler);
    try {
        saveToken(token);
    } catch (IOException e) {
        // do nothing
    }
    Element eleResumptionToken = new Element("resumptionToken", xmlns);
    eleResumptionToken.setAttribute("expirationDate", Utils.convertDate(time));
    eleResumptionToken.setAttribute("completeListSize", String.valueOf(totalHits));
    eleResumptionToken.setAttribute("cursor", String.valueOf(cursor));
    eleResumptionToken.setText(token.getTokenName());

    return eleResumptionToken;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:26,代码来源:XMLGeneration.java

示例3: prepareComponentElement

import org.jdom2.Element; //导入方法依赖的package包/类
private Element prepareComponentElement(Namespace rootns) {
	Element component = new Element("component", rootns);
	Element structuredBody = new Element("structuredBody", rootns);
	Element componentTwo = new Element("component", rootns);
	Element aciSectionElement = new Element("templateId", rootns);
	aciSectionElement.setAttribute("root", TemplateId.ACI_SECTION.getRoot());
	aciSectionElement.setAttribute("extension", TemplateId.ACI_SECTION.getExtension());

	componentTwo.addContent(aciSectionElement);
	structuredBody.addContent(componentTwo);
	component.addContent(structuredBody);
	return component;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:14,代码来源:ClinicalDocumentDecoderTest.java

示例4: getOaiPmhElement

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * creates root element for oai protocol
 * 
 * @param elementName
 * @return
 */
public Element getOaiPmhElement(String elementName) {
    Element oaiPmh = new Element(elementName);

    oaiPmh.setNamespace(Namespace.getNamespace("http://www.openarchives.org/OAI/2.0/"));
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    oaiPmh.addNamespaceDeclaration(xsi);
    oaiPmh.setAttribute("schemaLocation", "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd", xsi);
    return oaiPmh;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:16,代码来源:XMLGeneration.java

示例5: addToOutput

import org.jdom2.Element; //导入方法依赖的package包/类
public void addToOutput(Element output) {
    Element authorElement = new Element("author");
    authorElement.addContent((new Element("surname")).addContent(surname));
    authorElement.addContent((new Element("middlename")).addContent(middlename));
    authorElement.addContent((new Element("firstname")).addContent(firstname));
    
    String name = (middlename.isEmpty()) ? firstname + " " + surname : firstname + " " + middlename + " " + surname;
    authorElement.setAttribute("name", name);
    
    authorElement.addContent((new Element("institution")).addContent(institution));
    authorElement.addContent((new Element("department")).addContent(department));
    authorElement.addContent((new Element("address")).addContent(address));
    authorElement.addContent((new Element("scopusAuthorID")).addContent(scopusAuthorID));
    authorElement.addContent((new Element("ResearcherID")).addContent(researcherID));
    authorElement.addContent((new Element("orcid")).addContent(orcid));
    authorElement.addContent((new Element("gnd")).addContent(gnd));
    authorElement.addContent((new Element("lsfID")).addContent(lsfID));
    authorElement.addContent((new Element("hIndex")).addContent(hIndex));
    authorElement.addContent((new Element("researchGate")).addContent(String.valueOf(researchGate)));
    authorElement.addContent((new Element("numberOfPublicationsUniBib")).addContent(String.valueOf(numberOfPublicationsUniBib)));
    authorElement.addContent((new Element("numberOfPublicationsScopus")).addContent(String.valueOf(numberOfPublicationsScopus)));
    authorElement.addContent((new Element("numberOfPublicationsWoS")).addContent(String.valueOf(numberOfPublicationsWoS)));
    authorElement.addContent((new Element("linkGoogleProfile")).addContent(String.valueOf(linkGoogleProfile)));
    authorElement.addContent((new Element("linkHomepage")).addContent(String.valueOf(linkHomepage)));
    authorElement.addContent((new Element("foundInDatabase")).addContent(String.valueOf(foundInDatabase)));
    output.addContent(authorElement);
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:28,代码来源:PublicationAuthor.java

示例6: generateEpicurHeader

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * generates header for epicur format
 * 
 * @param doc
 * @param dateUpdated
 * @return
 */
private static Element generateEpicurHeader(SolrDocument doc, long dateUpdated) {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element header = new Element("header", xmlns);
    Element identifier = new Element("identifier", xmlns);
    identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + (String) doc.getFieldValue(
            "URN"));
    header.addContent(identifier);

    Element datestamp = new Element("datestamp", xmlns);
    datestamp.setText(parseDate(dateUpdated));
    header.addContent(datestamp);
    // setSpec
    List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
    if (!setSpecFields.isEmpty()) {
        for (String setSpecField : setSpecFields) {
            if (doc.containsKey(setSpecField)) {
                for (Object fieldValue : doc.getFieldValues(setSpecField)) {
                    // TODO translation
                    Element setSpec = new Element("setSpec", xmlns);
                    setSpec.setText((String) fieldValue);
                    header.addContent(setSpec);
                }
            }
        }
    }
    // status="deleted"
    if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
        header.setAttribute("status", "deleted");
    }

    return header;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:40,代码来源:XMLGeneration.java

示例7: generateEpicurPageHeader

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * 
 * @param doc
 * @param urn
 * @param dateUpdated
 * @return
 */
private static Element generateEpicurPageHeader(SolrDocument doc, String urn, long dateUpdated) {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element header = new Element("header", xmlns);

    Element identifier = new Element("identifier", xmlns);
    identifier.setText(DataManager.getInstance().getConfiguration().getOaiIdentifier().get("repositoryIdentifier") + urn);
    header.addContent(identifier);

    Element datestamp = new Element("datestamp", xmlns);
    datestamp.setText(parseDate(dateUpdated));
    header.addContent(datestamp);
    // setSpec
    List<String> setSpecFields = DataManager.getInstance().getConfiguration().getSetSpecFieldsForMetadataFormat(Metadata.epicur.name());
    if (!setSpecFields.isEmpty()) {
        for (String setSpecField : setSpecFields) {
            if (doc.containsKey(setSpecField)) {
                for (Object fieldValue : doc.getFieldValues(setSpecField)) {
                    // TODO translation
                    Element setSpec = new Element("setSpec", xmlns);
                    setSpec.setText((String) fieldValue);
                    header.addContent(setSpec);
                }
            }
        }
    }
    // status="deleted"
    if (doc.getFieldValues(SolrConstants.DATEDELETED) != null) {
        header.setAttribute("status", "deleted");
    }

    return header;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:40,代码来源:XMLGeneration.java

示例8: generateAdministrativeData

import org.jdom2.Element; //导入方法依赖的package包/类
private static Element generateAdministrativeData(String status, Namespace xmlns) {
    // Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element administrative_data = new Element("administrative_data", xmlns);
    Element delivery = new Element("delivery", xmlns);
    Element update_status = new Element("update_status", xmlns);
    update_status.setAttribute("type", status);
    delivery.addContent(update_status);
    Element transfer = new Element("transfer", xmlns);
    transfer.setAttribute("type", "oai");
    delivery.addContent(transfer);
    administrative_data.addContent(delivery);
    return administrative_data;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:14,代码来源:XMLGeneration.java

示例9: getBadArgument

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * required argument is missing, argument has wrong syntax or argument has invalid value
 * 
 * @return
 */
public Element getBadArgument() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "badArgument");
	error.setText("The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java

示例10: getBadResumptionToken

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * resumptionToken is expired, invalid, not found
 * 
 * @return
 */
public Element getBadResumptionToken() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "badResumptionToken");
	error.setText("The value of the resumptionToken argument is invalid or expired.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java

示例11: getNoSetHierarchy

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * there are no sets in repository
 * 
 * @return
 */
public Element getNoSetHierarchy() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "noSetHierarchy");
	error.setText("The repository does not support sets.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java

示例12: prepareOutput

import org.jdom2.Element; //导入方法依赖的package包/类
public Element prepareOutput() {
    Element citationStatistics = new Element("citationStatistics");
    citationStatistics.setAttribute("source", source);
    citationStatistics.addContent(new Element("totalCitations").setText(String.valueOf(totalCitations)));
    citationStatistics.addContent(new Element("uncited").setText(String.valueOf(uncited)));
    citationStatistics.addContent(new Element("numberOfDocumentsWithCitationData").setText(String.valueOf(numberOfDocumentsWithCitationData)));
    citationStatistics.addContent(new Element("hIndex").setText(String.valueOf(hIndex)));
    return citationStatistics;
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:10,代码来源:CitationStatistics.java

示例13: getIdDoesNotExist

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * identifier does not exist
 * 
 * @return
 */
public Element getIdDoesNotExist() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "idDoesNotExist");
	error.setText(" 	The value of the identifier argument is unknown or illegal in this repository.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java

示例14: getNoRecordsMatch

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * query returns no hits
 * 
 * @return
 */
public Element getNoRecordsMatch() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "noRecordsMatch");
	error.setText("The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java

示例15: getNoMetadataFormats

import org.jdom2.Element; //导入方法依赖的package包/类
/**
 * for given identifier the metadata format used in metadataPrefix is not provided
 * 
 * @return
 */
public Element getNoMetadataFormats() {
	Element error = new Element("error", xmlns);
	error.setAttribute("code", "noMetadataFormats");
	error.setText("There are no metadata formats available for the specified item.");
	return error;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:12,代码来源:ErrorCode.java


注:本文中的org.jdom2.Element.setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。