[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

mixing it up: REST+XML Namespaces + XLST

Subject: mixing it up: REST+XML Namespaces + XLST
From: James Fuller <jim.fuller@xxxxxxxxxxxxxx>
Date: Tue, 19 Apr 2005 01:25:26 +0200
rest implementation
let me preface the following that I have no burning desire to *put*
something that means something within an XML namespace URI...though was
wondering of any variations on the following theme exist out there in
the wild.

for this simple illustration, I will just talk about HTTP GET and none
of the other CRUD operations that map to REST

take for example take a simple REST interface to a database with a few
tables; 

http://www.example.org/app/tables/company
http://www.example.org/app/tables/user
http://www.example.org/app/tables/products

performing a GET on top level URL http://www.example.org/app/tables returns

<tables>
<user xmlns="http://www.example.org/app/tables/user"/>
<company xmlns="http://www.example.org/app/tables/company"/>
<products xmlns="http://www.example.org/app/tables/products"/>
</tables>

note, I have bastardized REST by eschewing with xlink:href (was just
transforming them into other things in any event) and defining namespaces.

performing GET on these URL's will return XML with a list of records,

<records>
    <company xmlns="http://www.example.org/app/tables/company">1</company>
</records>

sending a GET  for http://www.example.org/app/tables/company/1/ would in
turn return XML data about the com

<row xmlns="http://www.example.org/app/tables/company" xml:ID="1">
<uid>1</uid>
<name>My Company</name>
<phone>wou 55</phone>
<email>jim.fuller@xxxxxxxxxxxxxx</email>
</row>

note: I have used xml:ID to identify because I have written a bit of
code to handle such things.

so I now find myself doing things like defining namespaces for use in
XSLT (though we dont have to explicitly define them, necc);

xmlns:company="http://www.example.org/app/tables/company"

xmlns:products="http://www.example.org/app/tables/products"

xmlns:user="http://www.example.org/app/tables/user"

then with the various fn:namespace functions e.g.
fn:namespace-uri,fn:namespace-uri-for-prefix,fn:namespace-uri-from-QName
I can now infer access these resources with document() calls.

<xsl:variable name="company" select="document(fn:namespace-uri(.))"/>

by being able to consume the record lists its easy to create detail
level document() calls...also if your data has regular id
sequences...its now easy with ranges and such to just append the id
number to document() call.

With every document() call I recieve xml with relevent namespaces which
point to their REST implementation...it feels very state like to me,
being passed a namespace which contains its REST URI
implementation....would like to hear if anyone else is using XML
namespace to their own ends ?

cheers, Jim Fuller

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.