本文整理汇总了Java中org.jdom2.Element.addNamespaceDeclaration方法的典型用法代码示例。如果您正苦于以下问题:Java Element.addNamespaceDeclaration方法的具体用法?Java Element.addNamespaceDeclaration怎么用?Java Element.addNamespaceDeclaration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom2.Element
的用法示例。
在下文中一共展示了Element.addNamespaceDeclaration方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInternalDecode
import org.jdom2.Element; //导入方法依赖的package包/类
@Test
void testInternalDecode() throws Exception {
Namespace rootNs = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Context context = new Context();
Element element = new Element("observation", rootNs);
element.addContent(new Element("templateId", rootNs).setAttribute("root", TemplateId.ACI_AGGREGATE_COUNT.getTemplateId(context)));
element.addContent(new Element("value", rootNs).setAttribute("value", "450").setAttribute("type", "INT", ns));
element.addNamespaceDeclaration(ns);
Node thisNode = new Node();
AggregateCountDecoder instance = new AggregateCountDecoder(context);
instance.setNamespace(element, instance);
instance.internalDecode(element, thisNode);
assertThat(thisNode.getValue("aggregateCount"))
.isEqualTo("450");
}
示例2: makeClinicalDocument
import org.jdom2.Element; //导入方法依赖的package包/类
private Element makeClinicalDocument(String programName) {
Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Element clinicalDocument = new Element("ClinicalDocument", rootns);
clinicalDocument.addNamespaceDeclaration(ns);
Element informationRecipient = prepareInfoRecipient(rootns, programName);
Element documentationOf = prepareDocumentationElement(rootns);
Element component = prepareComponentElement(rootns);
clinicalDocument.addContent(informationRecipient);
clinicalDocument.addContent(documentationOf);
clinicalDocument.addContent(component);
return clinicalDocument;
}
示例3: testInternalDecode
import org.jdom2.Element; //导入方法依赖的package包/类
@Test
void testInternalDecode() throws Exception {
//set-up
Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Element element = new Element("organizer", rootns);
Element templateIdElement = new Element("templateId", rootns)
.setAttribute("root","2.16.840.1.113883.10.20.27.3.28");
Element referenceElement = new Element("reference", rootns);
Element externalDocumentElement = new Element("externalDocument", rootns);
Element idElement = new Element("id", rootns).setAttribute("extension", MEASURE_ID);
externalDocumentElement.addContent(idElement);
referenceElement.addContent(externalDocumentElement);
element.addContent(templateIdElement);
element.addContent(referenceElement);
element.addNamespaceDeclaration(ns);
Node thisNode = new Node();
AciNumeratorDenominatorDecoder objectUnderTest = new AciNumeratorDenominatorDecoder(new Context());
objectUnderTest.setNamespace(element, objectUnderTest);
//execute
objectUnderTest.internalDecode(element, thisNode);
//assert
assertThat(thisNode.getValue("measureId"))
.isEqualTo(MEASURE_ID);
}
示例4: internalDecodeReturnsTreeContinue
import org.jdom2.Element; //导入方法依赖的package包/类
@Test
void internalDecodeReturnsTreeContinue() {
//set-up
AciMeasurePerformedRnRDecoder objectUnderTest = new AciMeasurePerformedRnRDecoder(new Context());
Namespace rootns = Namespace.getNamespace("urn:hl7-org:v3");
Namespace ns = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Element element = new Element("organizer", rootns);
Element templateIdElement = new Element("templateId", rootns)
.setAttribute("root","2.16.840.1.113883.10.20.27.3.28");
Element referenceElement = new Element("reference", rootns);
Element externalDocumentElement = new Element("externalDocument", rootns);
Element idElement = new Element("id", rootns).setAttribute("extension", MEASURE_ID);
externalDocumentElement.addContent(idElement);
referenceElement.addContent(externalDocumentElement);
element.addContent(templateIdElement);
element.addContent(referenceElement);
element.addNamespaceDeclaration(ns);
Node aciMeasurePerformedNode = new Node();
objectUnderTest.setNamespace(element, objectUnderTest);
//execute
DecodeResult decodeResult = objectUnderTest.internalDecode(element, aciMeasurePerformedNode);
//assert
assertThat(decodeResult)
.isEqualTo(DecodeResult.TREE_CONTINUE);
String actualMeasureId = aciMeasurePerformedNode.getValue("measureId");
assertThat(actualMeasureId)
.isEqualTo(MEASURE_ID);
}
示例5: 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;
}
示例6: generateMets
import org.jdom2.Element; //导入方法依赖的package包/类
/**
* Creates a list of METS documents for the given Solr document list.
*
* @param records
* @param totalHits
* @param firstRow
* @param numRows
* @param handler
* @param recordType "GetRecord" or "ListRecords"
* @return
* @throws IOException
* @throws JDOMException
* @throws SolrServerException
*/
private Element generateMets(List<SolrDocument> records, long totalHits, int firstRow, int numRows, RequestHandler handler, String recordType)
throws JDOMException, IOException, SolrServerException {
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
Element xmlListRecords = new Element(recordType, xmlns);
Namespace mets = Namespace.getNamespace("mets", "http://www.loc.gov/METS/");
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace mods = Namespace.getNamespace("mods", "http://www.loc.gov/mods/v3");
Namespace dv = Namespace.getNamespace("dv", "http://dfg-viewer.de/");
Namespace xlink = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");
if (records.size() < numRows) {
numRows = records.size();
}
for (SolrDocument doc : records) {
String url = new StringBuilder(DataManager.getInstance().getConfiguration().getDocumentResolverUrl()).append(doc.getFieldValue(
SolrConstants.PI_TOPSTRUCT)).toString();
String xml = Utils.getWebContent(url);
if (StringUtils.isEmpty(xml)) {
xmlListRecords.addContent(new ErrorCode().getCannotDisseminateFormat());
continue;
}
org.jdom2.Document metsFile = Utils.getDocumentFromString(xml, null);
Element mets_root = metsFile.getRootElement();
Element newmets = new Element("mets", mets);
newmets.addNamespaceDeclaration(xsi);
newmets.addNamespaceDeclaration(mods);
newmets.addNamespaceDeclaration(dv);
newmets.addNamespaceDeclaration(xlink);
newmets.setAttribute("schemaLocation",
"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/version17/mets.v1-7.xsd",
xsi);
newmets.addContent(mets_root.cloneContent());
Element record = new Element("record", xmlns);
Element header = getHeader(doc, null, handler);
record.addContent(header);
Element metadata = new Element("metadata", xmlns);
metadata.addContent(newmets);
record.addContent(metadata);
xmlListRecords.addContent(record);
}
// Create resumption token
if (totalHits > firstRow + numRows) {
Element resumption = createResumptionTokenAndElement(totalHits, firstRow + numRows, xmlns, handler);
xmlListRecords.addContent(resumption);
}
return xmlListRecords;
}
示例7: generateEpicurElement
import org.jdom2.Element; //导入方法依赖的package包/类
private static Element generateEpicurElement(String urn, Long dateCreated, Long dateUpdated, Long dateDeleted) {
Namespace xmlns = Namespace.getNamespace("urn:nbn:de:1111-2004033116");
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace epicurNamespace = Namespace.getNamespace("epicur", "urn:nbn:de:1111-2004033116");
Element epicur = new Element("epicur", xmlns);
epicur.addNamespaceDeclaration(xsi);
epicur.addNamespaceDeclaration(epicurNamespace);
epicur.setAttribute("schemaLocation", "urn:nbn:de:1111-2004033116 http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd", xsi);
String status = "urn_new";
// xsi:schemaLocation="urn:nbn:de:1111-2004033116 http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd"
// xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
// xmlns:epicur="urn:nbn:de:1111-2004033116"
// xmlns="urn:nbn:de:1111-2004033116"
if (dateDeleted != null) {
status = "url_delete";
} else {
if (dateCreated != null && dateUpdated != null) {
if (dateUpdated > dateCreated) {
status = "url_update_general";
} else {
status = "urn_new";
}
} else {
status = "urn_new";
}
}
epicur.addContent(generateAdministrativeData(status, xmlns));
Element record = new Element("record", xmlns);
Element schemaIdentifier = new Element("identifier", xmlns);
schemaIdentifier.setAttribute("scheme", "urn:nbn:de");
schemaIdentifier.setText(urn);
record.addContent(schemaIdentifier);
Element resource = new Element("resource", xmlns);
record.addContent(resource);
Element identifier = new Element("identifier", xmlns);
identifier.setAttribute("origin", "original");
identifier.setAttribute("role", "primary");
identifier.setAttribute("scheme", "url");
identifier.setAttribute("type", "frontpage");
identifier.setText(DataManager.getInstance().getConfiguration().getUrnResolverUrl() + urn);
resource.addContent(identifier);
Element format = new Element("format", xmlns);
format.setAttribute("scheme", "imt");
format.setText("text/html");
resource.addContent(format);
epicur.addContent(record);
return epicur;
}
示例8: generateEpicurPageElement
import org.jdom2.Element; //导入方法依赖的package包/类
/**
*
* @param urn
* @param dateCreated
* @param dateUpdated
* @param dateDeleted
* @return
*/
private static Element generateEpicurPageElement(String urn, Long dateCreated, Long dateUpdated, Long dateDeleted) {
Namespace xmlns = Namespace.getNamespace("urn:nbn:de:1111-2004033116");
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
Namespace epicurNamespace = Namespace.getNamespace("epicur", "urn:nbn:de:1111-2004033116");
Element epicur = new Element("epicur", xmlns);
epicur.addNamespaceDeclaration(xsi);
epicur.addNamespaceDeclaration(epicurNamespace);
epicur.setAttribute("schemaLocation", "urn:nbn:de:1111-2004033116 http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd", xsi);
String status = "urn_new";
// xsi:schemaLocation="urn:nbn:de:1111-2004033116 http://www.persistent-identifier.de/xepicur/version1.0/xepicur.xsd"
// xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
// xmlns:epicur="urn:nbn:de:1111-2004033116"
// xmlns="urn:nbn:de:1111-2004033116"
// /*
// TODO add this after dnb can handle status updates
if (dateDeleted != null) {
status = "url_delete";
} else if (dateCreated != null && dateUpdated != null) {
if (dateUpdated > dateCreated) {
status = "url_update_general";
} else {
status = "urn_new";
}
}
// */
epicur.addContent(generateAdministrativeData(status, xmlns));
Element record = new Element("record", xmlns);
Element schemaIdentifier = new Element("identifier", xmlns);
schemaIdentifier.setAttribute("scheme", "urn:nbn:de");
schemaIdentifier.setText(urn);
record.addContent(schemaIdentifier);
Element resource = new Element("resource", xmlns);
record.addContent(resource);
Element identifier = new Element("identifier", xmlns);
identifier.setAttribute("origin", "original");
identifier.setAttribute("role", "primary");
identifier.setAttribute("scheme", "url");
identifier.setAttribute("type", "frontpage");
identifier.setText(DataManager.getInstance().getConfiguration().getUrnResolverUrl() + urn);
resource.addContent(identifier);
Element format = new Element("format", xmlns);
format.setAttribute("scheme", "imt");
format.setText("text/html");
resource.addContent(format);
epicur.addContent(record);
return epicur;
}
示例9: generateLido
import org.jdom2.Element; //导入方法依赖的package包/类
/**
* Creates LIDO records
*
* @param records
* @param totalHits
* @param firstRow
* @param numRows
* @param handler
* @param recordType "GetRecord" or "ListRecords"
* @return
* @throws IOException
* @throws JDOMException
* @throws SolrServerException
*/
private Element generateLido(List<SolrDocument> records, long totalHits, int firstRow, int numRows, RequestHandler handler, String recordType)
throws JDOMException, IOException, SolrServerException {
Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
Element xmlListRecords = new Element(recordType, xmlns);
Namespace lido = Namespace.getNamespace("lido", "http://www.lido-schema.org");
Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
if (records.size() < numRows) {
numRows = records.size();
}
for (SolrDocument doc : records) {
String url = new StringBuilder(DataManager.getInstance().getConfiguration().getDocumentResolverUrl()).append(doc.getFieldValue(
SolrConstants.PI_TOPSTRUCT)).toString();
String xml = Utils.getWebContent(url);
if (StringUtils.isEmpty(xml)) {
xmlListRecords.addContent(new ErrorCode().getCannotDisseminateFormat());
continue;
}
org.jdom2.Document lidoFile = Utils.getDocumentFromString(xml, null);
Element lidoRoot = lidoFile.getRootElement();
Element newLido = new Element("lido", lido);
newLido.addNamespaceDeclaration(xsi);
newLido.setAttribute(new Attribute("schemaLocation", "http://www.lido-schema.org http://www.lido-schema.org/schema/v1.0/lido-v1.0.xsd",
xsi));
newLido.addContent(lidoRoot.cloneContent());
Element record = new Element("record", xmlns);
Element header = getHeader(doc, null, handler);
record.addContent(header);
Element metadata = new Element("metadata", xmlns);
metadata.addContent(newLido);
// metadata.addContent(mets_root.cloneContent());
record.addContent(metadata);
xmlListRecords.addContent(record);
}
// Create resumption token
if (totalHits > firstRow + numRows) {
Element resumption = createResumptionTokenAndElement(totalHits, firstRow + numRows, xmlns, handler);
xmlListRecords.addContent(resumption);
}
return xmlListRecords;
}