[opencms-dev] Mapping nested elements to a propertyList
Florian Hopf
hopf at synyx.de
Fri Jul 16 14:20:20 CEST 2010
Hi,
I am trying to map String values from nested elements to a propertyList.
This is what I am using:
<mapping element="Outer/Inner1/StringValue"
mapto="propertyList:myProperty"/>
where Outer and Inner1 are complex nested elements and StringValue is an
element of type OpenCmsString.
In XPath syntax I am looking for these elements: //Outer/Inner1/StringValue
Only the first StringValue in the document is mapped this way. I Guess
this is caused by getValue(...) in A_CmsXmlDocument where the XPath is
constructed like this: /Outer[1]/Inner1[1]/StringValue
It seems that mapping propertyLists is only possible for sequences in
the same level.
Another workaround I tried: Adding several mappings for the different
levels:
<mapping element="Outer[1]/Inner1[1]/StringValue"
mapto="propertyList:myProperty"/>
<mapping element="Outer[2]/Inner1[1]/StringValue"
mapto="propertyList:myProperty"/>
But then the last mapping overwrites the mappings applied before. This
would also be really ugly because I would have to know how many elements
there are.
Does anybody know if there is another workaround? I could of course
write a custom XmlContentHandler that checks for the exact values I
expect but I would prefer a generic way.
Regards
Florian
More information about the opencms-dev
mailing list