Examples of DOMXPath


Examples of org.jaxen.dom.DOMXPath

        return o;
    }
   
    protected List selectNodes(Node node, String path) throws JaxenException
    {
        DOMXPath xpath = new DOMXPath(path);
        for (Iterator itr = namespaces.entrySet().iterator(); itr.hasNext();)
        {
            Map.Entry entry = (Map.Entry) itr.next();
            xpath.addNamespace((String) entry.getKey(), (String) entry.getValue());
        }
       
        return xpath.selectNodes(node);
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

         Thread.dumpStack();
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal argument in xpath match() call");
      }
     
      // Access cached query ...
      DOMXPath expression;
     
      try {
         if (query.getPreparedQuery() == null) {
            try {
               expression = new DOMXPath(query.getQuery());
               query.setPreparedQuery(expression);
            } catch (JaxenException e) {
               log.warning("Can't compile XPath filter expression '" + query + "':" + e.toString());
               throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Can't compile XPath filter expression '" + query + "'", e);
            }
         }
         else
            expression = (DOMXPath)query.getPreparedQuery();
        
         // Access cached xsl transformation
         XslTransformer xslContentTransformer = null;
         if (this.xslContentTransformerFileName != null) {
            xslContentTransformer = (XslTransformer)query.getTransformer();
            if (xslContentTransformer == null) {
               Map xslProps = new TreeMap(); // TODO: Where to get them from
               xslContentTransformer = new XslTransformer(glob, this.xslContentTransformerFileName, null, null, xslProps);
            }
         }
        
         String xml = getXml(msgUnit).trim(); // Content or QoS
        
         if (xml.length() == 0) {
            log.warning("Provided XML string is empty, query does not match.");
            return false;
         }
        
         Document doc = null;
         try {
            doc = getDocument(msgUnit);
         }
         catch (Throwable e) {
            log.warning("The msgUnit can't be parsed, we reject it for this subscriber: " + e.toString());
            return false;
         }
        
         if ( log.isLoggable(Level.FINEST))
            log.finest("Matching query " + query.getQuery() + " against document: " + getXml(msgUnit));
        
         boolean match = expression.booleanValueOf(doc);
         if (log.isLoggable(Level.FINE))
            log.fine("Query "+query.getQuery()+" did" + (match ? " match" : " not match"));
        
         if (match == true && xslContentTransformer != null) {
            String tmp = (this.matchAgainstQos) ? msgUnit.getContentStr() : xml;
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    XPath xPath = (XPath) cachedXPaths.get(expression);
    if (xPath == null)
    {
      try
      {
        xPath = new DOMXPath(expression);
        addNamespaceContext(contextNode, xPath, expression);
      }
      catch (JaxenException e)
      {
        throw new JRException("XPath compilation failed. Expression: " + expression, e);
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    List nlist;
    String namespaceXPathString = "//namespace::node()";

    try
    {
      XPath xpath = new DOMXPath(namespaceXPathString);
      nlist = xpath.selectNodes(contextNode);
     
            for (int i = 0; i < nlist.size(); i++)
            {
                Node node = (Node)nlist.get(i);
                if(node.getParentNode() != null && node.getParentNode().getPrefix() != null)
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    XPath xPath = (XPath) cachedXPaths.get(expression);
    if (xPath == null)
    {
      try
      {
        xPath = new DOMXPath(expression);
      }
      catch (JaxenException e)
      {
        throw new JRException("XPath compilation failed. Expression: " + expression, e);
      }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

  public Object selectObject(Node contextNode, String expression) throws JRException
  {
    try
    {
      XPath xpath = new DOMXPath(expression);
      Object object = xpath.evaluate(contextNode);
      Object value;
      if (object instanceof List)
      {
        List list = (List) object;
        if (list.isEmpty())
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

  public XmlResource getNode(XcapResource resource, String nodeSelector) throws XcapException
  {
    try
    {
      DOMXPath xPath = new DOMXPath(nodeSelector);
      for (String prefix : resource.getNamespaceContext().keySet())
        xPath.addNamespace(prefix, resource.getNamespaceContext().get(prefix));
      Node node = (Node) xPath.selectSingleNode(resource.getDocument().getDom());
      if (node == null)
        return null;
      return new XpathXmlResource(node);
    }
    catch (JaxenException e)
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected final XPath createXPath(String xp) throws JaxenException {
        return new DOMXPath(xp);
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

            throw new XPathException("Could not transform context to DOM Node", ex);
        }
    }

    private XPath createXPath(String expression) throws JaxenException {
        XPath xpath = new DOMXPath(expression);
        if (getNamespaces() != null && !getNamespaces().isEmpty()) {
            xpath.setNamespaceContext(new SimpleNamespaceContext(getNamespaces()));
        }
        return xpath;
    }
View Full Code Here

Examples of org.jaxen.dom.DOMXPath

     * @return the compiled {@code XPathExpression}
     * @throws XPathParseException when the given expression cannot be parsed
     */
    static XPathExpression createXPathExpression(String expression) {
        try {
            XPath xpath = new DOMXPath(expression);
            return new JaxenXpathExpression(xpath);
        }
        catch (JaxenException ex) {
            throw new org.springframework.xml.xpath.XPathParseException(
                    "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex);
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.