Package org.apache.xalan.xpath

Examples of org.apache.xalan.xpath.XObject


          if(score == kd.m_match.MATCH_SCORE_NONE)
            continue;

          // Query from the node, according the the select pattern in the
          // use attribute in xsl:key.
          XObject xuse = kd.m_use.execute(xmlLiaison, testNode, nscontext);

          NodeList nl = xuse.nodeset();
          if(0 == nl.getLength())
            continue;
         
          // Use each node in the node list as a key value that we'll be
          // able to use to look up the given node.
          int nUseValues = nl.getLength();
          for(int k = 0; k < nUseValues; k++)
          {
            Node useNode = nl.item(k);
           
            // Use getExpr to get the string value of the given node. I hope
            // the string assumption is the right thing... I can't see how
            // it could work any other way.
            String exprResult = xmlLiaison.getNodeData(useNode);
           
            if(null == exprResult)
              continue;
           
            // Look to see if there's already a table indexed by the
            // name attribute on xsl:key.  If there's not, create one.
            Hashtable namedKeyTable;
            {
              Object keyTableObj = m_keys.get(kd.m_name);
              if(null == keyTableObj)
              {
                namedKeyTable = new Hashtable();
                m_keys.put(kd.m_name, namedKeyTable);
              }
              else
              {
                namedKeyTable = (Hashtable)keyTableObj;
              }
            }
           
            // Look to see if we already have row indexed by
            // the node value, which is one of the nodes found via
            // the use attribute of xsl:key.  If there's not a row,
            // create one.
            NodeListImpl keyNodes;
            {
              Object nodeListObj = namedKeyTable.get(exprResult);
              if(null == nodeListObj)
              {
                keyNodes = new NodeListImpl();
                namedKeyTable.put(exprResult, keyNodes);
              }
              else
              {
                keyNodes = (NodeListImpl)nodeListObj;
              }
            }
           
            // See if the matched node is already in the
            // table set.  If it is there, we're done, otherwise
            // add it.
            boolean foundit = false;
            int nKeyNodes = keyNodes.size();
            for(int j = 0; j < nKeyNodes; j++)
            {
              if(testNode == keyNodes.item(j))
              {
                foundit = true;
                break;
              }
            } // end for j
            if(!foundit)
            {
              keyNodes.addElement(testNode);
            }
          } // end for(int k = 0; k < nUseValues; k++)
        } // end for(int i = 0; i < nDeclarations; i++)
      }

    }
    catch(ClassCastException cce)
    {
      Node pos = startNode;

      // Do a non-recursive pre-walk over the tree.
      while(null != pos)
      {    
        int nDeclarations = keyDeclarations.size();
       
        // We're going to have to walk the attribute list
        // if it's an element, so get the attributes.
        NamedNodeMap attrs = null;
        int nNodes;
        if(Node.ELEMENT_NODE == pos.getNodeType())
        {
          attrs = ((Element)pos).getAttributes();
          nNodes = attrs.getLength();
          if(0 == nNodes)
            attrs = null;
        }
        else
        {
          nNodes = 0;
        }
       
        // Walk the primary node, and each of the attributes.
        // This loop is a little strange... it is meant to always
        // execute once, then execute for each of the attributes.
        Node testNode = pos;
        for(int nodeIndex = -1; nodeIndex < nNodes;)
        {
          // Walk through each of the declarations made with xsl:key
          for(int i = 0; i < nDeclarations; i++)
          {
            KeyDeclaration kd = (KeyDeclaration)keyDeclarations.elementAt(i);
           
            // See if our node matches the given key declaration according to
            // the match attribute on xsl:key.
            double score = kd.m_match.getMatchScore(execContext, testNode);
            if(score == kd.m_match.MATCH_SCORE_NONE)
              continue;

            // Query from the node, according the the select pattern in the
            // use attribute in xsl:key.
            XObject xuse = kd.m_use.execute(execContext, testNode, nscontext);

            NodeList nl = xuse.nodeset();
            if(0 == nl.getLength())
              continue;
           
            // Use each node in the node list as a key value that we'll be
            // able to use to look up the given node.
View Full Code Here


    String fileName;
    String fileNameExpr = elem.getAttribute ("select");
    if(null != fileNameExpr)
    {
      org.apache.xalan.xpath.XPathSupport execContext = context.processor.getExecContext();
      XObject xobj = context.processor.getStylesheet().evalXPathStr(execContext,
                                                                    fileNameExpr,
                                                                    context.sourceNode,
                                                                    execContext.getNamespaceContext());
      fileName = xobj.str();
      if((null == fileName) || (fileName.length() == 0))
      {
        fileName = elem.getAttribute ("file");
      }
    }
View Full Code Here

   */
  public static NodeList selectNodeList(Node contextNode, String str, Node namespaceNode)
    throws SAXException
  {
    // Execute the XPath, and have it return the result
    XObject list = eval(contextNode, str, namespaceNode);

    // Have the XObject return its result as a NodeSet.
    return list.nodeset();

  }
View Full Code Here

   * @param o Any java object.
   * @return An XObject object.
   */
  public XObject createXObject(Object o)
  {
    return new XObject(o);
  }
View Full Code Here

   * @param o Any java object.
   * @return An XObject object.
   */
  public XObject createXObject(Object o)
  {
    return new XObject(o);
  }
View Full Code Here

    {
      if(Constants.ELEMNAME_WITHPARAM == child.getXSLToken())
      {
        ElemWithParam xslParamElement = (ElemWithParam)child;

        XObject var;
        if(null != xslParamElement.m_selectPattern)
        {
          var = xslParamElement.m_selectPattern.execute(engine.getXMLProcessorLiaison(), sourceNode,
                                                        xslParamElement);
        }
View Full Code Here

   * global space.
   */
  public XObject getParamVariable(QName qname)
    throws SAXException
  {
    XObject val = null;
    int nElems = getCurrentStackFrameIndex();

    for(int i = (nElems - 1); i >= 0; i--)
    {
      Object obj = elementAt(i);
View Full Code Here

    String fileName;
    String fileNameExpr = ((ElemExtensionCall)elem).getAttribute ("select", context.sourceNode, context.processor);
    if(null != fileNameExpr)
    {
      org.apache.xalan.xpath.XPathSupport execContext = context.processor.getExecContext();
      XObject xobj = context.processor.getStylesheet().evalXPathStr(execContext, fileNameExpr,
                                                                    context.sourceNode,
                                                                    execContext.getNamespaceContext());
      fileName = xobj.str();
      if((null == fileName) || (fileName.length() == 0))
      {
        fileName = ((ElemExtensionCall)elem).getAttribute ("file", context.sourceNode, context.processor);
      }
    }
View Full Code Here

   */
  public static NodeList selectNodeList(Node contextNode, String str, Node namespaceNode)
    throws SAXException
  {
    // Execute the XPath, and have it return the result
    XObject list = eval(contextNode, str, namespaceNode);

    // Have the XObject return its result as a NodeSet.
    return list.nodeset();

  }
View Full Code Here

            continue;
         

          // Query from the node, according the the select pattern in the
          // use attribute in xsl:key.
          XObject xuse = kd.m_use.execute(xmlLiaison, testNode, nscontext);
         
          NodeList nl = null;
          int nUseValues;
          String exprResult = null;
          if(xuse.getType() != xuse.CLASS_NODESET)
          {
            nUseValues = 1;
            exprResult = xuse.str();
          }
          else
          {
            nl = xuse.nodeset();
            if(0 == nl.getLength())
            { 
              kd.m_buildState = KeyDeclaration.BUILT;
              continue;
           
           
            // Use each node in the node list as a key value that we'll be
            // able to use to look up the given node.
            nUseValues = nl.getLength();
          }
          for(int k = 0; k < nUseValues; k++)
          {           
            // Use getExpr to get the string value of the given node. I hope
            // the string assumption is the right thing... I can't see how
            // it could work any other way.
            if(null != nl)
            {
              Node useNode = nl.item(k);
              exprResult = XMLParserLiaisonDefault.getNodeData(useNode);
            }
           
            if(null == exprResult)
              continue;
           
            // Look to see if there's already a table indexed by the
            // name attribute on xsl:key.  If there's not, create one.
            Hashtable namedKeyTable;
            {
              Object keyTableObj = m_keys.get(kd.m_name);
              if(null == keyTableObj)
              {
                namedKeyTable = new Hashtable();
                m_keys.put(kd.m_name, namedKeyTable);
              }
              else
              {
                namedKeyTable = (Hashtable)keyTableObj;
              }
            }
           
            // Look to see if we already have row indexed by
            // the node value, which is one of the nodes found via
            // the use attribute of xsl:key.  If there's not a row,
            // create one.
            NodeListImpl keyNodes;
            {
              Object nodeListObj = namedKeyTable.get(exprResult);
              if(null == nodeListObj)
              {
                keyNodes = new NodeListImpl();
                namedKeyTable.put(exprResult, keyNodes);
              }
              else
              {
                keyNodes = (NodeListImpl)nodeListObj;
              }
            }
           
            // See if the matched node is already in the
            // table set.  If it is there, we're done, otherwise
            // add it.
            boolean foundit = false;
            int nKeyNodes = keyNodes.size();
            for(int j = 0; j < nKeyNodes; j++)
            {
              if(testNode == keyNodes.item(j))
              {
                foundit = true;
                break;
              }
            } // end for j
            if(!foundit)
            {
              keyNodes.addElement(testNode);
            }
          } // end for(int k = 0; k < nUseValues; k++)
          kd.m_buildState = KeyDeclaration.BUILT;
          break;
        } // end for(int i = 0; i < nDeclarations; i++)
       
        // Need to break out of main loop?
        if (breakout)
          break;
      }

    }
    catch(ClassCastException cce)
    {
      Node pos = startNode;

      // Do a non-recursive pre-walk over the tree.
      while(null != pos)
      {    
        int nDeclarations = keyDeclarations.size();
       
        // We're going to have to walk the attribute list
        // if it's an element, so get the attributes.
        NamedNodeMap attrs = null;
        int nNodes;
        if(Node.ELEMENT_NODE == pos.getNodeType())
        {
          attrs = ((Element)pos).getAttributes();
          nNodes = attrs.getLength();
          if(0 == nNodes)
            attrs = null;
        }
        else
        {
          nNodes = 0;
        }
       
        // Walk the primary node, and each of the attributes.
        // This loop is a little strange... it is meant to always
        // execute once, then execute for each of the attributes.
        Node testNode = pos;
        for(int nodeIndex = -1; nodeIndex < nNodes;)
        {
          // Walk through each of the declarations made with xsl:key
          for(int i = 0; i < nDeclarations; i++)
          {
            KeyDeclaration kd = (KeyDeclaration)keyDeclarations.elementAt(i);
           
            if(!kd.m_name.equals(name))
              continue;
            // We are currently processing this key declaration.
            // More than likely, the key function was called in the
            // xsl:key declaration using the same key name.
            if( kd.m_buildState == KeyDeclaration.BUILDING)
            {
              return;
              // break;
           
            kd.m_buildState = KeyDeclaration.BUILDING;
           
            // See if our node matches the given key declaration according to
            // the match attribute on xsl:key.
            double score = kd.m_match.getMatchScore(execContext, testNode);
            if(score == kd.m_match.MATCH_SCORE_NONE)
            {
              kd.m_buildState = KeyDeclaration.BUILT;
              continue;
            }
            // Query from the node, according the the select pattern in the
            // use attribute in xsl:key.
            XObject xuse = kd.m_use.execute(execContext, testNode, nscontext);

            NodeList nl = null;
            int nUseValues;
            String exprResult = null;
            if(xuse.getType() != xuse.CLASS_NODESET)
            {
              nUseValues = 1;
              exprResult = xuse.str();
            }
            else
            {
              nl = xuse.nodeset();
              if(0 == nl.getLength())
              { 
                kd.m_buildState = KeyDeclaration.BUILT;
                continue;
             
View Full Code Here

TOP

Related Classes of org.apache.xalan.xpath.XObject

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.