Package org.w3c.dom.xpath

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 = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_NUMBER, new Object[] {getTypeString(m_resultType)});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg); // Can not convert {0} 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


   * @see org.w3c.dom.xpath.XPathResult#getStringValue()
   */
  public String getStringValue() throws XPathException {
    if (getResultType() != STRING_TYPE) {
      String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_STRING, new Object[] {m_resultObj.getTypeString()});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg); // Can not convert {0} 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

   * @see org.w3c.dom.xpath.XPathResult#getBooleanValue()
   */
  public boolean getBooleanValue() throws XPathException {
    if (getResultType() != BOOLEAN_TYPE) {
      String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {getTypeString(m_resultType)});   
      throw new XPathException(XPathException.TYPE_ERR,fmsg)// Can not convert {0} 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

  public Node getSingleNodeValue() throws XPathException {
   
    if ((m_resultType != ANY_UNORDERED_NODE_TYPE) &&
        (m_resultType != FIRST_ORDERED_NODE_TYPE)) {
           String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] {getTypeString(m_resultType)});                       
       throw new XPathException(XPathException.TYPE_ERR,fmsg); // Can not convert {0} to a single node. This getter applies 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

  public int getSnapshotLength() throws XPathException {
 
    if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
        (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
           String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_GET_SNAPSHOT_LENGTH, new Object[] {getTypeString(m_resultType)});                       
       throw new XPathException(XPathException.TYPE_ERR,fmsg); // Can not get snapshot length on type: {0}. This getter applies to types
                                                         //UNORDERED_NODE_SNAPSHOT_TYPE and ORDERED_NODE_SNAPSHOT_TYPE.
      }
     
    return m_list.getLength();
  }
View Full Code Here

   */
  public Node iterateNext() throws XPathException, DOMException {
    if ((m_resultType != UNORDERED_NODE_ITERATOR_TYPE) &&
        (m_resultType != ORDERED_NODE_ITERATOR_TYPE)) {
          String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NON_ITERATOR_TYPE, new Object[] {getTypeString(m_resultType)});                       
      throw new XPathException(XPathException.TYPE_ERR, fmsg)// Can not iterate over non iterator type: {0}
      }

    if (getInvalidIteratorState()) {
          String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_DOC_MUTATED, null);                       
      throw new DOMException(DOMException.INVALID_STATE_ERR,fmsg)// Document mutated since result was returned. Iterator is invalid.
View Full Code Here

  public Node snapshotItem(int index) throws XPathException {
   
    if ((m_resultType != UNORDERED_NODE_SNAPSHOT_TYPE) &&
        (m_resultType != ORDERED_NODE_SNAPSHOT_TYPE)) {
           String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NON_SNAPSHOT_TYPE, new Object[] {getTypeString(m_resultType)});                       
           throw new XPathException(XPathException.TYPE_ERR, fmsg); // Can call snapshotItem on type: {0}. This method applies to types
                                                              // UNORDERED_NODE_SNAPSHOT_TYPE and ORDERED_NODE_SNAPSHOT_TYPE.
      }   
       
        Node node = m_list.item(index);
       
View Full Code Here

        //    
        // If the type is not a supported type, throw an exception and be
        // done with it!
        if (!XPathResultImpl.isValidType(type)) {
            String fmsg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_INVALID_XPATH_TYPE, new Object[] {new Integer(type)});      
            throw new XPathException(XPathException.TYPE_ERR,fmsg); // Invalid XPath type argument: {0}              
        }
       
        // Cache xpath context?
        XPathContext xpathSupport = new XPathContext();
       
        // if m_document is not null, build the DTM from the document
        if (null != m_doc) {
            xpathSupport.getDTMHandleFromNode(m_doc);
        }

        XObject xobj = null;
        try {
            xobj = m_xpath.execute(xpathSupport, contextNode, m_resolver );        
        } catch (TransformerException te) {
            // What should we do here?
            throw new XPathException(XPathException.INVALID_EXPRESSION_ERR,te.getMessageAndLocation());
        }

        // Create a new XPathResult object
        // Reuse result object passed in?
        // The constructor will check the compatibility of type and xobj and
View Full Code Here

         * @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

         * @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

TOP

Related Classes of org.w3c.dom.xpath.XPathException

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.