當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。