Getting formatted code samples into DITA

H_Too_Oh
Posts: 44
Joined: Tue Mar 13, 2012 5:01 pm

Getting formatted code samples into DITA

Post by H_Too_Oh » Thu May 17, 2012 10:43 am

Could someone walk me through the preferred way to get code/markup into DITA using Oxygen? I knew how to do this by importing text files in other XML tools but I'm not working out how to do it with Oxygen. I read about <coderef> and tried that but not getting what I need.

I just want to insert something like this into a topic:

Code: Select all

  

<xsl:template name="InsertFooter">
<fo:block>
<fo:table width="100%">
<fo:table-column column-number="1"
column-width="30%" />
<fo:table-column column-number="2"
column-width="40%" />
<fo:table-column column-number="3"
column-width="30%" />
<fo:table-body>
<fo:table-row height="10mm">
<fo:table-cell margin-left="0pt"
margin-right="0pt">
<fo:block margin-top="5pt"
text-align="left"></fo:block>
</fo:table-cell>
<fo:table-cell margin-left="0pt"
margin-right="0pt">
<fo:block margin-top="5pt"
text-align="center">Copyright © 2012
</fo:block>
</fo:table-cell>
<fo:table-cell margin-left="0pt"
margin-right="0pt">
<fo:block margin-top="5pt"
text-align="right"><fo:page-number/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
so it looks that way. If I paste it into a codeblock it doesn't come out that way, and if I use a link using coderef it just puts a reference, not the text displayed as above. I can use codeblock for code that's one line long, but nothing like the above it seems.

In Epic Editor I remember that this involved putting the xsl or xml markup into a separate text file and importing it a certain way, but I don't remember details. I'm sure there's something similar?

Radu
Posts: 6398
Joined: Fri Jul 09, 2004 5:18 pm

Re: Getting formatted code samples into DITA

Post by Radu » Thu May 17, 2012 4:21 pm

Hi,

Either you use a syntax like:

Code: Select all

<codeblock><coderef href="test.frag"/></codeblock>
where the @href attribute points to the file where the fragment is located.

or you paste the XSL content directly in the Author page in a <codeblock>.
If you choose the paste alternative and it does not work, there might be another flavor in the system clipboard which is preferred by Oxygen (some browsers also set an HTML flavor which is preferred by Oxygen).
You could try to first paste in a very simple text application like Notepad, then copy from there and paste in the Author page.

What exactly do you want to obtain in the output? Do you also want XML syntax highlight on those fragments?
I remember there was a DITA OT plugin for this but I've never tried it myself.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

H_Too_Oh
Posts: 44
Joined: Tue Mar 13, 2012 5:01 pm

Re: Getting formatted code samples into DITA

Post by H_Too_Oh » Thu May 17, 2012 6:12 pm

Okay, that was useful to know that simply pasting it in to a codeblock tag should work. I was copying from what seemed like a text file but it was actually an .rtf format, so I moved it to a plain text file as an intermediary and copied from there, and that way it pastes in without mixing up the alignments. That's even better than the other XML editor, in which pasting wouldn't work, only referencing.

That's all I needed for this, but I might look into what that plugin was at some point, that could be useful.

Thanks again,

Post Reply