xmlNamespaceDefinitions         package:XML         R Documentation

_G_e_t _d_e_f_i_n_i_t_i_o_n_s _o_f _a_n_y _n_a_m_e_s_p_a_c_e_s _d_e_f_i_n_e_d _i_n _t_h_i_s _X_M_L _n_o_d_e

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

     If the given node has any namespace definitions declared within
     it, i.e. of the form 'xmlns:myNamespace="http://www.myNS.org"',
     'xmlNamespaceDefinitions' provides access to these definitions.
     While they appear in the XML node in the document as attributes,
     they are treated differently by the parser and so do not show up
     in the nodes attributes via 'xmlAttrs'.

     'getDefaultNamespace' is used to get the default namespace for the
     top-level node in a document.

     The 'recursive' parameter allows one to   conveniently find all
     the namespace definitions in a document or sub-tree without having
     to examine the file. This can be useful when working with XPath
     queries via 'getNodeSet'.

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

     xmlNamespaceDefinitions(x, addNames = TRUE, recursive = FALSE)
     getDefaultNamespace(doc) 

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

       x: the 'XMLNode' object in which to find any namespace
          definitions

addNames: a logical indicating whether to compute the names for the
          elements in the resulting list. The names are convenient, but
          one can avoid the (very small) overhead of computing these
          with this parameter.

     doc: the XMLInternalDocument object obtained from a call to
          'xmlTreeParse(, useInternalNodes = TRUE)' 

recursive: a logical value indicating whether to extract the namespace
          definitions for just this node ('FALSE') or all of the
          descendant nodes as well ('TRUE'). If this is 'TRUE', all the
          namespace definitions are collected into a single "flat" list
          and so there may be duplicate names. 

_D_e_t_a_i_l_s:

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

     A list with as many elements as there are namespace definitions.
     Each element is an object of class XMLNameSpace, containing fields
     giving the local identifier, the associated defining URI and a
     logical value indicating whether the definition is local to this
     node. The name of each element is the prefix or alias used  for
     that namespace definition, i.e. the value of the 'id' field in the
     namespace definition. For default namespaces, i.e. those that have
     no prefix/alias, the name is '""'.

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

     Duncan Temple Lang

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

     <URL: http://www.w3.org/XML>

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

     'xmlTreeParse' 'xmlAttrs' 'xmlGetAttr'

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

       f = system.file("exampleData", "longitudinalData.xml", package = "XML")
       n = xmlRoot(xmlTreeParse(f))
       xmlNamespaceDefinitions(n)
       xmlNamespaceDefinitions(n, recursive = TRUE)

       f = system.file("exampleData", "namespaces.xml", package = "XML")
       n = xmlRoot(xmlTreeParse(f, useInternal = TRUE))
       xmlNamespaceDefinitions(n)

       xmlNamespaceDefinitions(n, recursive = TRUE)

