jocelyn.raymond at ualberta.ca wrote: > I have been looking into XXE for some time now, and read through your > available documents. One important thing that I have been trying to > accomplish but were unsucessful goes as follow: > > first my xml file looks like: > > <section section-number="14"> > <header>First header</header> > <paragraph>...</paragraph> > ... > > <header>Second header</header> > <paragraph>...</paragraph> > ... > </section> > > I need to add to each <header> a section number that follow the number > according to the section-number attribute of the root element (<section > section-number="14">). That number is unfortunately not consistent (don't > ask me why; long story) and thus the header should look like in xxe: > > 14.1 First header > ... > > 14.2 Second header > ... > > So I was wondering if I can use the CSS counter() to do such a thing.
No, the counter() pseudo-function can only be used to generate the ".1", ".2". ".3" part of the numbering you want. > Therefore the question is: > Is it possible for the css to refer to an attribute of the root document (or > any ancestor for that matter)? If so, how? [1] With current version V2.5p4, you can do *exactly* what you want but you need to program a CSS style sheet extension in Java. See http://www.xmlmind.com/xmleditor/_distrib/docs/dev/ar01s07.html [2] Next version V2.6 will allow to use an XPath-based pseudo-function, let's call it xpath("XPath 1 expression which returns a string"), similar to standard pseudo-function attr() but much more powerful, which allows to refer to any part of the document. Note that this xpath() pseudo-function is invoked only when the element which is the target of the CSS rule is created, and not each time the document is updated. This means that you may have refresh problems. [3] Version V2.8+ is expected to have another XPath-based pseudo-function, let's call it label(), which is automatically refreshed each time the document is updated (and, for performance reasons, when the editing context changes). Conclusion: unless you can wait a couple of monthes for V2.8+, if you really need a perfect implementation of what you describe, you'll have to implement [1].

