Subject: RE: [xsl] Getting the root element. From: Jeff Beadle <Jbeadle@xxxxxxxx> Date: Thu, 24 Jul 2003 06:54:47 -0400 |
Be advised though, that doesn't always work ... at least maybe not in the way you think. I guess it depends on which "document" root node you need. If you've constructed xml within a variable, lets say, and then you apply-templates on that given instance, xpathing--within context--to "/" will take you to the root of the xml "document" within that given variable. What I mean by "within context" is operations conducted on/within the context node. For example, if you xpath to "/" within a predicate or a for-each that's is operating on the context node. To get around this, what I do is pre-load a "this" variable at "global" scope with "/" ... or, you could do it locally--but, I don't think that makes sense if you plan to access that path within multiple/separate code paths. To illustrate what I'm babbling about: xml: <xml/> xsl: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"> <xsl:output method="text"/> <xsl:variable name="this" select="/"/> <xsl:template match="/"> <xsl:variable name="my-instance"> <node/> </xsl:variable> <xsl:apply-templates select="msxsl:node-set($my-instance)/node"/> </xsl:template> <xsl:template match="node"> context "/" name: <xsl:value-of select="name(/*[1])"/>; global "/" name : <xsl:value-of select="name($this/*[1])"/>; </xsl:template> </xsl:stylesheet> Anyhow, this may not be an issue for you. -Jeff -----Original Message----- From: Jarno.Elovirta@xxxxxxxxx [mailto:Jarno.Elovirta@xxxxxxxxx] Sent: Thursday, July 24, 2003 6:02 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Getting the root element. Hi, > Q: > When deep within the structure (In my case recursing down a > branch) what it > the most elegent way of getting the document root node? / Cheers, Jarno - Covenant: Bullet (Club Version) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Getting the root element., Jarno . Elovirta | Thread | [xsl] namespace conflict, sathish . kumar |
Re: [xsl] Getting the root element., Eric van der Vlist | Date | RE: [xsl] Change text on given node, Mukul Gandhi |
Month |