[opencms-dev] open questions about XML content

Alexander Kandzior alex at opencms.org
Thu Nov 11 17:38:09 CET 2004



> 1) From the example posted on the mailing list, XML content 
> uses the template-element property to determine its display 
> page. However, if I have multiple types of content in a 
> single directory, how can I direct one type to display with 
> one page and another to display with a different page? Is the 
> use of template-elements hard coded? 
> 
> * Currently you can't mix differnet XML content types in one 
> directory and attach the "template-elements" to the folder. 
> If you want to have multiple XM Lcontent types in one folder, 
> you must attach "template-elements" to each file manually.
> 
> Q: Is there any way to programmatically change the 
> template-elements property before the file is processed 
> (without getting into changing the source code)? 

Not without changing the source code.

> I'm 
> wondering if there would be a way to insert code at the top 
> of a template, for example, that would determine the 
> template-elements setting before the template is processed.

That may be possible doing in scriptlet code. Chech the "templateone"
template source code, it usually ready various properties when it loads.

> 2) Create a content schema, create several items based on the 
> schema, then add more fields to the schema. New items of that 
> type will have the new fields. Editing older items will not 
> show the new fields. Is there any way to automatically bring 
> older items up-to-date with a modified schema? 
> 
> * No. Currently not.
> 
> Q: Is there a programmatic way to add information to an 
> existing XML content resource? 

That's certainly possible using the XmlContent API. It's certainly not an
easy task, and it would probably involve a couple of core additions. Check
out the source code of the XML content editor in
org.opencms.workplace.editors.CmsXmlContentEditor, it may provide a start.

However, it's certainly not the intention of the XML content to have schema
changes many times. Think of the XML content schema as of database schemas:
Once you got them right on you development machine, they should be deployed
to production and not change often.

> For example, using CmsObject 
> or some other back-end object, could I access the resource 
> and add empty values for the new fields such that those 
> fields then appear in the Workplace form when the resource is edited?
> If so then I could write a workaround to auto-update 
> resources on schema updates.

Check out org.opencms.xml.content.CmsXmlContentFactory. This enables you to
get an instance of an XML content to manupulate. Also check out
org.opencms.xml.CmsXmlEntityResolver, it caches the schema files.

Best Regards,
Alex.

Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com







More information about the opencms-dev mailing list