Skip to end of metadata
Go to start of metadata

The {code} markup lets you include sample code in your document.

{code}Hello, world!{code}

You can also specify the language of the code, either java or xml. (This will be used to apply syntax markup in the DocBook XML transformation.) For example:

You can obtain a UserTransaction from JNDI:
{code:java}
	InitialContext ic = new InitialContext();
	UserTransaction utx = ic.lookup("java:comp/UserTransaction")
{code}

You can obtain a UserTransaction from JNDI:

Add a title to your code sample by modifying the opening {code} tag, like so:

{code:java|title=Obtaining a UserTransaction from JNDI}
	InitialContext ic = new InitialContext();
	UserTransaction utx = ic.lookup("java:comp/UserTransaction")
{code}
Obtaining a UserTransaction from JNDI

The DocBook that results is of the following format:

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 01, 2012

    If a user wants to add XML mark-up using confluence, is there an issue with using the < and > angle brackets with a view to XML export?

    When exported to DocBook, do these symbols (and other XML special characters) get converted to their appropriate XML entities (for example < and &gt;)?

    If the symbols do not get normalized, there will be issues with XML validation in the exported document.

    1. Oct 02, 2012

      Hi Jared,

      everything is exported correctly, exported DocBook XML is valid definitely.