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


Java Namespace.getNamespace方法代碼示例

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


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

示例1: 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

示例2: resolve

import org.jdom2.Namespace; //導入方法依賴的package包/類
@Override
public Source resolve(String href, String base) throws TransformerException {
    String id = href.substring(href.indexOf(":") + 1);
    LOGGER.debug("Reading METS for ID {}", id);
    MCRObjectID objId = MCRObjectID.getInstance(id);
    if (!objId.getTypeId().equals("derivate")) {
        String derivateID = getDerivateFromObject(id);
        if (derivateID == null) {
            return new JDOMSource(new Element("mets", Namespace.getNamespace("mets", "http://www.loc.gov/METS/")));
        }
        id = derivateID;
    }
    MCRPath metsPath = MCRPath.getPath(id, "/mets.xml");
    try {
        if (Files.exists(metsPath)) {
            //TODO: generate new METS Output
            //ignoreNodes.add(metsFile);
            return new MCRPathContent(metsPath).getSource();
        }
        Document mets = MCRMETSGeneratorFactory.create(MCRPath.getPath(id, "/")).generate().asDocument();
        return new JDOMSource(mets);
    } catch (Exception e) {
        throw new TransformerException(e);
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:26,代碼來源:MCRMetsResolver.java

示例3: setNamespace

import org.jdom2.Namespace; //導入方法依賴的package包/類
/**
 * Sets xml namespace
 *
 * @param element Element that hold the namespace
 * @param decoder Decoder to configure
 */
void setNamespace(Element element, XmlInputDecoder decoder) {
	decoder.defaultNs = element.getNamespace();

	// this handles the case where there is no URI for a default namespace (test)
			String uri = decoder.defaultNs.getURI();
			decoder.xpathNs = Strings.isNullOrEmpty(uri) ? Namespace.NO_NAMESPACE
					: Namespace.getNamespace("ns", decoder.defaultNs.getURI());
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:15,代碼來源:XmlInputDecoder.java

示例4: makeClinicalDocument

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

示例5: testInternalDecode

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

示例6: internalDecodeReturnsTreeContinue

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

示例7: getOaiPmhElement

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

示例8: getCatalogStructureFileNamespaces

import org.jdom2.Namespace; //導入方法依賴的package包/類
static Namespace[] getCatalogStructureFileNamespaces() {
    return new Namespace[]{
        Namespace.getNamespace("s", "http://www.w3.org/TR/1999/PR-rdf-schema-19990303#"),
        Namespace.getNamespace("r", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
        Namespace.getNamespace("n3", "http://www.nesstar.org/rdf/Catalog#"),
        Namespace.getNamespace("n", "http://www.nesstar.org/rdf/"),
        Namespace.getNamespace("n5", "http://www.nesstar.org/rdf/Server#"),
        Namespace.getNamespace("n6", "http://www.nesstar.org/rdf/common/"),
        Namespace.getNamespace("n4", "http://www.nesstar.org/rdf/faster/")
    };
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:12,代碼來源:CatalogStructure.java

示例9: getDtdNamespace

import org.jdom2.Namespace; //導入方法依賴的package包/類
/**
 * Creates a Namespace for a dtd defined document
 * @param publicId
 *            the publicId from the <!-Doctype> node
 * @return Namespace with an URI missing the leading '-' from the publicId
 * @author sholzer (Sep 4, 2015)
 */
public Namespace getDtdNamespace(String publicId) {
    String arg = publicId;

    if (publicId.indexOf("-") == 0) {
        arg = publicId.replaceFirst("-", "");
    }

    return Namespace.getNamespace(arg);
}
 
開發者ID:maybeec,項目名稱:lexeme,代碼行數:17,代碼來源:JDom2Util.java

示例10: resolve

import org.jdom2.Namespace; //導入方法依賴的package包/類
@Override
public Source resolve(String href, String base) throws TransformerException {
    String includePart = href.substring(href.indexOf(":") + 1);
    Namespace xslNamespace = Namespace.getNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

    Element root = new Element("stylesheet", xslNamespace);
    root.setAttribute("version", "1.0");

    // get the parameters from mycore.properties
    String propertyName = "MCR.URIResolver.xslIncludes." + includePart;
    List<String> propValue = Collections.emptyList();
    if (includePart.startsWith("class.")) {
        MCRXslIncludeHrefs incHrefClass = MCRConfiguration.instance()
            .getInstanceOf(propertyName);
        propValue = incHrefClass.getHrefs();
    } else {
        propValue = MCRConfiguration.instance().getStrings(propertyName, propValue);

    }

    for (String include : propValue) {
        // create a new include element
        Element includeElement = new Element("include", xslNamespace);
        includeElement.setAttribute("href", include);
        root.addContent(includeElement);
        LOGGER.info("Resolved XSL include: {}", include);
    }
    return new JDOMSource(root);
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:30,代碼來源:MCRURIResolver.java

示例11: HolidayEndpoint

import org.jdom2.Namespace; //導入方法依賴的package包/類
public HolidayEndpoint(HumanResourceService humanResourceService)
		throws JDOMException, XPathFactoryConfigurationException,
		XPathExpressionException {
	this.humanResourceService = humanResourceService;
	Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
	XPathFactory xPathFactory = XPathFactory.instance();
	this.startDateExpression = xPathFactory.compile("//hr:StartDate",
			Filters.element(), null, namespace);
	this.endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(),
			null, namespace);
	this.nameExpression = xPathFactory.compile(
			"concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null,
			namespace);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:HolidayEndpoint.java

示例12: generateMets

import org.jdom2.Namespace; //導入方法依賴的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;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:67,代碼來源:XMLGeneration.java

示例13: generateEpicurElement

import org.jdom2.Namespace; //導入方法依賴的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;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:58,代碼來源:XMLGeneration.java

示例14: generateEpicurPageElement

import org.jdom2.Namespace; //導入方法依賴的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;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:67,代碼來源:XMLGeneration.java

示例15: generateLido

import org.jdom2.Namespace; //導入方法依賴的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;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:61,代碼來源:XMLGeneration.java


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