[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Breaking up Program Code Examples

Subject: [xsl] Breaking up Program Code Examples
From: Craig Sampson <Craig.Sampson@xxxxxxx>
Date: Tue, 18 Sep 2012 19:33:40 +0000


We are having issues with copying and pasting programming code examples in our
The documentation has coding examples and our users want to copy these lines
of code and paste
them in their applications in order to run them. The newlines in the code,
we're outputting in
as-is mode, were being lost so Antenna House suggested that we place
<fo:block> elements
around each line of code. Outputting each line in its own block will hopefully
eliminate the

We are using an xsl:tokenize statement to read up until the newline character.
This works fine
for breaking up our code examples into individual lines but we have 2

1) We lose indents in the code when pasted.
2) We allow a few embedded elements, like <userSuppliedValue>, within our
<code> element
that we are losing through the tokenize. We still need these to surface so we
can react
when they are present.

Here is the example of the tokenize:

<fo:block xsl:use-attribute-sets="code" space-before="6pt" space-after="0pt"
    white-space="pre" white-space-treatment="preserve"
  <xsl:for-each select="tokenize(., '\n')">
    <fo:block><xsl:sequence select="."/></fo:block>

Here is an example of the XML:
<codeBlock eid="n0b7p8f53ujhsbn17928o22t9lyb">
<code eid="p01xqdrm89zmnon115yg9qm064mb">begin;

The <userSuppliedValue> element italizes the code it contains but
since it's getting eaten by tokenize what we get is:


Thanks for any suggestions on how to get this working.


Craig R. Sampson    SAS Institute Inc.  email: craig.sampson@xxxxxxx
  XML Technologies  SAS Campus Drive    phone: (919) 531-7417
                    Cary, NC.  27513    FAX:   (919) 677-4444
     Please consider the environment before printing this email

Current Thread