Examples of XPathException


Examples of org.dom4j.XPathException

        new SimpleVariableContext(), DocumentNavigator.getInstance());
  }

  protected void handleJaxenException(JaxenException exception)
      throws XPathException {
    throw new XPathException(text, exception);
  }
View Full Code Here

Examples of org.dom4j.XPathException

      if (answer == null) {
        return null;
      }

      throw new XPathException("The result of the XPath expression is "
          + "not a Node. It was: " + answer + " of type: "
          + answer.getClass().getName());
    } catch (JaxenException e) {
      handleJaxenException(e);
View Full Code Here

Examples of org.dom4j.XPathException

    }
  }

  protected void handleJaxenException(JaxenException exception)
      throws XPathException {
    throw new XPathException(text, exception);
  }
View Full Code Here

Examples of org.exist.xquery.XPathException

  public DecimalValue(String str) throws XPathException {
        str = StringValue.trimWhitespace(str);
    try {
      if (!decimalPattern.matcher(str).matches()) {
        throw new XPathException(ErrorCodes.FORG0001, "cannot construct " + Type.getTypeName(this.getItemType()) +
            " from \"" + str + "\"");           
      }
      value = stripTrailingZeros(new BigDecimal(str));
    } catch (final NumberFormatException e) {
      throw new XPathException(ErrorCodes.FORG0001, "cannot construct " + Type.getTypeName(this.getItemType()) +
          " from \"" + getStringValue() + "\"");         
    }
  }
View Full Code Here

Examples of org.pdf4j.saxon.trans.XPathException

                sequence.getSpecialProperties(), visitor, this);

        //declaration = null;     // let the garbage collector take it

        action = visitor.typeCheck(action, contextItemType);
        XPathException err = TypeChecker.ebvError(action, visitor.getConfiguration().getTypeHierarchy());
        if (err != null) {
            err.setLocator(this);
            throw err;
        }
        return this;
    }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathException

   */
   XPathResultImpl(short type, XObject result, Node contextNode, XPath xpath) {
    // Check that the type is valid
    if (!isValidType(type)) {
            String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INVALID_XPATH_TYPE, new Object[] {new Integer(type)});      
            throw new XPathException(XPathException.TYPE_ERR,fmsg); // Invalid XPath type argument: {0}          
    }

        // Result object should never be null!
        if (null == result) {
            String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_EMPTY_XPATH_RESULT, null);      
            throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,fmsg); // Empty XPath result object
        }
       
        this.m_resultObj = result;
        this.m_contextNode = contextNode;
        this.m_xpath = xpath;

        // If specified result was ANY_TYPE, determine XObject type
        if (type == ANY_TYPE) {
            this.m_resultType = getTypeFromXObject(result);
        } else {
            this.m_resultType = type;
        }
   
        // If the context node supports DOM Events and the type is one of the iterator
        // types register this result as an event listener
        if (((m_resultType == XPathResult.ORDERED_NODE_ITERATOR_TYPE) ||
            (m_resultType == XPathResult.UNORDERED_NODE_ITERATOR_TYPE))) {
              addEventListener();
               
        }// else can we handle iterator types if contextNode doesn't support EventTarget??
           
        // If this is an iterator type get the iterator
        if ((m_resultType == ORDERED_NODE_ITERATOR_TYPE) ||
            (m_resultType == UNORDERED_NODE_ITERATOR_TYPE) ||
            (m_resultType == ANY_UNORDERED_NODE_TYPE) ||
            (m_resultType == FIRST_ORDERED_NODE_TYPE))  {
   
            try {
                m_iterator = m_resultObj.nodeset();
            } catch (TransformerException te) {
                // probably not a node type
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INCOMPATIBLE_TYPES, new Object[] {m_xpath.getPatternString(), getTypeString(getTypeFromXObject(m_resultObj)),getTypeString(m_resultType)});      
            throw new XPathException(XPathException.TYPE_ERR, fmsg)// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be coerced into the specified XPathResultType of {2}."},
           }
   
                // If user requested ordered nodeset and result is unordered
                // need to sort...TODO
    //            if ((m_resultType == ORDERED_NODE_ITERATOR_TYPE) &&
    //                (!(((DTMNodeIterator)m_iterator).getDTMIterator().isDocOrdered()))) {
    //
    //            }
   
        // If it's a snapshot type, get the nodelist
        } else if ((m_resultType == UNORDERED_NODE_SNAPSHOT_TYPE) ||
                   (m_resultType == ORDERED_NODE_SNAPSHOT_TYPE)) {
            try {        
             m_list = m_resultObj.nodelist();
            } catch (TransformerException te) {
            // probably not a node type
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INCOMPATIBLE_TYPES, new Object[] {m_xpath.getPatternString(), getTypeString(getTypeFromXObject(m_resultObj)),getTypeString(m_resultType)});      
        throw new XPathException(XPathException.TYPE_ERR, fmsg); // "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be coerced into the specified XPathResultType of {2}."},
            }
      }        
  }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathException

   * @see org.w3c.dom.xpath.XPathResult#getNumberValue()
   */
  public double getNumberValue() throws XPathException {
    if (getResultType() != NUMBER_TYPE) {
      String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_XPATHRESULTTYPE_TO_NUMBER, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg);
//    "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a number"
    } else {
      try {
         return m_resultObj.num();
      } catch (Exception e) {
        // Type check above should prevent this exception from occurring.
        throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
      }
    }   
  }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathException

   * @see org.w3c.dom.xpath.XPathResult#getStringValue()
   */
  public String getStringValue() throws XPathException {
    if (getResultType() != STRING_TYPE) {
      String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_STRING, new Object[] {m_xpath.getPatternString(), m_resultObj.getTypeString()});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg);
//    "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a string."
    } else {
      try {
         return m_resultObj.str();
      } catch (Exception e) {
        // Type check above should prevent this exception from occurring.
        throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
      }
    }
  }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathException

   * @see org.w3c.dom.xpath.XPathResult#getBooleanValue()
   */
  public boolean getBooleanValue() throws XPathException {
    if (getResultType() != BOOLEAN_TYPE) {
      String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg);
//    "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean."     
    } else {
      try {
         return m_resultObj.bool();
      } catch (TransformerException e) {
        // Type check above should prevent this exception from occurring.
        throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
      }
    }
  }
View Full Code Here

Examples of org.w3c.dom.xpath.XPathException

  public Node getSingleNodeValue() throws XPathException {
   
    if ((m_resultType != ANY_UNORDERED_NODE_TYPE) &&
        (m_resultType != FIRST_ORDERED_NODE_TYPE)) {
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});                       
        throw new XPathException(XPathException.TYPE_ERR,fmsg);
//        "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a single node.
//         This method applies only to types ANY_UNORDERED_NODE_TYPE and FIRST_ORDERED_NODE_TYPE."
      }
 
    NodeIterator result = null;
    try {
      result = m_resultObj.nodeset();
    } catch (TransformerException te) {
      throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
    }
       
        if (null == result) return null;
       
        Node node = result.nextNode();
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.