Resolving http file with local repository.

Wednesday, 5 August 2015 · 3 messages · last reply 6 Aug 2015
AK
ankit kumar5 Aug 2015 15:00 #
Hi, I want to load document having a http url from local cache directory. Is there a way i can resolve http url to my local cache directory. For example
 let $file := doc("http://abc.com/example.xml")
should resolve example.xml from c:\documents\repo\http\abc.com\example.xml Thanks, Anky
CG
Christian Grün5 Aug 2015 15:05 #
Hi Anky, just write a simple resolver in XQuery. This is a simple example how to do it:
  declare variable $BASE := "c:\documents\repo\";
  declare function local:resolve($url) {
    $BASE || replace($url, 'http://', '')
  };
  doc(local:resolve("http://abc.com/example.xml"))
Cheers, Christian
Quoted text · ankit kumar · 13 lines
On Wed, Aug 5, 2015 at 3:00 PM, ankit kumar <anky4bugs at gmail.com> wrote: > Hi, > > I want to load document having a http url from local cache directory. Is > there a way i can resolve http url to my local cache directory. For example > > let $file := doc("http://abc.com/example.xml") > > should resolve example.xml from c:\documents\repo\http\abc.com\example.xml > > > Thanks, > Anky
AK
ankit kumar6 Aug 2015 07:42 #
Hi, Thanks for the prompt reply. I have set catalog file using GUI and tried firing following query. Catalog File ::
<?xml version="1.0"?>
<catalog prefer="system"
xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
   <rewriteSystem systemIdStartString="http://"
rewritePrefix="file:///D:/local_repo/http/" />
</catalog>
and Trying to load file by executing doc("http://abc.com/example.xml"), But it is not able to load document as it seems it is not referring my catelog file. Thanks, Anky
Quoted text · Christian Grün · 32 lines
On 5 August 2015 at 18:35, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Anky, > > just write a simple resolver in XQuery. This is a simple example how to do > it: > > declare variable $BASE := "c:\documents\repo\"; > declare function local:resolve($url) { > $BASE || replace($url, 'http://', '') > }; > doc(local:resolve("http://abc.com/example.xml")) > > Cheers, > Christian > > > On Wed, Aug 5, 2015 at 3:00 PM, ankit kumar <anky4bugs at gmail.com> wrote: > > Hi, > > > > I want to load document having a http url from local cache directory. Is > > there a way i can resolve http url to my local cache directory. For > example > > > > let $file := doc("http://abc.com/example.xml") > > > > should resolve example.xml from c:\documents\repo\http\abc.com > \example.xml > > > > > > Thanks, > > Anky >

⚡Generated with XQuery