Package org.springframework.util.xml

Examples of org.springframework.util.xml.SimpleNamespaceContext


  }

  private XPathExpression compileXpathExpression(String expression, Map<String, String> namespaces)
      throws XPathExpressionException {

    SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
    namespaceContext.setBindings((namespaces != null) ? namespaces : Collections.<String, String> emptyMap());
    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(namespaceContext);
    return xpath.compile(expression);
  }
View Full Code Here


  }

  private XPathExpression compileXpathExpression(String expression, Map<String, String> namespaces)
      throws XPathExpressionException {

    SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext();
    namespaceContext.setBindings((namespaces != null) ? namespaces : Collections.<String, String> emptyMap());
    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(namespaceContext);
    return xpath.compile(expression);
  }
View Full Code Here

        JSONObject projectInfo = new JSONObject();

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

                Document pomDoc = XMLUtils.parseMessagePayload(pomXml);
                projectInfo.put("basePackage", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:groupId", nsContext, XPathConstants.STRING));
                projectInfo.put("name", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:artifactId", nsContext, XPathConstants.STRING));
                projectInfo.put("version", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:properties/mvn:citrus.version", nsContext, XPathConstants.STRING));
                projectInfo.put("description", XPathUtils.evaluateExpression(pomDoc, "/mvn:project/mvn:description", nsContext, XPathConstants.STRING));
            } catch (IOException e) {
                throw new CitrusAdminRuntimeException("Unable to open Maven pom.xml file", e);
            }
        } else if (isAntProject()) {
            try {
                String buildXml = FileUtils.readToString(new FileSystemResource(new File(getAntBuildFilePath())));
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();

                Document buildDoc = XMLUtils.parseMessagePayload(buildXml);
                projectInfo.put("name", XPathUtils.evaluateExpression(buildDoc, "/project/@name", nsContext, XPathConstants.STRING));
                projectInfo.put("version", XPathUtils.evaluateExpression(buildDoc, "/project/property[@name='citrus.version']/@value", nsContext, XPathConstants.STRING));
                projectInfo.put("description", XPathUtils.evaluateExpression(buildDoc, "/project/@description", nsContext, XPathConstants.STRING));
View Full Code Here

            new ReferencedEnvelope(-180,180,-90,90, DefaultGeographicCRS.WGS84));
        return mapContent;
    }

    void initXPath(XPath xpath) {
        SimpleNamespaceContext ctx = new SimpleNamespaceContext();
        ctx.bindNamespaceUri("kml", "http://www.opengis.net/kml/2.2");
        xpath.setNamespaceContext(ctx);
    }
View Full Code Here

        try {
            XPathFactory factory = XPathFactory.newInstance();
            javax.xml.xpath.XPath xpath = factory.newXPath();
           
            if (namespaces != null) {
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
                bindUnboundedNamespaces(nsContext, namespaces);
                xpath.setNamespaceContext(nsContext);
            }

            return (NodeList) xpath.evaluate(path, node, XPathConstants.NODESET);
View Full Code Here

        try {
            XPathFactory factory = XPathFactory.newInstance();
            javax.xml.xpath.XPath xpath = factory.newXPath();
           
            if (namespaces != null) {
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
                bindUnboundedNamespaces(nsContext, namespaces);
                xpath.setNamespaceContext(nsContext);
            }

            return (Node) xpath.evaluate(path, node, XPathConstants.NODE);
View Full Code Here

        try {
            XPathFactory factory = XPathFactory.newInstance();
            javax.xml.xpath.XPath xpath = factory.newXPath();

            if (namespaces != null) {
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
                bindUnboundedNamespaces(nsContext, namespaces);
                xpath.setNamespaceContext(nsContext);
            }

            return (String) xpath.evaluate(path, node, XPathConstants.STRING);
View Full Code Here

  public static NamespaceContext getContext() {
    return ctx;
  }

  private static NamespaceContext create() {
    SimpleNamespaceContext ctx = new SimpleNamespaceContext();
    ctx.bindNamespaceUri("oai20", OaiPmhConstants.OAI_2_0_XML_NS);
    return ctx;
  }
View Full Code Here

TOP

Related Classes of org.springframework.util.xml.SimpleNamespaceContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.