4

My current implementation generates XML using JSPs, but the number of different record types I'm working with has grown and the number of JSP templates has become unwieldy to maintain.

So I coded up a solution using javax.xml.bind but quickly found that the code would compile but not run in OSGi. Long story short, there is a natively compiled dependency -- com.sun.* -- that is not included in the Felix boot classpath by default. Including this dependency is a matter of modifying sling.properties to include com.sun.* in the org.osgi.framework.bootdelegation config line. However, I'm working in a large corporate production environment so the thought of managing an extra configuration piece is not ideal.

So, the meat of my question: is there a better way to generate custom XML programmatically in Adobe CQ? Is there a different JAXB impl in the stack that I should be using, instead of javax.xml.bind? Is there another XML marshalling API that is more CQ/Felix friendly?

jason
  • 83
  • 7
  • Here is an example of using EclipseLink JAXB (MOXy) in an OSGi Environment: http://stackoverflow.com/questions/12942750/moxy-error-with-karaf/12943115#12943115 – bdoughan Jan 31 '13 at 18:46
  • Thanks for the info, Blaise. I'm particularly looking for an ready-to-use solution that is already in the Adobe CQ/Felix stack. I already have a solution that requires an extra configuration management piece, looking to simplify my life :) – jason Jan 31 '13 at 19:56
  • There are ways around the boot delegation issue using config in the Maven build - I know, I've done it. Which version of CQ are you using? – antonyh Mar 04 '13 at 22:32

3 Answers3

2

I've not got any concrete documentation on this yet, but it's possible to include com.sun.* without changing the Sling boot delegation.

I've done it in this pom.xml for a demo project using CXF in CQ5 as an OSGi service. It's either the <dependency> or the <Import-Package> in the maven-bundle-plugin.

The whole project is available on GitHub at https://github.com/antonyh/cq5-cxf - it builds, installs, and works without changes to boot delegation on CQ5.4 / CQ5.5.

antonyh
  • 2,131
  • 2
  • 21
  • 42
1

CQ5.5 osgi bundles include org.apache.cocoon.cocoon-xml which exports packages:

org.apache.cocoon.xml.dom,version=2.0.0
org.apache.cocoon.xml.sax,version=2.0.0

Which are available for use in other osgi bundles or component jsp files.

kfaerber
  • 1,327
  • 8
  • 10
0

For "vanilla" XML you can simply add a .xml extension to your content URL and an XML representation of the content will be output. This can be fetched by HTTP.

diffa
  • 2,986
  • 1
  • 22
  • 35
  • I don't want "vanilla" xml. I know that CQ has handlers to export both xml and json (with no control over the schema) by swapping out the extension on your resource from ".html" to ".xml" or ".json". What I want is to be able to generate, programmatically, XML that matches a custom schema using software that is available in Java context within CQ or Felix. Thanks. – jason Feb 01 '13 at 13:01
  • Fair enough. Although not in the java context, another option would be to transform using XSLT using [Sling output rewriting](http://sling.apache.org/site/output-rewriting-pipelines-orgapacheslingrewriter.html). – diffa Feb 01 '13 at 14:42