|
Subject: Re: default element construction rule From: Gregg Reynolds <greyno@xxxxxxx> Date: Mon, 13 Apr 1998 22:12:57 -0400 |
Paul Prescod wrote:
>
> The default rule is invoked at *every level* in the absenseof anything
> else that matches.
Yes and no. Below you'll find a very simple dtd, doc instance and
stylesheet. If you experiment with commenting out various lines you'll
find that the only way to fire the H2 element-construction rule is to
include a construction rule for its ancestors, **UNLESS** you omit the
default-element-construction-rule. The relevant passages from the
standard are:
(sect. 12.4.1, p. 174) "A flow object tree is constructed ... by
processing the root node of the source grove ... the flow objects
specified by the resulting sosofo are added as children of the root of
the flow object tree." (comment: the "resulting sosofo" results from
processing the root node, which may or may not include processing its
children; this is true for all nodes in the grove, AFAIK.)
(p. 175) "In addition to construction rules explicitly specified in
style-language-bodies, there is an implicit-default-construction-rule.
The default construction rule matches any node in a source grove but is
less specific than any explicitly specified construction-rule".
(comment: if you include an explicit default construction rule, the
implicit one (which returns, eg, (process-children) for nodes of class
"element") is overridden. If you don't override it with an explicit
default rule, you get the whole shebang.)
End result: if you want to include a default-construction-rule and you
also want to fire some rules for nodes within the grove hierarchy, you
must provide a "path" of explicit construction-rules. The default rule
is indeed invoked for every element on a given level, but only if
processing reaches that level.
Here's the dssslsheet:
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"
[
]>
(declare-flow-object-class entity
"UNREGISTERED::James Clark//Flow Object Class::entity")
(declare-flow-object-class element
"UNREGISTERED::James Clark//Flow Object Class::element")
(default (empty-sosofo))
(element ROOT
(make entity ;;; comment out this and the next line to see the
results on stdout
system-id: "foo.dat"
(process-matching-children "H1" "H2")))
;;; (process-children)))
;;;(element H1
;;; (process-children))
(element H2
(make element
gi: "H2"
(literal "This is an H2 element")))
...and here's the dtd and doc instance:
<!DOCTYPE root [
<?dsssl dft.dsl>
<!ELEMENT root - - (H1)*>
<!ELEMENT H1 - - (H2)*>
<!ELEMENT H2 - - (H3)*>
<!ELEMENT H3 - - (#PCDATA)>
]>
<root>
<H1></H1>
<H1>
<H2></H2>
</H1>
<H1>
<H2>
<H3>foo</H3>
<H3>bar</H3>
</H2>
</H1>
</root>
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: default element construction ru, Paul Prescod | Thread | Re: default element construction ru, Chris Maden |
| Re: default element construction ru, Paul Prescod | Date | Re: default element construction ru, Chris Maden |
| Month |