findXInclude               package:XML               R Documentation

_F_i_n_d _t_h_e _X_I_n_c_l_u_d_e _n_o_d_e _a_s_s_o_c_i_a_t_e_d _w_i_t_h _a_n _X_M_L _n_o_d_e

_D_e_s_c_r_i_p_t_i_o_n:

     This function is used to traverse the ancestors of an  internal
     XML node to find the associated XInclude  node that identifies it
     as being an XInclude'd node. Each top-level node that results from
     an include href=... in the libxml2 parser is sandwiched between
     nodes of class XMLXIncludeStartNode and XMLXIncludeStartNode.
     These are the sibling nodes.

_U_s_a_g_e:

     findXInclude(x, asNode = FALSE)

_A_r_g_u_m_e_n_t_s:

       x: the node whose XInclude "ancestor" is to be found

  asNode: a logical value indicating whether to return the node itself
          or the attributes of the node which are typically the
          immediately interesting  aspect of the node.

_V_a_l_u_e:

     Either 'NULL' if there was no node of class XMLXIncludeStartNode
     found. Otherwise, if 'asNode' is 'TRUE', that 
     XMLXIncludeStartNode node is returned, or alternatively its
     attribute character vector.

_A_u_t_h_o_r(_s):

     Duncan Temple Lang

_R_e_f_e_r_e_n_c_e_s:

     www.libxml.org

_S_e_e _A_l_s_o:

     'xmlParse' and the 'xinclude' parameter.

_E_x_a_m_p_l_e_s:

      f = system.file("exampleData", "functionTemplate.xml", package = "XML")

      cat(readLines(f), "\n")

      doc = xmlParse(f)

       # Get all the para nodes
       # We just want to look at the 2nd and 3rd which are repeats of the
       # first one.
      a = getNodeSet(doc, "//author")
      findXInclude(a[[1]])

      i = findXInclude(a[[1]], TRUE)
      top = getSibling(i)

        # Determine the top-level included nodes
      tmp = getSibling(i)
      nodes = list()
      while(!inherits(tmp, "XMLXIncludeEndNode")) {
        nodes = c(nodes, tmp)
        tmp = getSibling(tmp)
      }

