RE: determining position of a document included using
>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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format