當前位置: 首頁>>代碼示例>>Java>>正文


Java Namespace類代碼示例

本文整理匯總了Java中org.jdom2.Namespace的典型用法代碼示例。如果您正苦於以下問題:Java Namespace類的具體用法?Java Namespace怎麽用?Java Namespace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Namespace類屬於org.jdom2包,在下文中一共展示了Namespace類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepareDocumentationElement

import org.jdom2.Namespace; //導入依賴的package包/類
private Element prepareDocumentationElement(Namespace rootns) {
	Element documentationOf = new Element("documentationOf", rootns);
	Element serviceEvent = new Element("serviceEvent", rootns);
	Element performer = new Element("performer", rootns);
	Element assignedEntity = new Element("assignedEntity", rootns);
	Element nationalProviderIdentifier = new Element("id", rootns)
			.setAttribute("root", "2.16.840.1.113883.4.6")
			.setAttribute("extension", "2567891421");

	Element representedOrganization = prepareRepOrgWithTaxPayerId(rootns);
	assignedEntity.addContent(representedOrganization);
	assignedEntity.addContent(nationalProviderIdentifier);
	performer.addContent(assignedEntity);
	serviceEvent.addContent(performer);
	documentationOf.addContent(serviceEvent);
	return documentationOf;
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:18,代碼來源:ClinicalDocumentDecoderTest.java

示例2: testInternalDecode

import org.jdom2.Namespace; //導入依賴的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");
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:22,代碼來源:AggregateCountDecoderTest.java

示例3: createListIdentifiers

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * for the server request ?verb=ListIdentifiers this method build the xml section
 * 
 * @param handler
 * @param firstRow
 * @param numRows
 * @return
 * @throws SolrServerException
 */
public Element createListIdentifiers(RequestHandler handler, int firstRow, int numRows) throws SolrServerException {
    Map<String, String> datestamp = filterDatestampFromRequest(handler);
    SolrDocumentList listIdentifiers = solr.getListIdentifiers(datestamp, firstRow, numRows, false);
    if (listIdentifiers == null || listIdentifiers.isEmpty()) {
        return new ErrorCode().getNoRecordsMatch();
    }

    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Element xmlListIdentifiers = new Element("ListIdentifiers", xmlns);
    long totalHits = listIdentifiers.getNumFound();
    for (int i = 0; i < listIdentifiers.size(); i++) {
        SolrDocument doc = listIdentifiers.get(i);
        Element header = getHeader(doc, null, handler);
        xmlListIdentifiers.addContent(header);
    }

    // Create resumption token
    if (totalHits > firstRow + numRows) {
        Element resumption = createResumptionTokenAndElement(totalHits, firstRow + numRows, xmlns, handler);
        xmlListIdentifiers.addContent(resumption);
    }

    return xmlListIdentifiers;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:34,代碼來源:XMLGeneration.java

示例4: createMetadataFormats

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * for the server request ?verb=ListMetadataFormats this method build the xml section
 * 
 * @return
 */
public Element createMetadataFormats() {
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    if (Metadata.values().length == 0) {
        return new ErrorCode().getNoMetadataFormats();
    }
    Element listMetadataFormats = new Element("ListMetadataFormats", xmlns);
    for (Metadata m : Metadata.values()) {
        // logger.trace("{}: {}", m.getMetadataPrefix(), DataManager.getInstance().getConfiguration().isMetadataFormatEnabled(m.name()));
        if (m.isOaiSet() && DataManager.getInstance().getConfiguration().isMetadataFormatEnabled(m.name())) {
            Element metadataFormat = new Element("metadataFormat", xmlns);
            Element metadataPrefix = new Element("metadataPrefix", xmlns);
            metadataPrefix.setText(m.getMetadataPrefix());
            Element schema = new Element("schema", xmlns);
            schema.setText(m.getSchema());
            Element metadataNamespace = new Element("metadataNamespace", xmlns);
            metadataNamespace.setText(m.getMetadataNamespace());
            metadataFormat.addContent(metadataPrefix);
            metadataFormat.addContent(schema);
            metadataFormat.addContent(metadataNamespace);
            listMetadataFormats.addContent(metadataFormat);
        }
    }
    return listMetadataFormats;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:30,代碼來源:XMLGeneration.java

示例5: createResumptionTokenAndElement

import org.jdom2.Namespace; //導入依賴的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

示例6: initNamespaces

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Adds relevant XML namespaces to the list of available namespace objects.
 * 
 * @should add custom namespaces correctly
 */
public void initNamespaces() {
    namespaces.clear();
    namespaces.put("xml", Namespace.getNamespace("xml", "http://www.w3.org/XML/1998/namespace"));
    namespaces.put("mets", Namespace.getNamespace("mets", "http://www.loc.gov/METS/"));
    namespaces.put("mods", Namespace.getNamespace("mods", "http://www.loc.gov/mods/v3"));
    namespaces.put("gdz", Namespace.getNamespace("gdz", "http://gdz.sub.uni-goettingen.de/"));
    namespaces.put("xlink", Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink"));
    namespaces.put("dv", Namespace.getNamespace("dv", "http://dfg-viewer.de/"));
    namespaces.put("lido", Namespace.getNamespace("lido", "http://www.lido-schema.org"));
    namespaces.put("mix", Namespace.getNamespace("mix", "http://www.loc.gov/mix/v20"));
    namespaces.put("mm", Namespace.getNamespace("mm", "http://www.mycore.de/metsmaker/v1"));
    namespaces.put("tei", Namespace.getNamespace("tei", "http://www.tei-c.org/ns/1.0"));

    Map<String, String> additionalNamespaces = getListConfiguration("init.namespaces");
    if (additionalNamespaces != null) {
        for (String key : additionalNamespaces.keySet()) {
            namespaces.put(key, Namespace.getNamespace(key, additionalNamespaces.get(key)));
            logger.info("Added custom namespace '{}'.", key);
        }
    }
}
 
開發者ID:intranda,項目名稱:goobi-viewer-indexer,代碼行數:27,代碼來源:Configuration.java

示例7: getPreferredRubricLabel

import org.jdom2.Namespace; //導入依賴的package包/類
protected static String getPreferredRubricLabel(Element classElement, String lang) {
	Iterator<Element> it = classElement.getChildren(ClamlConstants.RUBRIC_ELEMENT).iterator();
	String label = null;
	while (it.hasNext() && label == null) {
		Element rubric = it.next();
		if (ClamlConstants.RUBRIC_KIND_PREFFERD_ATTR.equals(rubric.getAttributeValue(ClamlConstants.KIND_ATTR))) {
			Element labelElement = rubric.getChild(ClamlConstants.LABEL_ELEMENT);
			if (labelElement != null) {
				if (CommonUtil.isEmptyString(lang) || lang.equals(labelElement.getAttributeValue(ClamlConstants.XML_LANG, Namespace.XML_NAMESPACE))) {
					label = labelElement.getTextTrim();
				}
			} else {
				throw new IllegalArgumentException(getKind(classElement) + " " + getCode(classElement) + ": " + ClamlConstants.RUBRIC_ELEMENT + " without "
						+ ClamlConstants.LABEL_ELEMENT);
			}
		}
	}
	return label;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:20,代碼來源:ClamlClassProcessor.java

示例8: getNameSpaces

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Returns a List of NamespaceURIs used in the subtree of node
 * @param element
 *            {@link Element}
 * @return {@link java.util.List}&lt;{@link String}>
 * @author sholzer (14.04.2015)
 */
private List<String> getNameSpaces(Element element) {
    List<String> namespaces = new LinkedList<>();
    for (Namespace ns : element.getNamespacesInScope()) {
        boolean flag = true;
        for (String s : namespaces) {
            if (ns.getURI().equals(s)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            namespaces.add(ns.getURI());
        }
    }

    return namespaces;
}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:25,代碼來源:DocumentValidatorImpl.java

示例9: ThirdBeanTest

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Simple Spring Beans test case.
 * @throws Exception
 *             when something somewhere goes wrong
 * @author sholzer (31.03.2015)
 */
@Test
public void ThirdBeanTest() throws Exception {
    String mergeSchemaLocation = resources + "mergeschemas";

    String bean = "http://www.springframework.org/schema/beans";
    String aop = "http://www.springframework.org/schema/aop";

    Document base = JDom2Util.getInstance().getDocument(resources + "bases/Beans3.xml");
    Document patch = JDom2Util.getInstance().getDocument(resources + "patches/Beans3.xml");
    LeXeMerger testMerger = new LeXeMerger(mergeSchemaLocation);
    Element result =
        testMerger.merge(base.getRootElement(), patch.getRootElement(),
            ConflictHandlingType.PATCHOVERWRITE);
    assertEquals("Not as much bean as expected", result.getChildren("bean", Namespace.getNamespace(bean))
        .size(), 2);
    assertTrue("no aop:config found",
        result.getChildren("config", Namespace.getNamespace(aop)).size() == 1);
    Element config = result.getChild("config", Namespace.getNamespace(aop));
    assertEquals("Not as much pointcut as expected", 2,
        config.getChildren("pointcut", Namespace.getNamespace(aop)).size());
    assertEquals("Not as much advisor as expected", 2,
        config.getChildren("advisor", Namespace.getNamespace(aop)).size());

}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:31,代碼來源:FullFunctionalityTest.java

示例10: SecondTestWithDifferentPrefixes

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Test case as in {@link FirstWorkingBuild#SecondTest()}. Patch uses another prefix for its namespace.
 * The prefix used in the result should be the same as in the base
 * @throws Exception
 *             when something somewhere goes wrong
 * @author sholzer (31.03.2015)
 */
@Test
public void SecondTestWithDifferentPrefixes() throws Exception {
    String mergeSchemaLocation = resources + "mergeschemas/SecondMergeSchema.xml";
    String uri = "http://www.example.org/SecondSchema";
    Document base = JDom2Util.getInstance().getDocument(resources + "bases/SecondBase.xml");
    Document patch =
        JDom2Util.getInstance().getDocument(resources + "patches/SecondPatchWithOtherPrefixes.xml");
    LeXeMerger testMerger = new LeXeMerger(mergeSchemaLocation);
    Element result =
        testMerger.merge(base.getRootElement(), patch.getRootElement(),
            ConflictHandlingType.PATCHATTACHOROVERWRITE);
    assertTrue("No B Element found", result.getChildren("B", Namespace.getNamespace(uri)).size() == 1);
    Element b = result.getChildren("B", Namespace.getNamespace(uri)).get(0);
    assertTrue("Wrong id at B element", b.getAttribute("id").getValue().equals("abc;def"));
    assertTrue("No B Element found", (result.getChildren("C", Namespace.getNamespace(uri))).size() == 1);
    Element c = result.getChildren("C", Namespace.getNamespace(uri)).get(0);
    assertTrue("Wrong number of Ca elements",
        (c.getChildren("Ca", Namespace.getNamespace(uri))).size() == 1);
    assertTrue("Wrong content of Ca",
        JDom2Util.getInstance().getTextNodes(c.getChildren("Ca", Namespace.getNamespace(uri)).get(0))
            .get(0).getText().equals("0"));
    int numberOfCb = (c.getChildren("Cb", Namespace.getNamespace(uri))).size();
    assertTrue("Wrong number of Cb elements. Found " + numberOfCb, numberOfCb == 3);

}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:33,代碼來源:FirstWorkingBuild.java

示例11: SecondBeanTest

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Simple Spring Beans test case
 * @throws Exception
 *             when something somewhere goes wrong
 * @author sholzer (31.03.2015)
 */
@Test
public void SecondBeanTest() throws Exception {
    String mergeSchemaLocation = resources + "mergeschemas/BeansMergeSchema.xml";
    String namespaceUri = "http://www.springframework.org/schema/beans";

    Document base = JDom2Util.getInstance().getDocument(resources + "bases/Beans2.xml");
    Document patch = JDom2Util.getInstance().getDocument(resources + "patches/Beans2.xml");
    LeXeMerger testMerger = new LeXeMerger(mergeSchemaLocation);
    Element result =
        testMerger.merge(base.getRootElement(), patch.getRootElement(),
            ConflictHandlingType.PATCHOVERWRITE);
    assertEquals("Not all bean elements found", 2,
        result.getChildren("bean", Namespace.getNamespace("http://www.springframework.org/schema/beans"))
            .size());
    List<Element> beanNodeList = result.getChildren("bean", Namespace.getNamespace(namespaceUri));
    Element bean1 = beanNodeList.get(0);

    assertEquals("wrong parent for bean1", "bean2", bean1.getAttribute("parent").getValue());
    assertEquals("No properties found", 1,
        bean1.getChildren("property", Namespace.getNamespace(namespaceUri)).size());

}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:29,代碼來源:FirstWorkingBuild.java

示例12: testAdditionalNamespaceDefinition

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Tests the merge process if the merge schema has multiple namespace definitions. The setup of
 * {@link FirstWorkingBuild#FirstTest()} is used with a modified MergeSchema
 * @throws Exception
 *             when something unexpected happens
 * @author sholzer (Jul 30, 2015)
 */
@Test
public void testAdditionalNamespaceDefinition() throws Exception {
    final String mergeSchemaLocation = pathRoot + "mergeschemas/CobiGenIntegration/";
    final String uri = "http://www.example.org/FirstXMLSchema";
    Document base = JDom2Util.getInstance().getDocument(pathRoot + "bases/FirstBase.xml");
    Document patch = JDom2Util.getInstance().getDocument(pathRoot + "patches/FirstPatch.xml");

    LeXeMerger testObject = LeXeMeFactory.build(mergeSchemaLocation);
    Element result =
        testObject.merge(base.getRootElement(), patch.getRootElement(),
            ConflictHandlingType.PATCHATTACHOROVERWRITE);

    List<Element> bList = result.getChildren("B", Namespace.getNamespace(uri));
    assertTrue("Wrong number of B elements found. Excpected 2, found " + bList.size(), bList.size() == 2);
    assertTrue("Wrong id attribute at first B element", bList.get(0).getAttribute("id").getValue()
        .equals("abc"));
    assertTrue("Wrong id attribute at first B element", bList.get(1).getAttribute("id").getValue()
        .equals("def"));
    List<Element> cList = result.getChildren("C", Namespace.getNamespace(uri));
    assertTrue("Wrong number of C elements found. Excpected 1, found " + cList.size(), cList.size() == 1);
    assertTrue("Wrong id attribute at first C element", cList.get(0).getAttribute("id").getValue()
        .equals("def"));
}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:31,代碼來源:CobigenIntegrationTest.java

示例13: writeXML

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Output xml
 * @param eRoot - the root element
 * @param lang - the language which should be filtered or null for no filter
 * @return a string representation of the XML
 * @throws IOException
 */
private static String writeXML(Element eRoot, String lang) throws IOException {
    StringWriter sw = new StringWriter();
    if (lang != null) {
        // <label xml:lang="en" text="part" />
        XPathExpression<Element> xpE = XPathFactory.instance().compile("//label[@xml:lang!='" + lang + "']",
            Filters.element(), null, Namespace.XML_NAMESPACE);
        for (Element e : xpE.evaluate(eRoot)) {
            e.getParentElement().removeContent(e);
        }
    }
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    Document docOut = new Document(eRoot.detach());
    xout.output(docOut, sw);
    return sw.toString();
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:23,代碼來源:MCRRestAPIClassifications.java

示例14: writeChildrenAsJSONCBTree

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * output children in JSON format used as input for Dijit Checkbox Tree
 *
 * @param eParent - the parent xml element
 * @param writer - the JSON writer
 * @param lang - the language to be filtered or null if all languages should be displayed
 *
 * @throws IOException
 */
private static void writeChildrenAsJSONCBTree(Element eParent, JsonWriter writer, String lang, boolean checked)
    throws IOException {
    writer.beginArray();
    for (Element e : eParent.getChildren("category")) {
        writer.beginObject();
        writer.name("ID").value(e.getAttributeValue("ID"));
        for (Element eLabel : e.getChildren("label")) {
            if (lang == null || lang.equals(eLabel.getAttributeValue("lang", Namespace.XML_NAMESPACE))) {
                writer.name("text").value(eLabel.getAttributeValue("text"));
            }
        }
        writer.name("checked").value(checked);
        if (e.getChildren("category").size() > 0) {
            writer.name("children");
            writeChildrenAsJSONCBTree(e, writer, lang, checked);
        }
        writer.endObject();
    }
    writer.endArray();
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:30,代碼來源:MCRRestAPIClassifications.java

示例15: setLabel

import org.jdom2.Namespace; //導入依賴的package包/類
/**
 * Sets a label for this node
 * 
 * @param lang
 *            the xml:lang language ID
 * @param label
 *            the label in this language
 */
public void setLabel(String lang, String label) throws IOException {

    data.getChildren(LABEL_ELEMENT)
        .stream()
        .filter(child -> lang.equals(
            child.getAttributeValue(LANG_ATT,
                Namespace.XML_NAMESPACE)))
        .findAny()
        .orElseGet(() -> {
            Element newLabel = new Element(LABEL_ELEMENT).setAttribute(LANG_ATT, lang, Namespace.XML_NAMESPACE);
            data.addContent(newLabel);
            return newLabel;
        })
        .setText(label);
    getRoot().saveAdditionalData();
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:25,代碼來源:MCRStoredNode.java


注:本文中的org.jdom2.Namespace類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。