Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2003 22:14:56 +0200
From:      "Simon L. Nielsen" <simon@FreeBSD.org>
To:        Murray Stokely <murray@FreeBSD.org>
Cc:        freebsd-doc@freebsd.org
Subject:   Re: 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
Message-ID:  <20030819201456.GH392@FreeBSD.org>
In-Reply-To: <20030818203453.R235@freebsdmall.com>
References:  <200308171355.h7HDt5ii082681@repoman.freebsd.org> <20030817140406.GB391@FreeBSD.org> <20030818123221.C235@freebsdmall.com> <20030819005734.GC1489@FreeBSD.org> <20030818203453.R235@freebsdmall.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--+1TulI7fc0PCHNy3
Content-Type: multipart/mixed; boundary="eNMatiwYGLtwo1cJ"
Content-Disposition: inline


--eNMatiwYGLtwo1cJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

[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.
>=20
> 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. :-)
>=20
> 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.

--=20
Simon L. Nielsen
FreeBSD Documentation Team

--eNMatiwYGLtwo1cJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="doc-trademark-auto-dsssl.patch"
Content-Transfer-Encoding: quoted-printable

--- /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$)=09
+		(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$)))
+
       ]]>
=20
       <!-- 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=20
+	  (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))
+
       ]]>
=20
       <![ %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=3D? (node-list-first nl) trademark)
+		    num
+		    (if (and (string=3D? (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 (=3D ($chunk-trademark-number$ trademark) 1)
+	    (equal? (attribute-string (normalize "role") trademark) "force")))
+
     </style-specification-body>
   </style-specification>
      =20

--eNMatiwYGLtwo1cJ--

--+1TulI7fc0PCHNy3
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE/QoU/h9pcDSc1mlERAoFdAKC+B3Xwl+tNqyeC/X8Dbcgh670EdgCgtgfl
bzYBsk0gmrimdwDKCLN+qtU=
=W8OV
-----END PGP SIGNATURE-----

--+1TulI7fc0PCHNy3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030819201456.GH392>