[opencms-dev] Java class to translate XML code contained in the VFS in HTML page source code
Kwok Peng Tuck
pengtuck at makmal.net
Tue Nov 4 10:14:00 CET 2003
Hmm, maybe you can transform it to html by writing your own xslt ?
Just a suggestion.
Massimiliano wrote:
>As I post yesterday I'm writing a java class to retrieve HTML pages
>from the VFS.
>The result obtained yesterday is this XML template that contains the
>text I wrote in the page:
>
><?xml version="1.0" encoding="ISO-8859-1"?>
><XMLTEMPLATE>
> <TEMPLATE><![CDATA[<p><strong>Questa è la homepage del Mio Primo
>progetto OpenCMS!</strong></p>]]></TEMPLATE>
> <edittemplate><![CDATA[<P><STRONG>Questa è la homepage del Mio Primo
>progetto
>OpenCMS!</STRONG></P>]]></edittemplate>
></XMLTEMPLATE>
>
>The XML contains the text I wrote in the page, but what I need is the
>complete html code like the code generated by opencms when I call the
>page from the web browser.
>How can I translate the XML code to obtain the complete HTML code using
>the openCMS Java API?
>
>Thank you again.
>
>Massimiliano.
>
>------
>This is my java source code:
>
>OpenCms m_openCms;
>CmsObject m_cms;
>
>try {
> CmsBase.setBasePath("c:\\Program Files\\Apache Group\\Tomcat
>4.1\\webapps\\opencms\\WEB-INF");
> String propsPath = CmsBase.getPropertiesPath(true);
> System.out.println("%%% props: " + propsPath);
> Configurations conf = new Configurations(new
>ExtendedProperties(propsPath));
> m_openCms = new OpenCms(conf);
> m_cms = new CmsObject();
>
> //log in default user.
> m_openCms.initUser(m_cms, null, null, CmsXmlTemplate.C_USER_GUEST,
>CmsXmlTemplate.C_GROUP_GUEST, CmsXmlTemplate.C_PROJECT_ONLINE_ID, null);
>
> CmsFile file = m_cms.readFile(CmsWorkplaceDefault.C_VFS_PATH_BODIES +
>"MyFirstProject/Index.html");
> if ( file != null )
> {
> System.out.println(file);
>
> byte [] fileContent = file.getContents();
>
> ByteArrayOutputStream bA = new ByteArrayOutputStream();
> bA.write(fileContent);
> System.out.println (bA.toString());
> }
> else
> throw new NullPointerException ("Oggetto file nullo");
> }
> catch(Exception exc) {
> exc.printStackTrace();
> }
>
>_______________________________________________
>This mail is send to you from the opencms-dev mailing list
>To change your list options, or to unsubscribe from the list, please visit
>http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
>
>
>
More information about the opencms-dev
mailing list