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


Java SimpleNamespaceContext.bindNamespaceUri方法代码示例

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


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

示例1: naConstructie

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
/**
 * Zet xpath namespace ctx & initialiseer database met afnemervoorbeeld schema.
 */
@PostConstruct
//heeft shutdown hook
//
public void naConstructie() {
    final SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
    nsContext.bindNamespaceUri("brp", "http://www.bzk.nl/brp/brp0200");
    xPath.setNamespaceContext(nsContext);

    LOGGER.warn("Berichten opslaan in database: {}", isDatabasePersistent);

    if (isDatabasePersistent) {
        final ClassPathXmlApplicationContext cp = new ClassPathXmlApplicationContext("afnemervoorbeeld-databasepersist-context.xml");
        cp.registerShutdownHook();
        jdbcTemplate = (JdbcTemplate) cp.getBean("jdbcTemplate");
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:DatabasePersister.java

示例2: createXPathExpression

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
public static XPathExpression createXPathExpression(String expression) {
    SimpleNamespaceContext namespaces = new SimpleNamespaceContext();

    // NOTE: These are the internal prefixes used in XPath expression
    namespaces.bindNamespaceUri("wfs", NS_URL_WFS);
    namespaces.bindNamespaceUri("xlink", NS_URL_XLINK);
    namespaces.bindNamespaceUri("gml", NS_URL_GML);
    namespaces.bindNamespaceUri("ogc", NS_URL_OGC);
    namespaces.bindNamespaceUri("ktjkiiwfs", NS_URL_KTJ_KIINTEISTO);
    namespaces.bindDefaultNamespaceUri(NS_URL_KTJ_KIINTEISTO);

    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(namespaces);

    try {
        return xpath.compile(expression);
    } catch (XPathExpressionException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:21,代码来源:WFSUtil.java

示例3: getTargetLanguage

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
/**
 * Gets the target language of the XLIFF by looking at the first "file" 
 * element.
 *
 * @param xliffContent xliff content from which to extract the target language
 * @return the target language or {@code null} if not found
 */
public String getTargetLanguage(String xliffContent) {

    String targetLanguage = null;

    InputSource inputSource = new InputSource(new StringReader(xliffContent));
    XPath xPath = XPathFactory.newInstance().newXPath();
    
    SimpleNamespaceContext simpleNamespaceContext = new SimpleNamespaceContext();
    simpleNamespaceContext.bindNamespaceUri("xlf", "urn:oasis:names:tc:xliff:document:1.2");
    xPath.setNamespaceContext(simpleNamespaceContext);
    
    try {
        Node node = (Node) xPath.evaluate("/xlf:xliff/xlf:file[1]/@target-language", inputSource, XPathConstants.NODE);
        
        if(node != null) {
            targetLanguage = node.getTextContent();
        }
        
    } catch (XPathExpressionException xpee) {
        logger.debug("Can't extract target language from xliff", xpee);
    }
    return targetLanguage;
}
 
开发者ID:box,项目名称:mojito,代码行数:31,代码来源:XliffUtils.java

示例4: transform

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
private static XPathRoot transform(TransformationBuilder builder) {
    StreamResult result;
    SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
    try {
        TransformerFactory transformerFactory = (TransformerFactory)
                Class.forName(XsltTransformer.PREFERRED_TRANSFORMER_FACTORY).newInstance();
        Transformer transformer = transformerFactory.newTransformer(
                new StreamSource(XmlTransformationTestUtil.class.getResourceAsStream(builder.stylesheet)));
        for (Map.Entry<String, Object> mapEntry : builder.parameterMap.entrySet()) {
            transformer.setParameter(mapEntry.getKey(), mapEntry.getValue());
        }
        result = new StreamResult(new StringWriter());
        transformer.transform(new StreamSource(XmlTransformationTestUtil.class.getResourceAsStream(builder.source)), result);
    } catch (Exception e) {
        throw new GreenbirdTestException(e);
    }
    for (String key : builder.namespaceMap.keySet()) {
        namespaceContext.bindNamespaceUri(key, builder.namespaceMap.get(key));
    }
    return XPathRoot.forString(result.getWriter().toString()).withNamespaceContext(namespaceContext);
}
 
开发者ID:greenbird,项目名称:mule-test-tools,代码行数:22,代码来源:XmlTransformationTestUtil.java

示例5: getModules

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
/**
 * Get the Citrus modules for this project based on the build dependencies.
 * @return
 */
public List<Module> getModules() {
    List<Module> modules = new ArrayList<>();
    Collection<String> allModules = new SpringBeanNamespacePrefixMapper().getNamespaceMappings().values();

    if (project.isMavenProject()) {
        try {
            String pomXml = FileUtils.readToString(new FileSystemResource(project.getMavenPomFile()));
            SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
            nsContext.bindNamespaceUri("mvn", "http://maven.apache.org/POM/4.0.0");

            Document pomDoc = XMLUtils.parseMessagePayload(pomXml);

            NodeList dependencies = XPathUtils.evaluateAsNodeList(pomDoc, "/mvn:project/mvn:dependencies/mvn:dependency/mvn:artifactId[starts-with(., 'citrus-')]", nsContext);

            for (int i = 0; i < dependencies.getLength(); i++) {
                String moduleName = DomUtils.getTextValue((Element) dependencies.item(i));

                if (moduleName.equals("citrus-core")) {
                    allModules.remove("citrus");
                } else {
                    allModules.remove(moduleName);
                }

                modules.add(new Module(moduleName.substring("citrus-".length()), getActiveProject().getVersion(), true));
            }
        } catch (IOException e) {
            throw new ApplicationRuntimeException("Unable to open Maven pom.xml file", e);
        }
    }

    allModules.stream()
            .filter(name -> !name.equals("citrus-test"))
            .map(name -> name.equals("citrus") ? "citrus-core" : name)
            .map(name -> new Module(name.substring("citrus-".length()), getActiveProject().getVersion(), false))
            .forEach(modules::add);

    return modules;
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:43,代码来源:ProjectService.java

示例6: bindUnboundedNamespaces

import org.springframework.util.xml.SimpleNamespaceContext; //导入方法依赖的package包/类
private static void bindUnboundedNamespaces(SimpleNamespaceContext nsContext, Map<String, String> namespaces) {
    for (Map.Entry<String, String> entry : namespaces.entrySet()) {
        //making sure that namespace is not already bound. Otherwise UnsupportedException happens
        if(nsContext.getPrefix(entry.getValue()) == null) {
            nsContext.bindNamespaceUri(entry.getKey(), entry.getValue());
        }
    }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:9,代码来源:XPath.java


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