lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] newline in C++ variables


From: Greg Chicares
Subject: Re: [lmi] newline in C++ variables
Date: Tue, 15 Sep 2009 14:27:49 +0000
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

On 2009-09-12 15:37Z, Wendy Boutin wrote:
> On 2009-09-12 11:03, Greg Chicares wrote:
>> On 2009-09-12 13:55Z, Wendy Boutin wrote:
>>> On 2009-09-12 08:11, Greg Chicares wrote:
[...]

Let's step back and state the problem we're trying to solve;
but first we need to discuss the background context.

Illustrations typically include many conditional footnotes.
Here's a fictitious example to show why they're conditional:
  "Illustrations for juveniles in the state of New York
  require a parental signature."
We don't want to say that for a California octogenarian, or even
for an adult New Yorker or a newborn Texan.

Each illustration uses exactly one of about half a dozen xsl
files for printed output. In the regrettable past, footnotes were
replicated inline in every xsl file that needed them. If it just
so happened that we didn't need to show variable annuities to
New York juveniles, then maybe the footnote above would have been
written inline in all xsl files except 'variable_annuity.xsl' and
the generic 'fo_common.xsl', with conditional logic like this:

  <xsl:if test="$scalars/StatePostalAbbrev='NY'">
    <xsl:if test="$scalars/Age &le; 18">
      <fo:block>
        Illustrations for juveniles in the state of New York
        require a parental signature.
      </fo:block>
    </xsl:if>
  </xsl:if>

Then someone would decide to reword it:
-        require a parental signature.
+        require a parent or legal guardian's signature.
and five files totalling a quarter of a megabyte would be edited,
often introducing accidental discrepancies.

Of course that approach was foolish. By trying to minimize the
immediate effort for each change, it increased long-term cost and
compromised quality. That's the general problem Wendy's working
on--instead, we want to specify each footnote once and only once,
in C++ code that generates '.pol' files, e.g.:

  std::string canonical_new_york_juvenile_footnote =
    "Illustrations for juveniles in the state of New York"
    " require a parental signature.";

and move the conditions into the C++ code that writes xml, e.g.:

  std::string NewYorkJuvenileFootnote = "";
  if("NY" == StatePostalAbbrev && Age <= 18)
    {NewYorkJuvenileFootnote = canonical_new_york_juvenile_footnote;}
  // write that to the xml file that's passed to xsl

and then write only this in each xsl file:

  <fo:block padding-top="1em">
    <xsl:value-of select="$scalars/NewYorkJuvenileFootnote"/>
  </fo:block>

(One could alternatively consolidate conditional footnotes in a
shared xsl file like 'fo_common.xsl', of course. What's important
is to consolidate them *somewhere*, and I'm satisfied that the
place we're moving them to is appropriate for reasons we need not
go into here.)

In that context, the specific problem we'd like to solve is that
it is considered desirable to show some footnotes as several
separate paragraphs, e.g.:

  Illustrations for juveniles in the state of New York
  require a parental signature.

  Contact the New York State Insurance Department if you
  have any questions about New York regulations pertaining
  to juveniles.

If we were just inserting that in a C++ stream, we could write:
  std::cout << "First paragraph.\n\nSecond paragraph.\n";
Instead, though, we're writing
  C++ --> '.pol' file --> xml --> xsl --> fo --> pdf
and it would be convenient to have a paragraph-separator that
would traverse that whole pipeline and yield the desired effect
in the final pdf output.

Right now, it breaks here:
  C++ --> '.pol' file
if we use '\n', because the '.pol' file is regrettably newline-
delimited text. We'd like to replace weird formats like that
with xml anyway, e.g.:

  <some_footnote>
    First paragraph.[paragraph-separator]Second paragraph.
  </some_footnote>

and I suppose CDATA or 'xml:space="preserve"' might let us use
literal newlines; but that makes me kind of queasy, if only
because of my limited knowledge.

Or we could designate a paragraph-separator (e.g., html &para;)
and pass every footnote through an xsl routine to translate it
into separate 'fo:block' elements. But separate paragraphs are
rarely needed, and I hesitate to impose extra xsl overhead.

Of course, we could just treat separate paragraphs as distinct
footnotes:
  some_footnote_paragraph_0 = "First paragraph."
  some_footnote_paragraph_1 = "Second paragraph."
and maybe that's the least awful solution for what is a fairly
rare problem.

Is there some nifty alternative that I'm not aware of?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]