Re: [xsl] XSL-FO: Fixed box to construct empty text-box or tick-box.

Subject: Re: [xsl] XSL-FO: Fixed box to construct empty text-box or tick-box.
From: "Lloyd Thompson" <lloyd_t@xxxxxxxxxxx>
Date: Thu, 23 Mar 2006 15:45:10 +0000
Unfortunately it would appear that for some reason Apache FOP will not let me place a block-container inside a list-item-body, I get the following error:

[ERROR] org.apache.fop.layout.BlockArea

Furthermore, the inline-container which had a leader inside also didn't render. Aside from the W3C spec for FO is there a site which provides a widely supported API like reference for FO elements?

I did manage to render fixed size boxes using SVG, however now my answer options appears next to the top of the box - how can I vertically align my answer text so it appears next to the box but centrally vertically aligned?

Current code as follows:

<fo:table border-collapse="separate" table-layout="fixed" space-before="0.5cm">
<fo:table-column column-width="11.5cm" />
<fo:table-column column-width="0.5cm" />
<fo:table-column column-width="3.75cm" />
<fo:table-column column-width="0.5cm" />
<fo:table-column column-width="3.75cm" />
<fo:table-body>
<fo:table-row>


						<fo:table-cell>
							<fo:block  font-family="Times">Question?</fo:block>

</fo:table-cell>

<fo:table-cell>
<fo:block>
<fo:instream-foreign-object>
<svg:svg>
<svg:rect fill="none" stroke-width="0.5" stroke="black" height="5mm" width="5mm" />
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>


						<fo:table-cell>
							<fo:block height="5mm" start-indent="3pt">Yes</fo:block>
						</fo:table-cell>

<fo:table-cell>
<fo:block>
<fo:instream-foreign-object>
<svg:svg>
<svg:rect style="fill:none;stroke:black" height="5mm" width="5mm" />
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>


						<fo:table-cell >
							<fo:block  start-indent="3pt">No</fo:block>
						</fo:table-cell>

					</fo:table-row>
				</fo:table-body>
			</fo:table>

Thanks,

Lloyd

From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSL-FO: Fixed box to construct empty text-box or tick-box.
Date: Wed, 22 Mar 2006 13:10:09 -0500


At 2006-03-22 17:23 +0000, Lloyd Thompson wrote:
I am writing XSL-FO to produce a questionnaire document. For this I will need to create empty text-boxes and tick-boxes.

When I've had to create quiz layouts, I've used <block-container> very effectively: if the quiz had a specified distance *including* the question, the question is flowed inside the <block-container>, whereas if the quiz had a specified distance for just the answer, the question is flowed before the <block-container>.


Here is the test bed that I used to learn this ... these are the first two questions from our evaluation form for our hands-on XSL training ... the first has the question inside the block container, the second has the question before the block container:

<list-item>
<list-item-label text-align="end" end-indent="label-end()">
<block>1)</block>
</list-item-label>
<list-item-body start-indent="body-start()">
<block-container block-progression-dimension="2.3cm">
<block start-indent="0pt">
<xsl:text>Did the material cover what you were expecting?</xsl:text>
</block>
</block-container>
</list-item-body>
</list-item>
<list-item>
<list-item-label text-align="end" end-indent="label-end()">
<block>2)</block>
</list-item-label>
<list-item-body start-indent="body-start()">
<block space-before="inherited-property-value(font-size) * .5"
text-align-last="justify">
<xsl:text>Quality of the presentation slides:</xsl:text>
<leader/>
<xsl:text>(poor) 1 - 10 (excellent): </xsl:text>
<leader leader-pattern="rule" leader-length="1cm"
rule-thickness="1pt"/>
</block>
<block space-before="inherited-property-value(font-size) * .5">
<xsl:text>How might the presentation slides be improved?</xsl:text>
</block>
<block-container block-progression-dimension="2.0cm"
start-indent="0pt"
space-before="inherited-property-value(font-size) * .5">
<block/>
</block-container>
</list-item-body>
</list-item>


For tick-boxes, I use a bordered <inline-container>, as in the following also from my evaluation sheet, though this appears to only work in Antenna House and not in XEP or in Ibex, and I haven't bothered to figure out who is right and who is wrong ... it might only be an issue of those tools not supporting <inline-container>:

    <block space-before="inherited-property-value(font-size) * .5"
           text-align-last="justify">
      <xsl:text>Would you like to be contacted for information</xsl:text>
      <xsl:text> on future courses from either the event</xsl:text>
      <xsl:text> organizers or directly from Crane?</xsl:text>
      <leader/>
      <inline-container width="1em" height="1em"
                        alignment-adjust="text-after-edge"
                        border-style="solid" border-width="1pt">
        <block><leader/></block>
      </inline-container>
      <xsl:text> No </xsl:text>
      <inline-container width="1em" height="1em"
                        alignment-adjust="text-after-edge"
                        border-style="solid" border-width="1pt">
        <block><leader/></block>
      </inline-container>
      <xsl:text> Yes</xsl:text>
    </block>

From my understanding of XSL-FO the above should be right.

I hope this helps.

. . . . . . . . Ken

At 2006-03-22 17:23 +0000, Lloyd Thompson wrote:

Greetings,

I am writing XSL-FO to produce a questionnaire document. For this I will need to create empty text-boxes and tick-boxes. So far, I have managed to produce text-boxes using fo:table; the text-boxes are simply cells that contain borders. The problem is that this box grows as the text in another column spans over more than one line, so ideally I want to place a fixed size box in the table.

What is the best way to go about doing this? I tried to create an empty fo:block and specified attributes for height and width but unfortunatley as the box is not populated, it appears as a flat line. Do I have to produce an SVG?

Many thanks,

Lloyd


--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread