[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: Graydon <graydon@xxxxxxxxx>
Date: Sat, 1 Jan 2011 18:04:58 -0500
Re:  should document-uri work like this?
On Sat, Jan 01, 2011 at 02:30:20PM -0800, Fred Christian scripsit:
[snip]
> <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>
[snip]
> Two questions here.
> - How do I get document-uri to work?

Remember that document-uri is the inverse of the doc function; it gives
you the document-uri property of a document node. (doc() gives you the
document node of the thing it finds at the URI you give it, if it can.)

If you call it on the context node in a global variable (which is what
that looks like) there isn't a context node, so the document-uri
property of a null sequence is the null sequence, but even if there _is_
a context node, if it's not the document node, you still won't get
anything back from document-uri().

So either use base-uri(), which will walk back up the various trees to
get the document node, or use document-uri(root(.)) if there really is
a context node defined, or use document-uri(/) if you want the document
URI in a global variable.

> - Once I do, should this idea work to make the document() function
> have a base-uri to resolve from?

Here I find myself unclear on what you're trying to do -- iterate over a
bunch of files?  That's what collection() is for, and will very likely
work better (if this is XSLT 2.0, which I think it has to be from
document-uri()) than trying to hand-code it.

-- Graydon

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.