wiki:updateResource

Update facilities of TNTBase

Method

  • URL: /update/{xqupdate}
    • Method: GET
    • Query parameters:
      • omdocNs (true or false): whether we want to bind OMDoc namespace to the empty prefix (default: true)
      • ns - a list of namespaces with prefixes that we want to use when querying. The format is the following: prefix:namespace. Note than prefixes can not be repeated
      • readonly (true or false): If true, just returns the modified document as a response. Otherwise the changes are committed to TNTBase, and thus the new revision of XML document appears.
    • Returns: text/xml
    • Description: Perform XQUpdate on the particular document in TNTBase, which mentioned in the XQUpdate (like insert nodes <TNT>I will explode</TNT> after doc(lectures/lecture1.omdoc)/omdoc/metadata/dc:author). The modified document can be either be returned to the user or stored as a new revision in TNTBase.

Example

  • URL:  http://localhost:8080/TNTBase/restful/update/insert nodes <external_metadata>Powered by TNTBase</external_metadata> after doc(/omstd/relation1.omdoc)/omdoc/metadata?readonly=true
  • Method: GET
  • Result: Only (because of readonly=true parameter) returns the transformed document which inserts the element after omdoc/metadata in the /omstd/relation1.omdoc document.
    <tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns">
      <tnt:result modified_doc="/omstd/relation1.omdoc">
        <omdoc xmlns="http://www.mathweb.org/omdoc" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:id="relation1-omdoc">
          <metadata>
            <dc:title>The OpenMath Content Dictionary relation1.ocd  in OMDoc form</dc:title>
            ... here are some metadata
            <dc:description>
              This CD holds the common arithmetic relations. It is intended
                to be `compatible' with the appropriate MathML elements.
            </dc:description>
          </metadata>
          <external_metadata>
            Powered by TNTBase
          <external_metadata>
          <theory xml:id="relation1">
          //clever theory stuff
            </example>
          </theory>
        </omdoc>
      </tnt:result>
    </tnt:results>
    

Method

  • URL: /update
    • Method: POST
    • Accepts: XQUpdate to be processed
    • Query parameters:
      • omdocNs (true or false): whether we want to bind OMDoc namespace to the empty prefix (default: true)
      • ns - a list of namespaces with prefixes that we want to use when querying. The format is the following: prefix:namespace. Note than prefixes can not be repeated
      • readonly (true or false): If true, just returns the modified document as a response. Otherwise the changes are committed to TNTBase, and thus the new revision of XML document appears.
    • Returns: text/xml
    • Description: the same as the above method, but contains an XQUpdate expression in the body of a request, but not as a part of url

Example

  • URL:  http://localhost:8080/TNTBase/restful/update?readonly=false
  • Method: POST
  • Request body:
      replace node doc(/omstd/error.omdoc)/omdoc/theory with <example>Last for now, but not least</example>
    
  • Result: Commits a new version of the modified document (omstd/error.omdoc). It replaces the whole theory element with the element provided in the body of the request