cvs commit: doc/en_US.ISO8859-1/books/handbook book.sgml doc/en_US.ISO8859-1/books/handbook/introduction chapter.sgml doc/en_US.ISO8859-1/books/handbook/install chapter.sgml doc/share/sgml trademarks.ent
Simon L. Nielsen
simon at FreeBSD.org
Tue Aug 19 20:14:58 UTC 2003
[Moved to -doc]
On 2003.08.18 20:34:53 -0700, Murray Stokely wrote:
> On Tue, Aug 19, 2003 at 02:57:35AM +0200, Simon L. Nielsen wrote:
> > I'm trying to make the stylesheet do this automatically without the need
> > for an role attribute (which is the way it should really work IMO), but
> > it's a bit more tricky than I thought. I though I could just make a
> > list of trademarks that have been shown with trademark symbol, but it
> > doesn't seem that DSSSL allow global/persistent variables, so for each
> > trademark I have to go back and check if the current trademark have been
> > shown with a trademark symbol before.
>
> I only considered that for half a second before deciding it would be a
> very silly things to waste tens of hours of my time on. ;) If you
Hehe. It probably only took about 10 hours, but then again, I had never
done any Scheme/DSSSL before :-).
The patch I came up with actually works fairly well. Of course it
probably needs some adjustment, but the base is there.
It only display a trademark symbol for each trademark the first in a
document for print/html, and the first time on each HTML page for
html-split. Then we can just use the trademark entities/tags for all
the referneces (or most).
If somebody then add or remove a trademark reference, it will still do
it right.
It differentiates between trademarks references in normal text and
titles so if there is a trademark in a title, the symbol will be
displayed the first time in the title, and the first time in the normal
text.
I did some performance tests and even though the stylesheet has to go
through the SGML tree quite a lot to look for trademarks, there wasn't
any measurable performance hit.
Anyway, patch is attached. Comments are very welcome.
> really want to do this then check out the way that footnotes and
> ulinks are counted inside chapters in Norm's stylesheets. There may
> be some code you can use there, but I definitely think a simple
> attribute is the way to go for now.
Thanks for the foodnote pointer; it contained a very useable example.
> > /me mumbles that it could have done in half an hour, if DSSSL had used a
> > sensible language. :-)
>
> You could probably add a pre-processing step in XSLT to add the
> attributes automatically.
I tried it briefly, but it complained a lot about all the SGML stuff. I
might have done something wrong though.
--
Simon L. Nielsen
FreeBSD Documentation Team
-------------- next part --------------
--- /FreeBSD/clean/doc/share/sgml/freebsd.dsl Fri Aug 15 13:40:43 2003
+++ doc/share/sgml/freebsd.dsl Tue Aug 19 16:05:47 2003
@@ -232,6 +232,26 @@
(literal "``")
(process-children)
(literal "''")))
+
+ ;; The special FreeBSD version of the trademark tag handling
+ ;; This function was more or less taken from the DocBook DSSSL
+ ;; stylesheets by Norman Walsh
+ (element trademark
+ (if (show-tm-symbol? (current-node))
+ (make sequence
+ ($charseq$)
+ (cond
+ ((equal? (attribute-string "class") (normalize "copyright"))
+ (make entity-ref name: "copy"))
+ ((equal? (attribute-string "class") (normalize "registered"))
+ (make entity-ref name: "reg"))
+ ((equal? (attribute-string "class") (normalize "service"))
+ (make element gi: "SUP"
+ (literal "SM")))
+ (else
+ (make entity-ref name: "#8482"))))
+ ($charseq$)))
+
]]>
<!-- HTML with images ............................................ -->
@@ -669,6 +689,29 @@
scale: graphic-scale
display?: display
display-alignment: graphic-align)))
+
+ ;; The special FreeBSD version of the trademark tag handling
+ ;; This function was more or less taken from the DocBook DSSSL
+ ;; stylesheets by Norman Walsh
+ (element trademark
+ (if (show-tm-symbol? (current-node))
+ (make sequence
+ ($charseq$)
+ (cond
+ ((equal? (attribute-string "class") (normalize "copyright"))
+ (literal "\copyright-sign;"))
+ ((equal? (attribute-string "class") (normalize "registered"))
+ (literal "\registered-sign;"))
+ ((equal? (attribute-string "class") (normalize "service"))
+ ($ss-seq$ + (literal "SM")))
+ (else
+ (literal "\trade-mark-sign;"))))
+ ($charseq$)))
+
+ ;; Make the trademark functions think print output has chunks
+ (define (chunk-parent nd)
+ (sgml-root-element nd))
+
]]>
<![ %output.print.pdf; [
@@ -937,6 +980,44 @@
attributes: attrlist
target)
target))
+
+ ;; Standard boolean XNOR (NOT Exclusive OR)
+ (define (xnor x y)
+ (or (and x y)
+ (and (not x) (not y))))
+
+ ;; Standard boolean XOR (Exclusive OR)
+ (define (xor x y)
+ (not (xnor x y)))
+
+ ;; Determine if a given node is in a title
+ (define (is-in-title? node)
+ (has-ancestor-member? node (list (normalize "title"))))
+
+ ;; Number of references to a trademark before the current reference
+ (define ($chunk-trademark-number$ trademark)
+ (let* ((trademarks (select-elements
+ (descendants (chunk-parent trademark))
+ (normalize "trademark"))))
+ (let loop ((nl trademarks) (num 1))
+ (if (node-list-empty? nl)
+ num
+ (if (node-list=? (node-list-first nl) trademark)
+ num
+ (if (and (string=? (data trademark)
+ (data (node-list-first nl)))
+ (xnor (is-in-title? trademark)
+ (is-in-title? (node-list-first nl))))
+ (loop (node-list-rest nl) (+ num 1))
+ (loop (node-list-rest nl) num)))))))
+
+ ;; Determine if we should show a trademark symbol. Either in
+ ;; first occurrence in the proper contect, or if the role
+ ;; attribute is set to force.
+ (define (show-tm-symbol? trademark)
+ (or (= ($chunk-trademark-number$ trademark) 1)
+ (equal? (attribute-string (normalize "role") trademark) "force")))
+
</style-specification-body>
</style-specification>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-doc/attachments/20030819/2f182535/attachment.sig>
More information about the freebsd-doc
mailing list