catalogResolve              package:XML              R Documentation

_L_o_o_k _u_p _a_n _e_l_e_m_e_n_t _v_i_a _t_h_e _X_M_L _c_a_t_a_l_o_g _m_e_c_h_a_n_i_s_m

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

     XML parsers use a catalog to map generic system and public
     addresses to actual local files or potentially different remote
     files. We can use a catalog to map a reference such as
     'http://www.omegahat.org/XSL/' to a particular directory on our
     local machine and then not have to modify any of the documents if
     we move the local files to another directory, e.g. install a new
     version in an alternate directory.

     This function provides a mechanism to query the catalog to resolve
     a URI, PUBLIC or SYSTEM identifier.

     This is now vectorized, so accepts a character vector of URIs and
     recycles 'type' to have the same length.

     If an entry is not resolved via the catalog system, a 'NA' is
     returned for that element. To leave the value unaltered in this
     case, use 'asIs = TRUE' .

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

     catalogResolve(id, type = "uri", asIs = FALSE, debug = FALSE)

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

      id: the name of the (generic) element to be resolved

    type: a string, specifying whether the lookup is for a uri, system
          or public element

    asIs: a logical. If 'TRUE' any element of 'id' which is not
          resolved by the catalog system will be left as given in the
          call. If 'FALSE', such unresolved elements are identified by
          'NA'. 

   debug: logical value indicating whether to turn on debugging output
          written to the console ('TRUE') or not ('FALSE').

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

     A character vector. If the element was resolved, the single
     element is the resolved value. Otherwise, the character vector
     will contain no elements.

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

     Duncan Temple Lang

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

     <URL: http://www.xmlsoft.org> <URL:
     http://www.sagehill.net/docbookxsl/Catalogs.html> provides a
     short, succinct tutorial on catalogs.

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

     'xmlTreeParse'

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

     if(!exists("Sys.setenv")) Sys.setenv = Sys.putenv

     Sys.setenv("XML_CATALOG_FILES" = system.file("exampleData", "catalog.xml", package = "XML"))


     catalogResolve("-//OASIS//DTD DocBook XML V4.4//EN", "public")

     catalogResolve("http://www.omegahat.org/XSL/foo.xsl")

     catalogResolve("http://www.omegahat.org/XSL/article.xsl", "uri")
     catalogResolve("http://www.omegahat.org/XSL/math.xsl", "uri")

       # This one does not resolve anything, returning an empty value.
     catalogResolve("http://www.oasis-open.org/docbook/xml/4.1.2/foo.xsl", "uri")

        # Vectorized and returns NA for the first and /tmp/html.xsl
        # for the second.

      catalogAdd("http://made.up.domain", "/tmp")
      catalogResolve(c("ddas", "http://made.up.domain/html.xsl"), asIs = TRUE)

