View source to see how easy it is to use the Dojo code highlight in your documentation.
Mimic the format of SyntaxHighlighter, using dojox.highlight and stylesheets, and our simple Code widget extension.
// setup the database named query
dbStatements = new HashMap<String, String>();
dbStatements.put("getCreditDefaultSwapsByEntityName",
"select xmldocument( " +
"xmlquery(" +
"'declare default element namespace \"http://www.fpml.org/2009/FpML-4-7\"; " +
"$DOCUMENT/FpML/trade/creditDefaultSwap' ) " +
" ) " +
"from fpmladmin.fpml43 where comment like ? and " +
"xmlexists(" +
"'declare default element namespace \"http://www.fpml.org/2009/FpML-4-7\"; " +
"$fpml/FpML/trade/creditDefaultSwap/generalTerms/referenceInformation/referenceEntity[entityName=$name]' " +
"passing document as \"fpml\", " +
"cast (? as varchar(100)) as \"name\")"
);
...
// create the executable and execute it with the JDBC resolver and entityName variable
Source source = new Source(FpMLServlet.class.getResource("/joinCreditDefaultSwap.xq").toString());
XQueryExecutable joinCreditDefaultSwapsXQ = factory.prepareXQuery(source, staticContext);
...
JDBCCollectionResolver inputResolver = new JDBCCollectionResolver(getConnection(), dbStatements);
dynamicContext.setCollectionResolver(inputResolver);
StreamSource source = new StreamSource(FpMLServlet.class.getResourceAsStream("/assets.xml"));
dynamicContext.bind(new QName("http://com.ibm.xml.samples", "entityName"), name);
XSequenceCursor output = joinCreditDefaultSwapsXQ.execute(source, dynamicContext);
declare variable $my:entityName as xs:string external;
declare variable $databaseURI := concat('jdbc://getCreditDefaultSwapsByEntityName?cd%&', $my:entityName);
declare variable $creditDefaultSwaps := collection($databaseURI);
declare function local:equityRows($root) {
for $equity in $root//equity
let $referenceEntity := $creditDefaultSwaps//fpml:referenceEntity
where $equity/name = $referenceEntity/fpml:entityName
return
<tr xmlns="http://www.w3.org/1999/xhtml">
<td>{ $equity/*:symbol/text() }</td>
<td>{ $equity/*:name/text() }</td>
<td>{ $equity/*:high/text() }</td>
<td>{ $equity/*:currency/text() }</td>
</tr>
};
<table border="1">
<tr>
<th>Ticker Symbol</th>
<th>Company Name</th>
<th>High</th>
<th>Currency</th>
</tr>
{ local:equityRows(/) }
</table>
<a>this is simple</a>
<?xml version="1.0" encoding="UTF-8"?>
<assets>
<equity>
<symbol>AGU</symbol>
<name>Agrium Inc.</name>
<currency>USD</currency>
<high>64.06</high>
<low>62.79</low>
</equity>
<equity>
<symbol>STM-FP</symbol>
<name>STMicroelectronics N.V.</name>
<currency>EUR</currency>
<high>6.92</high>
<low>7.2</low>
</equity>
</assets>