Examples of XResult


Examples of com.ibm.commons.xml.XResult

        }
    }
    public XResult evaluateXPath(NodeList nodeList, Object xpath, NamespaceContext nsContext) throws XPathException {
        try {
            if(nodeList.getLength()>0) {
                XResult result = null;
                NodeListImpl nodes = null;
                PrefixResolver pr = nsContext!=null ? new NSResolver(nsContext) : null;
                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
View Full Code Here

Examples of com.ibm.commons.xml.XResult

        }
    }
    public XResult evaluateXPath(NodeList nodeList, Object xpath, NamespaceContext nsContext) throws XPathException {
        try {
            if(nodeList.getLength()>0) {
                XResult result = null;
                NodeListImpl nodes = null;
                PrefixResolver pr = nsContext!=null ? new NSResolver(nsContext) : null;
                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
View Full Code Here

Examples of com.ibm.commons.xml.XResult

   
  /* (non-Javadoc)
   * @see com.ibm.commons.xml.XPathExpression#getType(java.lang.Object)
   */
  public Class getType(Object node) throws XPathException {
    XResult result = eval(node, null);
    if (result != null) {
      switch (result.getValueType()) {
      case XResult.TYPE_EMPTY:
        return Void.class;
      case XResult.TYPE_STRING:
        return String.class;
      case XResult.TYPE_BOOLEAN:
View Full Code Here

Examples of com.ibm.commons.xml.XResult

        }
    }
    public XResult evaluateXPath(NodeList nodeList, Object xpath, NamespaceContext nsContext) throws XPathException {
        try {
            if(nodeList.getLength()>0) {
                XResult result = null;
                NodeListImpl nodes = null;
                PrefixResolver pr = nsContext!=null ? new NSResolver(nsContext) : null;
                for( int i=0; i<nodeList.getLength(); i++ ) {
                    XObject res = XPathAPI.eval(nodeList.item(i),(String)xpath,pr);
                    switch(res.getType()) {
View Full Code Here

Examples of com.ibm.commons.xml.XResult

            return domDriver.evaluateXPath(nodeObj,compiledXPath,namespaceContext);
        }
        if (node instanceof NodeList) {
            NodeList nodeList = (NodeList)node;
            namespaceContext = resolveNamespaceContext(nodeList.item(0),namespaceContext);
            XResult r = domDriver.evaluateXPath(nodeList,compiledXPath,namespaceContext);
            return r;
        }
        throw new XPathException(null,"Try to evaluate an XPath on a object that is not a node or a node list"); // $NLS-XmlComplexExpression.TrytoevaluateanXPathonaobjectthat-1$
    }
View Full Code Here

Examples of com.ibm.commons.xml.XResult

        }

        Node nodeObj = (Node)node;
        nsContext = resolveNamespaceContext(nodeObj,nsContext);
       
        XResult r = domDriver.evaluateXPath(nodeObj,compiledXPath,nsContext);
        if(r.isEmpty()) {
            throw new XPathException(null,"Cannot create XPath {0}",getExpression()); // $NLS-XmlComplexExpression.CannotcreateXPath0-1$
        }
        if(r.isValue()) {
            throw new XPathException(null,"Cannot set a value on a value result, XPath={0}",getExpression()); // $NLS-XmlComplexExpression.CannotsetavalueonavalueresultXPat-1$
        }
        String strValue = Utils.getAsString(value);
        for( Iterator it=r.getNodeIterator(); it.hasNext(); ) {
            Object n = (Object)it.next();
            if( n instanceof Node ) {
                DOMUtil.setTextValue((Node)n, strValue);
            }
        }
View Full Code Here

Examples of com.ibm.commons.xml.XResult

      logger.entering(sourceClass, "get");
    }
    String result = "";
    try {
      XPathExpression xpathQuery = getXPathQuery(fieldName);
      XResult xResult = xpathQuery.eval(data, getNamespaceContext());
      result = xResult.getStringValue() != null ? xResult.getStringValue() : "";
    } catch (XPathException e) {
      logger.throwing(sourceClass, "get", e);
    } catch (XMLException e) {
      logger.throwing(sourceClass, "get", e);
    }
View Full Code Here

Examples of com.ibm.commons.xml.XResult

      logger.entering(sourceClass, "getEntities");
    }
    XPathExpression xpathQuery = getXPathQuery(namedQuery);

    try {
      XResult xResult = xpathQuery.eval(data, getNamespaceContext());
      // forcing erasure, as getNodes returns an array of objects
      List l = Arrays.asList(xResult.getNodes());;
      return l;
    } catch (XPathException e) {
      logger.throwing(sourceClass, "getNestedEntities", e);
    }
    if (logger.isLoggable(Level.FINEST)) {
View Full Code Here

Examples of com.ibm.commons.xml.XResult

    }
   
    private static JSSnippet createSnippetFromXml(String xml) {
        try {
            Document document = DOMUtil.createDocument(xml);
            XResult unid = DOMUtil.evaluateXPath(document, "unid");
            XResult js = DOMUtil.evaluateXPath(document.getDocumentElement(), "js");
            XResult html = DOMUtil.evaluateXPath(document.getDocumentElement(), "html");
            XResult css = DOMUtil.evaluateXPath(document.getDocumentElement(), "css");
            XResult docHtml = DOMUtil.evaluateXPath(document.getDocumentElement(), "docHtml");
            XResult theme = DOMUtil.evaluateXPath(document.getDocumentElement(), "theme");
            XResult description = DOMUtil.evaluateXPath(document.getDocumentElement(), "description");
            XResult tags = DOMUtil.evaluateXPath(document.getDocumentElement(), "tags");
            XResult labels = DOMUtil.evaluateXPath(document.getDocumentElement(), "labels");
           
            JSSnippet snippet = new JSSnippet();
            if(unid != null)
              snippet.setUnid(unid.getStringValue());
            if (js != null)
              snippet.setJs(js.getStringValue());
            if (html != null)
              snippet.setHtml(html.getStringValue());
            if (css != null)
              snippet.setCss(css.getStringValue());
            if (docHtml != null)
                snippet.setDocHtml(docHtml.getStringValue());
           
            Properties p = new Properties();
            snippet.init(p);
           
            if(theme != null && theme.getStringValue() != null)
              snippet.setTheme(theme.getStringValue());
            if(description != null && description.getStringValue() != null)
              snippet.setDescription(description.getStringValue());
            if(tags != null && tags.getValues() != null)
              snippet.setTags(tags.getValues());
            if(labels != null && labels.getValues() != null)
              snippet.setLabels(labels.getValues());
           
            return snippet;
        } catch (Exception e) {
            return null;
        }
View Full Code Here

Examples of com.ibm.commons.xml.XResult

    }
   
    private static JSSnippet createSnippetFromXml(String xml) {
        try {
            Document document = DOMUtil.createDocument(xml);
            XResult unid = DOMUtil.evaluateXPath(document, "unid");
            XResult js = DOMUtil.evaluateXPath(document.getDocumentElement(), "js");
            XResult html = DOMUtil.evaluateXPath(document.getDocumentElement(), "html");
            XResult css = DOMUtil.evaluateXPath(document.getDocumentElement(), "css");
            XResult docHtml = DOMUtil.evaluateXPath(document.getDocumentElement(), "docHtml");
            XResult theme = DOMUtil.evaluateXPath(document.getDocumentElement(), "theme");
            XResult description = DOMUtil.evaluateXPath(document.getDocumentElement(), "description");
            XResult tags = DOMUtil.evaluateXPath(document.getDocumentElement(), "tags");
            XResult labels = DOMUtil.evaluateXPath(document.getDocumentElement(), "labels");
           
            JSSnippet snippet = new JSSnippet();
            if(unid != null)
              snippet.setUnid(unid.getStringValue());
            if (js != null)
              snippet.setJs(js.getStringValue());
            if (html != null)
              snippet.setHtml(html.getStringValue());
            if (css != null)
              snippet.setCss(css.getStringValue());
            if (docHtml != null)
                snippet.setDocHtml(docHtml.getStringValue());
           
            Properties p = new Properties();
            snippet.init(p);
           
            if(theme != null && theme.getStringValue() != null)
              snippet.setTheme(theme.getStringValue());
            if(description != null && description.getStringValue() != null)
              snippet.setDescription(description.getStringValue());
            if(tags != null && tags.getValues() != null)
              snippet.setTags(tags.getValues());
            if(labels != null && labels.getValues() != null)
              snippet.setLabels(labels.getValues());
           
            return snippet;
        } catch (Exception e) {
            return null;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.