[xsl] Elements within "as-is" environment misaligning

Subject: [xsl] Elements within "as-is" environment misaligning
From: "Cindy Hunt" <Cindy.Hunt@xxxxxxx>
Date: Tue, 11 Dec 2007 15:08:39 -0500
Hi-

I am experiencing problems when transforming sections of "as-is" code. I
have an element which contains a sample of programming code within it.
Within the code sample I have some additional elements I call
<codeFocus> which will highlight that part of the code when it is
formatted. During the XSL-FO transform, the alignment around these
<codeFocus> elements gets messed up. The first one seems fine but then
the 2nd one has an extra blank line that appears before it starts and
the start tag is shifted over to the right (so it is no longer "as-is").

I am using a Saxon parser and version 1.0. I use Antenna House for the
FO formatting but the problem occurs before the doc is formatted.

My XML input:
<code>Dim obConnection As New ADODB.Connection
    Dim obRecordset As New ADODB.Recordset

    <codeFocus>obConnection.Provider = "SAS.IOMProvider.1"</codeFocus>
    <codeFocus>obConnection.Properties("Prompt") =
adPromptAlways</codeFocus>
    obConnection.Open

    obRecordset.Open "sasuser.MyData", obConnection, adOpenDynamic,
adLockOptimistic, adCmdTableDirect
    ' Operate on obRecordset.
</code>


My FO output (note the blank line between the 2 fo:inline and how the
2nd one indents in now):
                     <fo:block font-family="'Courier Standard',
'monospace', 'Arial Unicode MS' " font-size="8.5pt" font-stretch="90%"
line-height="12pt" start-indent="93pt+15pt"
linefeed-treatment="preserve" white-space-treatment="preserve"
white-space-collapse="false" wrap-option="no-wrap" space-before="6pt"
space-after="0pt">Dim obConnection As New ADODB.Connection
    Dim obRecordset As New ADODB.Recordset

    <fo:inline background-color="rgb(235, 235, 235)" padding-left="2pt"
padding-right="2pt">obConnection.Provider =
"SAS.IOMProvider.1"</fo:inline>

                        <fo:inline background-color="rgb(235, 235, 235)"
padding-left="2pt" padding-right="2pt">obConnection.Properties("Prompt")
= adPromptAlways</fo:inline>
    obConnection.Open

    obRecordset.Open "sasuser.MyData", obConnection, adOpenDynamic,
adLockOptimistic, adCmdTableDirect
    ' Operate on obRecordset.
</fo:block>

I did notice that if I type a letter before the 2nd <codeFocus> element,
it works fine and doesn't insert the extra line or shift over.

I even tried defining my xsl:template on a line by itself as not to get
any carriage returns:
	<xsl:template match="codeFocus"><fo:inline
background-color="rgb(235, 235, 235)" padding-left="2pt"
padding-right="2pt"><xsl:apply-templates/></fo:inline></xsl:template>

Does anyone have any ideas to prevent this from happening?

Any suggestions appreciated,
Cindy Hunt

Current Thread