Loading ...
Sorry, an error occurred while loading the content.

17951Re: [rest-discuss] Using URI templates in XHTML

Expand Messages
  • Marc Portier
    Nov 10, 2011
    • 0 Attachment
      On 09-11-11 17:39, Philippe Mougin wrote:

      >
      > URI templates:
      > **************
      > I'm now in possession of a shinny new URI-template library (implementing
      > http://tools.ietf.org/html/draft-gregorio-uritemplate-07) that I plan to

      care to share which one?

      I've been working on a js-jquery implementation at
      https://github.com/marc-portier/uri-templates/ myself


      > embed in some of the clients of my system. These client programs will
      > then be able to easily interpret (i.e., expand) URI templates.
      >
      > Question:
      > *********
      > I'd like to use URI template as hypermedia control in XHTML, as a
      > (richer) alternative to my existing forms. What do you think is the best
      > way to do so ? Specifically, how would you represent an URI template in
      > XHTML (given it must be used as a hypermedia control for programatic
      > clients)?
      >

      good question, and an interesting field for further 'standardisation'
      IMHO... some first thoughts:

      uri-templates are macro's producing actual uri's for individual 'contexts'

      Below I assume you think about in-browser (js) code that will be
      expanding the templates, right? If not: server side-expansion just
      yields uri's that can be injected in the HTML: so nothing special needed.


      Anyway, in terms of HTML such I think the lists of contexts could be
      provided by any repeating thing like ul/li, table/tr, p

      in a json-wrapped way:

      <li data-context='{"id": "3367-29283-2484", "type": "item", "field":
      "whatever"}'> label </li>

      or a more distributed way:

      <tr data-id="3367-29283-2484"><td>label</td><td
      data-context-name="type">item</td><td
      data-context-name="field">whatever</td></tr>

      (or even think microformats, and use class attributes rather then data-x)



      What remains is the need to know for each of these contexts in which
      template they should be injected (to achieve what result)

      So on the surrounding <ul> or <table> you could envision some indication
      of those:

      <ul data-uri-t="item-ref, item-form" > stating that these templates are
      useful on the items nested in the ul


      All that then makes sense inside some browser-state (HTML provided, HTTP
      header, provided, ajax loaded or whatever) where item-ref and item-form
      are known relations for 'links', something of the equivalent of

      <link rel="item-ref" href="item/{type}/{id}" /><!-- GET PUT DELETE -->
      <link rel="item-form" href="forms/{type}{?id}" /><!-- GET POST -->


      with a self-describing pure data-structure like this one could think
      about jquery code that enhances the structure with onclick-events or
      even added in clickable icons to follow the uri's associated to the
      various relations


      as said, just some first thoughts
      -marc=

      > Thanks,
      > Philippe Mougin
      >
      >
    • Show all 19 messages in this topic