[xquery-talk] Using UNC file paths in Saxon Xquery

Alexander, Kim (Kim) Kim.Alexander at ElPaso.com
Tue Jan 24 12:47:27 PST 2006


Hi All, 

 

Just wanted to report that Saxon.Net does support URI resolvers.

 

Below are some artifacts from my attempt. Not perfect but it worked with
my UNC file paths.  

 

Saxon.net I believe doesn't support URI's due to some limitation in the
gnu classpath?? 

So the URI resolver expects paths in the format  below.

 

Path Format

 

<collection>

  <doc href="\\tsclient\c\_Backup_offline\UALogs\APS\Log_2005-12-14.xml"
/>

</collection>

 

 

Usage: Example.

 

// SETUP THE SAXON.NET XQUERY EXPRESSION OBJECT

Configuration config = new Configuration();

SaxonURIResolver sur = new SaxonURIResolver();

config.setURIResolver(sur);

 

 

Thanks for your help,

Kim

 

-------------------------

 

// general

using System.IO;

using System;

using System.Xml;

 

// saxon.net

using net.sf.saxon;

using net.sf.saxon.query;

using java.util;

 

// URI resolving

using javax.xml;

using javax.xml.parsers;

using javax.xml.transform.dom;

using javax.xml.transform.sax;

using javax.xml.transform.stream;

using java.io;

using java.text;

using org.w3c.dom;

 

 

namespace ConsoleApplication2

{

      public class SaxonURIResolver : javax.xml.transform.URIResolver

      {

            public SaxonURIResolver()

            {

            }

             

            public javax.xml.transform.Source resolve(String href,
String uriBase)

            {

                  return document(href);

            }

            private DOMSource document(String name) 

            {

                  Console.WriteLine("name: "+name);

                  DOMSource source = null;

                  DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();

                  factory.setNamespaceAware(true);

                  DocumentBuilder builder;

 

                  try 

                  {

                        builder = factory.newDocumentBuilder();

                        Document doc = null;

                        java.io.File sourceFile = new
java.io.File(name);

            

                        if (sourceFile != null) 

                        {

                              doc = builder.parse(sourceFile);

                        }

                        source = new DOMSource(doc);

                        source.setSystemId(name);

                        return source;

                  } 

                  catch (Exception e) 

                  {

                        Console.WriteLine(e.StackTrace);

                  } 

                  return source;

            }

      }

 

}

 

 

________________________________

From: Alexander, Kim (Kim) 
Sent: Wednesday, January 18, 2006 12:33 PM
To: 'Michael Kay'
Subject: RE: [xquery-talk] Using UNC file paths in Saxon Xquery

 

Thanks Dr. Kay I'll investigate that avenue.

 

________________________________

From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On Behalf
Of Michael Kay
Sent: Tuesday, January 17, 2006 5:26 PM
To: Alexander, Kim (Kim); talk at xquery.com
Subject: RE: [xquery-talk] Using UNC file paths in Saxon Xquery

 

Saxon.NET is essentially Saxon recompiled using the IKVM compiler, using
the GNU Classpath for its runtime support. The URI resolution therefore
depends on what GNU Classpath does. There's no standard for how to map
URIs to UNC filenames, so it's quite likely to vary from one
implementation to another, and the best place to get an answer might be
on a GNU Classpath forum (http://www.gnu.org/software/classpath/). I'm
afraid I'm only just beginning to get to grips with the Saxon.NET port
myself, so I can't help you very much. I would suggest that the easiest
solution is to write your own URIResolver, but I can't even be 100%
certain that the Saxon.NET port offers that capability (I wasn't
involved in creating it).

 

Michael Kay

http://www.saxonica.com/

	 

	
________________________________


	From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com]
On Behalf Of Alexander, Kim (Kim)
	Sent: 17 January 2006 22:50
	To: talk at xquery.com
	Subject: [xquery-talk] Using UNC file paths in Saxon Xquery

	Hi All, 

	 

	I'm needing a bit of help.

	 

	I'm using the Saxon implementation of XQuery (actually
Saxon.Net) on Windows and am enjoying having the ability to tinker with
Xquery from DotNet sans SQL Server.

	I'm trying to make use of UNC file paths in my XQuery and am
getting a error I haven't been able to resolve - possibly because I'm
not familiar enough with Java..  

	The Error is::

	 

	Error at function local:Combine() on line 85

	  Invalid URI {file:////tsclient/C/_Backup_of...} - base
{file:/c:/_temp/Coll_APP.xml}:

	  doesn't match URI regular expression:

	
file://tsclient/C/_Backup_offline/UALogs/APS/Log_2005-12-14_Log

	.xml

	 

	Here's Coll_APP.xml 

	<?xml version="1.0" encoding="UTF-8"?>

	<collection>

	  <doc
href="file:////tsclient/C/_Backup_offline/UALogs/APS/Log_2005-12-14.xml"
/>

	  <doc
href="file:////tsclient/C/_Backup_offline/UALogs/APS/Log_2005-12-15.xml"
/>

	  <doc
href="file:////tsclient/C/_Backup_offline/UALogs/APS/Log_2005-12-16.xml"
/>

	  <doc
href="file:////tsclient/C/_Backup_offline/UALogs/APS/Log_2005-12-17.xml"
/>

	</collection>

	 

	I've read a post on SourceForge in the Saxon.Net project forum
that suggested using 4 forward slashes

	As I've done above but that got the error above, I've also tried
three and two slashes without success.

	 

	Please forward me any suggestions you may have.

	 

	Thanks,

	K. Alexander

	
******************************************************************
	This email and any files transmitted with it from the ElPaso
	Corporation are confidential and intended solely for the
	use of the individual or entity to whom they are addressed.
	If you have received this email in error please notify the
	sender.
	
******************************************************************

******************************************************************
This email and any files transmitted with it from the ElPaso
Corporation are confidential and intended solely for the
use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the
sender.
******************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20060124/47c5792b/attachment-0001.htm


More information about the talk mailing list