This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: determining position of a document included using document function
- From: "Bryan Rasmussen" <bry at itnisk dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 13 Feb 2002 17:28:02 +0100
- Subject: RE: [xsl] determining position of a document included using document function
- Keywords: xsltDEV
- Reply-to: xsl-list at lists dot mulberrytech dot com
>Could you be more specific about what you mean by "the position of 'file'
>in the root document"? The position() function returns the position of the
>current node within the current node list, which is not (at all) the same
>as the position of a node within a document.
actually I figured a way around my problem but I'd still like to know how to
do it, as it might be useful at some point. Originally I described it as
follows:
>If I'm using document() to make a number of simple includes, like
>
>><xsl:template match="file">
>><xsl:param name="doc" select="document(@href)">
>><xsl:for-each select="$doc">
>><xsl:apply-templates/>
>></xsl:for-each>
>
>>is there anyway to find out the position of file in the root document,
>>without trying to do <xsl:apply-templates>
>><xsl:with-param name="filepos" select="position()"/>
>></xsl:apply-templates>
>
>>my problem is that I have a template being applied quite low in the
included
>>documents which needs to know the position of the including document.
I was, as is my wont, probably horrendously unclear, let me clarify:
I run stylesheet1 against document1, document1 has a structure sort of like
in all the classic "xinclude with xslt" examples:
i.e
<doc>
<file href="document2.xml"/>
<file href="document3.xml"/>
</doc>
so when I get to the file node I use the document function as above to load
the document referred to by the href attribute,
then I apply-templates against that document, however I found in the
document I loaded at one point I would really have liked to know something
about the position of the file node which had the attribute href from which
I knew what document to load! :)
I can actually see where that might get very useful to know, or the
knowledge of what file's parent is, in cases where I load a document into
the middle of another one, which I do often, and I suppose others do as
well. Obviously that could be done by passing a parameter but what if, as in
this case, I need to apply-templates five or six times before I get to the
actual template I need the info in. so I'm hoping someone has a good answer
for this, I'm sort of having problems concentrating, and have had these
problems for the last week, what with over-consumption of coffee, and
finding out all the splendid ways that fop is sort of buggy.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list