本文整理汇总了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");
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
}