[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: DOCBOOK-APPS: Problem with centering images using DSSSLstylesheets?
[cc'd to Norm] On Wed, Feb 21, 2001 at 05:46:52PM -0500, Dan York wrote: > I'm having a problem with not being able to center graphics in either > the HTML or PDF files that I am generating. Bug in the stylesheets. I've got a patch, but it might need some work. It also only applies to the HTML stylesheets. If you look at the generated HTML, you'll see something like <div class="MEDIAOBJECT"> <p><img src="foo.png" alt="Foo"></p> </div> Tracing through Norm's code, it's something like this (in .../html/db31.dsl). 1. The code in "(element mediaobject ... )" runs. This code creates the DIV element and the P element inside it. This code does not know which (if any) elements are going to occur inside the MediaObject element. Control is handed to the $mediaobject$ function. 2. $mediaobject$ calls various other functions to work out which elements inside the MediaObject element are displayable. Inside this function "dobject" means the displayable object (chosen by select-displayable-object). In your example, dobject will end up being a reference to the ImageObject element. 3. "(element imageobject ... )" doesn't do anything except hand off processing to its children. In your case, the ImageData element. 4. "(element imagedata ... )" can look at the ImageData attributes, and do appropriate things with the Align attribute. But at this point we're too late. The patch removes the generation of the P element from the MediaObject element, and adds it to each of the ImageData, AudioData, and VideoData elements instead. This sort of works. Images are aligned as you want. However, it's then not possible to do 'floating' images (the equivalent of <img align="right"> in HTML), and the caption (if you have one) still appears on the left margin. A better approach might be to move the processing in to the $mediaobject$ function. Let it work out which is the displayable object (which it already does) then have it walk down the tree until it reaches the *data element, and pull out the align value. Then it can create paragraphs for the *data content and the caption using this data. That's left as an exercise for the reader. As is creating an default-image-alignment variable that could be used to specify how images line up normally. N -- Internet connection, $19.95 a month. Computer, $799.95. Modem, $149.95. Telephone line, $24.95 a month. Software, free. USENET transmission, hundreds if not thousands of dollars. Thinking before posting, priceless. Somethings in life you can't buy. For everything else, there's MasterCard. -- Graham Reed, in the Scary Devil Monastery
--- db31.dsl.org Thu Feb 22 16:46:28 2001 +++ db31.dsl Thu Feb 22 17:49:40 2001 @@ -86,8 +86,7 @@ (element mediaobject (make element gi: "DIV" attributes: (list (list "CLASS" (gi))) - (make element gi: "P" - ($mediaobject$)))) + ($mediaobject$))) (element inlinemediaobject (make element gi: "SPAN" @@ -108,16 +107,18 @@ (element videodata (let ((filename (data-filename (current-node)))) - (make element gi: "EMBED" - attributes: (list (list "SRC" filename))))) + (make element gi: "P" + (make element gi: "EMBED" + attributes: (list (list "SRC" filename)))))) (element audioobject (process-children)) (element audiodata (let ((filename (data-filename (current-node)))) - (make element gi: "EMBED" - attributes: (list (list "SRC" filename))))) + (make element gi: "P" + (make element gi: "EMBED" + attributes: (list (list "SRC" filename)))))) (element imageobject (process-children)) @@ -140,6 +141,7 @@ (data (node-list-first phrase)))))))) (fileref (attribute-string (normalize "fileref"))) (entityref (attribute-string (normalize "entityref"))) + (align (attribute-string (normalize "align"))) (format (if (attribute-string (normalize "format")) (attribute-string (normalize "format")) (if entityref @@ -149,12 +151,14 @@ (if fileref (include-file fileref) (include-file (entity-generated-system-id entityref))) - (make element gi: "IMG" - attributes: (append - (list (list "SRC" filename)) - (if alttext - (list (list "ALT" alttext)) - '())))))) + (make element gi: "P" + attributes: (if align (list (list "ALIGN" align)) '()) + (make element gi: "IMG" + attributes: (append + (list (list "SRC" filename)) + (if alttext + (list (list "ALT" alttext)) + '()))))))) (element textobject (make element gi: "DIV"
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC