[opencms-dev] Java class to translate XML code contained in the VFS in HTML page source code

Olli Aro olli_aro at yahoo.co.uk
Tue Nov 4 10:24:02 CET 2003


How about calling the page via HttpURLConnection? I know it goes through the
web server that way, not directly from OpenCms API, but local web call
should not be too expensive... Other option would be to call directly
com.opencms.launcher.CmlXmlLauncher class - this is the class that parses
the templates and content together.

Regards,

Olli


> -----Original Message-----
> From: opencms-dev-admin at opencms.org
> [mailto:opencms-dev-admin at opencms.org]On Behalf Of Kwok Peng Tuck
> Sent: 04 November 2003 08:43
> To: opencms-dev at opencms.org
> Subject: Re: [opencms-dev] Java class to translate XML code contained in
> the VFS in HTML page source code
>
>
> 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
> >
> >
> >
> >
> >
>
> _______________________________________________
> 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
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 27/10/2003




More information about the opencms-dev mailing list