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

Re: should document-uri work like this?

Subject: Re: should document-uri work like this?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 02 Jan 2011 09:57:08 +0000
Re:  should document-uri work like this?
On 01/01/2011 22:30, Fred Christian wrote:
I am using the document() function to access another xml file, but I
am having trouble getting my relative URI to work.

So, what do you want to use as the base URI - you haven't made it clear. You say below


But if there is a way to make a change so the document()
function resolves from my source xml file instead of the xsl file that
would be helpful to learn.

in which case the answer is to use

document($relative, /)

or if you prefer

doc(resolve-uri($relative, base-uri(/)))

But there also seem to be suggestions that you want to resolve it relative to the base output URI. I can't think of a reason why you would want to do this, and there isn't a standard way of doing it, but one could write a Saxon extension function to do it if it's really necessary.

Michael Kay
Saxonica

Two solution ideas.

1. Use document-uri to get a base uri to work from.
2. Find a way to modify my saxon command line call.
(Saxon 9 HE, using Java command line, I have 2.0 specified as my xsl version)

1.
I have a current result-document being output and am trying to get
document-uri to work.  See the following

<xsl:variable name="folder" select="format-number(position(), '00')"/>
<xsl:variable name="file">sp.html</xsl:variable>
<xsl:variable name="wb">./<xsl:value-of
select="$folder"/>/subfolder/index.xml</xsl:variable>
<xsl:result-document href="./{$folder}/{$file}">
  <xsl:variable name="thisdoc" select="document-uri(.)"/>
  ==<xsl:value-of select="base-uri()" />-TEST-base-uri
  ==<xsl:value-of select="$thisdoc" />-TEST-document-uri
  ==<xsl:value-of select="$wb" />-TEST-wb
  <xsl:if test="document($wb)">
  <script language="javascript" src="whiteboards/links.js"/>
  </xsl:if>
</xsl:result-document>
-------------
In my current output, my file 01/sp.html file is getting created properly.
It has this at the top where the TEST output is

==file:/C:/Users/Fred/Desktop/Test/IPC2/08_Files_Test/../xml/chapter.xsl-TEST-base-uri
==-TEST-document-uri
==./01/subfolder/index.xml-TEST-wb

Note: My document-uri function isn't returning any value.
If I get that to output something then I hope to change my if
statement to something like,.
<xsl:if test="document($wb,$thisdoc)">

Two questions here.
- How do I get document-uri to work?
- Once I do, should this idea work to make the document() function
have a base-uri to resolve from?

-------
In my second solution idea of modifying the saxon command line call, I
haven't been able to figure that out and it wouldn't be as flexible
anyways. But if there is a way to make a change so the document()
function resolves from my source xml file instead of the xsl file that
would be helpful to learn.

command line I am currently using
java -cp c:\Saxon9\saxon9he.jar net.sf.saxon.Transform
-s:C1\indexC1.xml -xsl:..\xml\chapter.xsl -o:C1\toc.html
-----

Thanks
Fred

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.