Subject: RE: Finding the root element From: "Reynolds, Gregg" <greynolds@xxxxxxxxxxxxxx> Date: Fri, 30 Oct 1998 13:38:05 -0600 |
Probably you encountered a problem when trying to use (current-node) to get at the document element directly, which is problem that crops up regularly. Since (current-node) is so commonly used to get at nodes of type element, the natural question is "why can't I use it for the root element"; but the production (172, p 176 or thereabouts) says "A root-construction-rule matches any node of class sgml-document". That class is defined to have a 'docelem' property whose value is of type element. (see definition of psmodule 'instabs', p 90). So actually, it would be inaccurate (if my understanding is correct) to say that (current-node) returns the root; it looks to me like it behaves exactly as specified. Where I think the standard could use some clarification is in the definition of (current-node); rather than "the semantics of this are defined by the context..." it might say something like "the class of the node returned depends on contenxt...". Your original question was: "Is it possible to find the node of the document element outside the context of another element? Specifically, can I find it in a function called from (root)?" Since the grove root is by definition the only node that does not appear as the value of any subnode property of any node, and since the sgmldoc node is the only node (that I know of) that fits that description, one should be able to get the same effect by using the 'grovroot' intrinsic property from any node, regardless of its class: (node-property 'property-appropriate-to-class-of-snl (node-property 'document-element (node-property 'grove-root snl))) At least I think so. I have not tested it. (Instrinsic properties are defined in section 9.4.) A question I have is, why is the meaning of (current-root) context dependent? Presumably this comes into play in hypergroves? Or subdocs? I infer it would be possible for node a to have a property of type urefnode, such that a value of that property, say node b, has a different grove-root than does node a. Accurate? -----Original Message----- From: Norman Walsh [mailto:ndw@xxxxxxxxxx] Sent: Thursday, October 29, 1998 11:49 AM To: dssslist@xxxxxxxxxxxxxxxx Cc: Norman Walsh Subject: Re: Finding the root element | Actually, undocumented feature of Jade is that (current-node) does in fact | return the root inside a root rule. So the following works: | | (root | (literal | (debug (node-property 'gi | (node-property 'document-element (current-node)))))) Right you are. Thanks, Henry. I swear I got an error once about current-node being undefined in root, which is why I've lept through all sorts of hurdles to get around the problem. I must have misinterpreted an error message... Cheers, norm -- Norman Walsh <ndw@xxxxxxxxxx> | Everything the same; everything http://nwalsh.com/ | distinct. DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Finding the root element, Norman Walsh | Thread | Jadetex 2.3 - table cell spacing, Glenn Kronschnabl |
Re: Finding the root element, W. Eliot Kimber | Date | Re: Distribution permissions for DS, Jon Bosak |
Month |