[opencms-dev] Use openCms to generate xml page, not html.
Alexander Kandzior
alex at opencms.org
Wed Feb 9 17:12:56 CET 2005
> My idea was to get this xml content as it is and return it in
> the jsp. But i wouldn't recreate explicitly all the XML
> markup regarding again the xml schema, all the more so since
> that the parsed xml content is already well formed.
Here's a simple trick how to achive this. I'll show how to do this with the
content of the "templateone" XML content demo.
First, in the /xmlcontent/ folder, create a file "xmldump.jsp" with the
following content:
-------------------
<%@page import="org.opencms.jsp.*, org.opencms.file.*" %><%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);
String uri = cms.getRequestContext().getUri();
CmsFile file = cms.getCmsObject().readFile(uri);
// note that this dosen't handle charsets
byte[] content = file.getContents();
String result = new String(content);
out.println(result);
%>
--------------------
Now go to any article file in the folder and open the property editor. In
the advanced property view, locate the "template-elements" property. Change
this to point to the newly created file e.g. "/xmlcontent/xmldump.jsp".
Now the XML should be dumped directly.
In order to not do this for all files individually, just do it on the folder
where the XML content files are located.
Best Regards,
Alex.
Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com
More information about the opencms-dev
mailing list