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


Java XPathAPI类代码示例

本文整理汇总了Java中org.apache.xpath.XPathAPI的典型用法代码示例。如果您正苦于以下问题:Java XPathAPI类的具体用法?Java XPathAPI怎么用?Java XPathAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parseBdxClasses

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
/**
 * Parses the BDX classes configuration.
 *
 * @param pNode the node
 * @throws RuntimeException if an error occurred while parsing the BDX classes configuration.
 */
protected void parseBdxClasses(Node pNode) {
    try {
        NodeList tNodeList = XPathAPI.selectNodeList(pNode,
            "//AsTransportConfiguration/BdxClass");
        for (int i = 0; i < tNodeList.getLength(); i++) {
            Node tNode = tNodeList.item(i);
            CwfDataIf tTree = AsUtil.parse((Element) tNode);
            String tClassName = tTree.getProperty("className");
            if (!mBdxClasses.contains(tClassName)) {
                AsDef.ensureClassName(tClassName);
                mBdxClasses.add(tClassName);
            }
        }
    }
    catch (TransformerException e) {
        throw new RuntimeException("Error selecting BDX class source node", e);
    }
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:25,代码来源:AsTransportConfiguration.java

示例2: cutSalaries

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
public static void cutSalaries(Document doc, String xpath) 
	throws TransformerException {
	    	    
    // Get the matching elements
    NodeList nodelist = XPathAPI.selectNodeList(doc, xpath);
    		    
    // Process the elements in the nodelist
    for (int i=0; i<nodelist.getLength(); i++) {
    	
        // Get element
        Element elem = (Element)nodelist.item(i);
        
        // Transform content of element
        double before = Double.parseDouble(elem.getTextContent());
        double after = before / 2;            
        elem.setTextContent(Double.toString(after));
    }
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:19,代码来源:Cut.java

示例3: parseServices

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
/**
 * Parses the service configuration
 * @param pNode the node to parse from
 * @throws AsInitializationException
 */
protected void parseServices(Element pNode) throws AsInitializationException {
    try {
        NodeList tNodeList = XPathAPI.selectNodeList(pNode, "//AsServices/service");
        for (int i = 0; i < tNodeList.getLength(); i++) {
            Node tNode = tNodeList.item(i);
            CwfDataIf tTree = AsUtil.parse((Element) tNode);
            String tServiceClass = tTree.getProperty("serviceClass");
            String tRequestClass = tTree.getProperty("requestClass");
            createAndRegisterService(tRequestClass, tServiceClass);
        }
    }
    catch (TransformerException e) {
        throw new RuntimeException("Error selecting service source node", e);
    }
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:21,代码来源:AsServiceHandler.java

示例4: parse

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
protected void parse(Node pNode) {
    try {
        NodeList tNodeList = XPathAPI.selectNodeList(pNode, "//AsBeanFactory/bean");
        for (int i = 0; i < tNodeList.getLength(); i++) {
            Node tNode = tNodeList.item(i);
            CwfDataIf tTree = AsUtil.parse((Element) tNode);

            String tInterface = tTree.getProperty("interface");
            String tClass = tTree.getProperty("class");
            boolean tSingleton = tTree.getBooleanProperty("singleton") == Boolean.TRUE;
            boolean tParameters = tTree.getBooleanProperty("parameters") == Boolean.TRUE;

            Class<?> tInterfaceClass = Class.forName(tInterface);
            Class<?> tImplementationClass = Class.forName(tClass);

            mBeanConfiguration.addConfiguration(tInterfaceClass, tImplementationClass, tSingleton, tParameters);
        }
    }
    catch (Exception e) {
        throw new RuntimeException("Error selecting bean source node", e);
    }
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:23,代码来源:AsBeanFactoryImpl.java

示例5: addReferences

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
private void addReferences() {
    try {
        Node tDoc = As.getConfigXmlParser().getConfigurationDocument();
        NodeList tNodeList = XPathAPI.selectNodeList(tDoc, "//" + TAG_AS_CACHE + "/" + TAG_CACHE_REFERENCE);
        for (int i = 0; i < tNodeList.getLength(); i++) {
            Node tNode = tNodeList.item(i);
            CwfDataIf tTree = AsUtil.parse((Element) tNode);
            String tType = tTree.getProperty(ATTR_TYPE);
            String tField = tTree.getProperty(ATTR_FIELD);
            addReference(tType, tField);
        }
    }
    catch (TransformerException e) {
        throw new RuntimeException("Error selecting cache reference node", e);
    }
}
 
开发者ID:cinnober,项目名称:ciguan,代码行数:17,代码来源:AsCache.java

示例6: preconfigure

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
@Override
public void preconfigure(Element element) throws Exception {
	super.preconfigure(element);
	
	String version = element.getAttribute("version");
	
	if (version!= null && VersionUtils.compare(version, "7.0.0") < 0) {
		Engine.logDatabaseObjectManager.info("Migration to 7.0.0 for MouseAdvanceStatement, migrate to javascriptable properties.");
		Document doc = element.getOwnerDocument();
		
		for (String propertyName : Arrays.asList("screenX", "screenY", "clientX", "clientY", "ctrlKey", "altKey", "shiftKey", "metKey", "button")) {
			Element exElt = (Element) XPathAPI.selectSingleNode(element, "property[@name='" + propertyName +"']/*");
			Element newElt = doc.createElement("java.lang.String");
			
			newElt.setAttribute("value", exElt.getAttribute("value"));
			exElt.getParentNode().replaceChild(newElt, exElt);
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:20,代码来源:MouseAdvanceStatement.java

示例7: main

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Document doc = XmlUtils.loadDoc("/testcode/xpath/data.xml");

    String input = args.length != 0 ? args[1] : "guess' or '1'='1";
    String query = "//groups/group[@id='" + input + "']/writeAccess/text()";

    //selectNodeIterator
    NodeIterator iterator = XPathAPI.selectNodeIterator(doc, query);
    XmlUtils.printNodeIterator(iterator);

    //selectNodeList
    NodeList nodeList = XPathAPI.selectNodeList(doc, query);
    XmlUtils.printNodeList(nodeList);

    //selectSingleNode
    Node node = XPathAPI.selectSingleNode(doc, query);
    XmlUtils.printNode(node);

    //Static string (safe)
    Node node2 = XPathAPI.selectSingleNode(doc, "//groups/group[@id='guess']/writeAccess/text()".toLowerCase());
    XmlUtils.printNode(node2);
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:23,代码来源:XPathApacheXPathApi.java

示例8: noError

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
/**
 * Checks, if errors were reported during execution
 * 
 * @return true, if no error was logged in the log file
 */
protected boolean noError() {

	// if there is no result file, there is an error
	if (result == null)
		return false;

	try {
		NodeList nodes = XPathAPI.selectNodeList(result.document,
				"//r:Error|//r:FatalError",
				result.document.getDocumentElement());
		if (nodes.getLength() > 0)
			return false;
	} catch (TransformerException e) {
		fail("An error occured processing an Xpath expression on the log file.");
		e.printStackTrace();
		return false;
	}

	return true;
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:26,代码来源:TestInstance.java

示例9: postSign

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
public void postSign(Element signatureElement, List<X509Certificate> signingCertificateChain) {
	Document document = signatureElement.getOwnerDocument();
	Element nsElement = document.createElement("nsElement");
	nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:ds", Constants.SignatureSpecNS);
	nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:xades", XAdESXLSignatureFacet.XADES_NAMESPACE);
	Element qualifyingPropertiesElement;
	try {
		qualifyingPropertiesElement = (Element) XPathAPI.selectSingleNode(signatureElement,
				"ds:Object/xades:QualifyingProperties", nsElement);
	} catch (TransformerException e) {
		throw new RuntimeException("XPath error: " + e.getMessage(), e);
	}
	String namespacePrefix = qualifyingPropertiesElement.getPrefix();
	if (null == namespacePrefix || namespacePrefix.isEmpty()) {
		namespacePrefix = "";
	} else {
		namespacePrefix = namespacePrefix + ":";
	}
	Element unsignedPropertiesElement = document.createElementNS(XAdESXLSignatureFacet.XADES_NAMESPACE,
			namespacePrefix + "UnsignedProperties");
	qualifyingPropertiesElement.appendChild(unsignedPropertiesElement);
	Element unsignedSignaturePropertiesElement = document.createElementNS(XAdESXLSignatureFacet.XADES_NAMESPACE,
			namespacePrefix + "UnsignedSignatureProperties");
	unsignedPropertiesElement.appendChild(unsignedSignaturePropertiesElement);
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:26,代码来源:Office2010SignatureFacet.java

示例10: getSignatureResourceName

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
private String getSignatureResourceName(URL url)
		throws IOException, ParserConfigurationException, SAXException, TransformerException {
	InputStream inputStream = url.openStream();
	ZipInputStream zipInputStream = new ZipInputStream(inputStream);
	ZipEntry zipEntry;
	while (null != (zipEntry = zipInputStream.getNextEntry())) {
		if (false == "[Content_Types].xml".equals(zipEntry.getName())) {
			continue;
		}
		Document contentTypesDocument = loadDocument(zipInputStream);
		Element nsElement = contentTypesDocument.createElement("ns");
		nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:tns",
				"http://schemas.openxmlformats.org/package/2006/content-types");
		NodeList nodeList = XPathAPI.selectNodeList(contentTypesDocument,
				"/tns:Types/tns:Override[@ContentType='application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml']/@PartName",
				nsElement);
		if (nodeList.getLength() == 0) {
			return null;
		}
		String partName = nodeList.item(0).getTextContent();
		LOG.debug("part name: " + partName);
		partName = partName.substring(1); // remove '/'
		return partName;
	}
	return null;
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:27,代码来源:OOXMLSignatureVerifierTest.java

示例11: sign

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
/**
 * Canonizes and signs a given input with the authentication private key.
 * of the EBICS user.
 * 
 * <p>The given input to be signed is first Canonized using the 
 * http://www.w3.org/TR/2001/REC-xml-c14n-20010315 algorithm.
 * 
 * <p>The element to be canonized is only the SignedInfo element that should be
 * contained in the request to be signed. Otherwise, a {@link TransformationException}
 * is thrown.
 * 
 * <p> The namespace of the SignedInfo element should be named <b>ds</b> as specified in
 * the EBICS specification for common namespaces nomination.
 * 
 * <p> The signature is ensured using the user X002 private key. This step is done in
 * {@link EbicsUser#authenticate(byte[]) authenticate}.
 * 
 * @param toSign the input to sign
 * @return the signed input
 * @throws EbicsException signature fails.
 */
public byte[] sign(byte[] toSign) throws EbicsException {
  try {
    DocumentBuilderFactory 		factory;
    DocumentBuilder			builder;
    Document				document;
    Node 				node;
    Canonicalizer 			canonicalizer;

    factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    builder = factory.newDocumentBuilder();
    builder.setErrorHandler(new IgnoreAllErrorHandler());
    document = builder.parse(new ByteArrayInputStream(toSign));
    node = XPathAPI.selectSingleNode(document, "//ds:SignedInfo");
    canonicalizer = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
    return user.authenticate(canonicalizer.canonicalizeSubtree(node));
  } catch(Exception e) {
    throw new EbicsException(e.getMessage());
  }
}
 
开发者ID:pinaraf,项目名称:ebics,代码行数:43,代码来源:SignedInfo.java

示例12: parseParameters

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
public Map<String, Parameter> parseParameters(String response) throws KettleException{ 
	Map<String, Parameter> parameters = new HashMap<String, Parameter>(); 
	try{
	    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
	    dfactory.setNamespaceAware(false);
	    Document doc = dfactory.newDocumentBuilder().parse(new InputSource(new StringReader(response)));
	    	      
	    Node n;
	    NodeIterator nodeIt = XPathAPI.selectNodeIterator(doc, root_expr);
	    while ((n = nodeIt.nextNode())!= null){ 	    	
	    	parameters.put(XPathAPI.eval(n, NAME_EXPR).str(), parseParameter(n));
	    }
	} catch (Exception e) {
		throw new KettleException("Error retrieving parameters from WPS response...", e);
	}   
	return parameters;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:ParameterBuilder.java

示例13: buildBoundingBoxFormat

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
private AbstractFormat buildBoundingBoxFormat(Node n) throws JDOMException, KettleException, DOMException, TransformerException{
	List<String> crss = new ArrayList<String>();
	String default_crs = XPathAPI.eval(n, DEFAULT_CRS_EXPR).str();
	if(default_crs == null)
		default_crs = EMPTY;
	
	Node crs_node;
	NodeIterator nodeIt = XPathAPI.selectNodeIterator(n, SUPPORTED_CRSS_EXPR);
    while ((crs_node = nodeIt.nextNode())!= null){ 	    	
    	crss.add(crs_node.getNodeValue());
    }	
    
    boolean alreadyExists = false;
    for(String crs: crss){
    	if(crs.equals(default_crs)){
    		alreadyExists = true;
    		break;
    	}			
    }

    if(!alreadyExists && !default_crs.equals(EMPTY))
    	crss.add(default_crs);
    return new BoundingBoxFormat(crss, default_crs);
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:25,代码来源:ParameterBuilder.java

示例14: getComplexFormats

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
private void getComplexFormats(Parameter param, Node n) throws JDOMException, KettleException, DOMException, TransformerException{		
	Node complex_default =  XPathAPI.selectSingleNode(n, DEFAULT_FORMAT_EXPR);
	AbstractFormat defaultFormat = null;
	if(complex_default!= null){ 	    	
    	defaultFormat = buildComplexFormat(complex_default);
		param.setDefaultFormat(defaultFormat);
    }

    Node complex_supported;
    NodeIterator nodeIt = XPathAPI.selectNodeIterator(n, SUPPORTED_FORMATS_EXPR);
    while ((complex_supported = nodeIt.nextNode())!= null){ 	    	
    	param.addSupportedFormat(buildComplexFormat(complex_supported));
    }
    
    if(param.getSupportedFormats().isEmpty() && defaultFormat != null)
    	param.addSupportedFormat(defaultFormat);	    	
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:ParameterBuilder.java

示例15: parseParameter

import org.apache.xpath.XPathAPI; //导入依赖的package包/类
private Parameter parseParameter(Node n) throws JDOMException, KettleException, TransformerException{
	Parameter param = buildParameter(n);	
	Node complex_node = XPathAPI.selectSingleNode(n, complex_expr);
	if (complex_node != null)
		getComplexFormats(param, complex_node);	
	else{		
		Node bbox_node =  XPathAPI.selectSingleNode(n, bbox_expr);	
		if (bbox_node != null)
			getBoundingBoxFormats(param, bbox_node);	
		else{		
			Node literal_node =  XPathAPI.selectSingleNode(n, literal_expr);	
			if (literal_node != null)
				getLiteralFormats(param, literal_node);							
		}
    }	
	return param;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:ParameterBuilder.java


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