xsl-list
[Top] [All Lists]

Re: Using document()

2002-10-08 15:18:46
Hello Adam,

document('') returns the root node of the stylesheet, so I assume, that document('#id2') returns the element with id 'id2' in the stylesheet, not the source document. Do from my understanding the expression
generate-id(document('#id2')) = generate-id(//*[(_at_)id='id2'])
will be evaluated to false.

Regards,

Joerg

Adam van den Hoven wrote:
I'm using the XLink model so my hrefs are URIs. In the example I gave,
it's a fragment identifier which should be expanded relative to the
source document (I understand xpointer to allow this). I'm assuming that
'#someval' is still a shortcut which points to some element with an id
value of 'someval'.
From http://www.w3.org/TR/xslt#function-document:
If the URI reference does not contain a fragment identifier, then a
node-set containing just the root node of the document is returned. If
the URI reference does contain a fragment identifier, the function
returns a node-set containing the nodes in the tree identified by the
fragment identifier of the URI reference.

This suggests to me that if I use <xsl:apply-templates
select="document('#id2')" />, I should get the node of the source
document which has an id attribute equal to 'id2'. In the same way, it
suggests that if I use <xsl:apply-templates
select="document('somefile.xml#id2')" />, I should get the node whose id
is 'id2' in 'somefile.xml' which is a sibling to the source document.
So my question is assuming that there is a node with an id (in this case
an id attribute) with a value of 'id2' in my source document can I
reasonably expect the following to be equivalent:

<xsl:apply-templates select="document('#id2')" />

<xsl:apply-templates select="//*[(_at_)id='id2']" />

And the following to be true:

generate-id(document('#id2')) = generate-id(//*[(_at_)id='id2'])

Before I go and start telling excelon that they seem to have a bug in
their product, I want to make sure I'm right in my assumption (if not,
I'm going to have to re-evaluate how I do things).
Adam


-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com [mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of Richard Lander
Sent: October 8, 2002 2:00 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Using document()


The XSLT processor is looking for a resolvable path as the argument to the document function.

If the value of the xlink:href attribute is a path to an actual XML file, then it should work. If it isn't, and it's an IDREF-type link to attribute that contains that value, then you'll need an XPath that will get that value for you.

w/o more information on your document structure ... It is a little hard on this end ...

Rich

-----Original Message-----
From: Adam van den Hoven [mailto:list(_at_)adamvandenhoven(_dot_)com] Sent: Tuesday, October 08, 2002 1:50 PM
To: XSL Mailing list

Sorry if this appears twice, I'm having some problems with my mail systems. I have a question.
I want to use the following:

<xsl:apply-templates select="document('#id2')" />
Ok, I'd never actually use this. In reality its something like:

<xsl:apply-templates select="document(@xlink:href)" />

which is likely to contain simply fragment identifiers since I'm using XLinks to normalize a sitemap hierarchy. When I try to run this as part of a transform, I get an error saying that the file (fully resolved to refer to the source doc) cannot be found. Is this a problem with how I'm doing things or perhaps a problem with app I'm using to develop templates with (Stylus Studio)?

Do you have any other ideas about how I can accomplish the same thing given that some of my xlink:href attributes will point to external documents?

Thanks, H. Adam van den Hoven

Web Developer

Credit Union Central of BC


__________________________________________________
D O T E A S Y - "Join the web hosting revolution!"
            http://www.doteasy.com

XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>