[opencms-dev] Two elements on schema to mapping

Juan Antonio Ruiz jaruiz at sopde.es
Thu Jun 16 12:19:36 CEST 2011

 Hi Michael,

 Ok, thank you for everything. I will try it.

-----Mensaje original-----
De: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org]
En nombre de Michael Emmerich
Enviado el: jueves, 16 de junio de 2011 12:10
Para: The OpenCms mailing list
Asunto: Re: [opencms-dev] Two elements on schema to mapping


> Can I map two element of schema on a property?
> I have this schema:
> <xsd:sequence>
> <xsd:elementname=/"Name"/ type=/"OpenCmsString"/ />
> <xsd:elementname=/"Surname"/ type=/"OpenCmsString"/ />
> I would like to do something like this,
> <mappings>
> <mappingelement=/"*Name,Surname*"/ mapto=/"property:fullname"/ />
> How I can it?
> Thanks.

Its not possible to do that in the XSD.

You could implement your own CmsXmlContentHandler by implementing the 
I_CmsXmlContentHandler. There, you can perform an operation on XML 
content creation or save operation:

You can do that by writing your own XML content handler that performs 
actions in the prepareForWrite() method.
This method is triggered every time an xml content is saved, so you have 
to avoid the database update when the temporary file is written 
automatically by the OpenCms xml content editor.

Here is a short example how to implement such a content handler:

public class CmsActionXmlContentHandler extends 
CmsDefaultXmlContentHandler {
     public CmsFile prepareForWrite(CmsObject cms, CmsXmlContent 
content, CmsFile file)
         throws CmsException {

         // first call super implementation
         super.prepareForWrite(cms, content, file);

         if (file.getName().indexOf(CmsWorkplace.TEMP_FILE_PREFIX) != 0) {
             String folderPath = cms.getRequestContext().removeSiteRoot(

             if (cms.existsResource(folderPath + 
                         file.getName(), CmsResourceFilter.ALL)) {

                 // do your stuff here
     return file;

In the XSD of your XML content, you have to add the following node to 
the appinfo section:

         <handler class="my.package.CmsActionXmlContentHandler"/>

As you can see, you have access to the CmsObject, the XmlContent and the 
Resource in the OpenCms VFS.

Kind regards,


Alkacon Software GmbH - The OpenCms Experts
Michael Emmerich
An der Wachsfabrik 13
50996 Koeln, DE

Tel: +49 (0)2236 3826-14
Fax: +49 (0)2236 3826-20
Email: m.emmerich at alkacon.com


Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 54613

This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit

More information about the opencms-dev mailing list