|
Subject: [xsl] Breaking up Program Code Examples From: Craig Sampson <Craig.Sampson@xxxxxxx> Date: Tue, 18 Sep 2012 19:33:40 +0000 |
Hello,
We are having issues with copying and pasting programming code examples in our
documentation.
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
problem.
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
problems.
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"
linefeed-treatment="preserve">
<xsl:for-each select="tokenize(., '\n')">
<fo:block><xsl:sequence select="."/></fo:block>
</xsl:for-each>
</fo:block>
Here is an example of the XML:
<codeBlock eid="n0b7p8f53ujhsbn17928o22t9lyb">
<code eid="p01xqdrm89zmnon115yg9qm064mb">begin;
x=y+<userSuppliedValue>2</userSuppliedValue>;
end;</code>
</codeBlock>
The <userSuppliedValue> element italizes the code it contains but
since it's getting eaten by tokenize what we get is:
begin;
x=y+2;
end;
Thanks for any suggestions on how to get this working.
Craig
--------------------------------------------------------------------
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Typing variables, Michael Kay | Thread | Re: [xsl] Breaking up Program Code , G. Ken Holman |
| RE: [xsl] XSL-FO preformatted text , Lynn Hales | Date | Re: [xsl] Breaking up Program Code , G. Ken Holman |
| Month |