Hello all,
I would like to design a "recursive" template.
My purpose is to have a template that can produce an xml like this:
<component xmlns="http://www.comune.ancona.it/schema/pagetemplate"
type="pagetemplate">
<pagetemplate>
<page>
<box name="level-1.1">
<box name="level-1.1.1">
<box name="level-1.1.1.1" component="/mypath/mycomponent" />
.....
<box name="level-1.1.1.2" component="/mypath/mycomponent" />
</box>
</box>
<box name="level-1.2">
<box name="level-1.2.1" component="/mypath/mycomponent" />
<box name="level-1.2.2" component="/mypath/mycomponent" />
</box>
.......
<box name="level-1.n">
<box>
...
</box>
</box>
</page>
</pagetemplate>
</component>
And so on...
I preparede the xsd, the layout.xml and the business-logic.xml but it
doesn't work.
Can anyone help me to understand why?
(My files are in attach to this mail)
--
By MCM.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2007 Municipality of Ancona (Italy)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<businesslogic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://repository.hippocms.org/schemas/cms-6.04/editor/businesslogic.xsd">
<!-- MCM: prefix definition for the internalization of the form -->
<i18n>
<field-prefix>cms.pagetemplate.fields</field-prefix>
<help-prefix>cms.pagetemplate.help</help-prefix>
</i18n>
<!-- MCM: Included Javascript libaries -->
<libs>
<!-- declare a code library
'src' is a html uri, in this case we use the default library
-->
<lib src="/editing/cf2/js/MCMutils.js"/>
</libs>
<pickers>
<!-- Define a picker to use with urlpreview widgets -->
<picker class="ResourcePopup2" id="components">
<arg><![CDATA['/explorer/resource-picker/content/structures/?mode=datasource']]></arg>
</picker>
</pickers>
<!-- the component type must be "pagetemplate" -->
<rule for="/component/@type">
<validation>
<validator name="regexp" pattern="^pagetemplate$"/>
</validation>
</rule>
<!-- define name as a required field -->
<rule for="/component/pagetemplate/page/box/@name">
<validation>
<validator name="required"/>
</validation>
</rule>
<!-- define the picker to use for navigation link selection -->
<rule for="/component/pagetemplate/page/box/@component">
<picker id="components" icon="/skins/images/icons/24x24/search.gif" class="resourcePicker"/>
<validation>
<validator name="regexp" pattern="^/content/structures/.*$"/>
</validation>
</rule>
<!-- define mane as a required field -->
<rule for="/box/@name">
<validation>
<validator name="required"/>
</validation>
</rule>
<!-- define the picker to use for navigation link selection -->
<rule for="/box/@component">
<picker id="components" icon="/skins/images/icons/24x24/search.gif" class="resourcePicker"/>
<validation>
<validator name="regexp" pattern="^/content/structures/.*$"/>
</validation>
</rule>
<!-- pick values for the selecttion box directly from the XSD -->
<type-rule type="myComponentType">
<i18n>
<list-prefix>cms.pagetemplate.componentType</list-prefix>
</i18n>
</type-rule>
</businesslogic>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008 Municipality of Ancona (Italy)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://repository.hippocms.org/schemas/cms-6.04/editor/layout.xsd"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1" xmlns:x="http://www.w3.org/1999/xhtml">
<!-- MCM: Layout Template for Standard Document -->
<template name="/">
<!-- Internals sections for messages -->
<x:div id="messages">
<messagewidget class="systemMessages"/>
<validationwidget class="validationMessages"/>
</x:div>
<!-- Selection box for component type -->
<x:div id="component-type">
<x:div class="label">
<i18n:text>[EMAIL PROTECTED]</i18n:text>
</x:div>
<x:div class="widget">
<dropdown id="/component/@type" />
</x:div>
</x:div>
<!-- MCM: Repeater group for PageBox Data -->
<x:div id="page">
<display id="/component/pagetemplate/page/box"/>
<macro-call id="repeater-pagebox">
<param name="path">/component/pagetemplate/page/box</param>
</macro-call>
</x:div>
<!-- Delete menu button -->
<x:div class="deletePageboxButton">
<action action="delete" ref="/component/pagetemplate/page/box"/>
</x:div>
</template>
<!-- MCM: Layout template to show the pagebox data group -->
<template name="/component/pagetemplate/page/box">
<!-- MCM: Language selection Box -->
<x:div class="box">
<!--Box Name -->
<x:div class="box-name">
<x:div class="label">
<i18n:text>[EMAIL PROTECTED]</i18n:text>
</x:div>
<x:div class="widget">
<textfield id="/component/pagetemplate/page/box/@name" class="box-nameWidget"/>
</x:div>
</x:div>
<!-- Box Component -->
<x:div class="box-component">
<x:div class="label">
<i18n:text>[EMAIL PROTECTED]</i18n:text>
</x:div>
<x:div class="widget">
<textfield id="/component/pagetemplate/page/box/@component" class="box-componentWidget"/>
</x:div>
</x:div>
<!-- MCM: Repeater group for PageBox Data -->
<x:div id="box">
<reference id="/box"/>
<macro-call id="repeater-box">
<param name="path">box</param>
</macro-call>
</x:div>
<!-- Delete menu button -->
<x:div class="deletePageboxButton">
<action action="delete" ref="/box"/>
</x:div>
</x:div>
</template>
<!-- MCM: Layout template to show the pagebox data group -->
<template name="/box">
<!-- MCM: Language selection Box -->
<x:div class="box">
<!--Box Name -->
<x:div class="box-name">
<x:div class="label">
<i18n:text>[EMAIL PROTECTED]</i18n:text>
</x:div>
<x:div class="widget">
<textfield id="/box/@name" class="box-nameWidget"/>
</x:div>
</x:div>
<!-- Box Component -->
<x:div class="box-component">
<x:div class="label">
<i18n:text>[EMAIL PROTECTED]</i18n:text>
</x:div>
<x:div class="widget">
<textfield id="/box/@component" class="box-componentWidget"/>
</x:div>
</x:div>
<!-- MCM: Repeater group for PageBox Data -->
<x:div id="box">
<reference id="/box"/>
<macro-call id="repeater-box">
<param name="path">/box</param>
</macro-call>
</x:div>
<!-- Delete menu button -->
<x:div class="deleteBoxButton">
<action action="delete" ref="/box"/>
</x:div>
</x:div>
</template>
<!-- MCM: repeater for the box data group -->
<macro name="repeater-pagebox">
<!-- button to add primary -->
<x:div class="addPageBoxButton">
<action action="add" ref="${path}"/>
</x:div>
</macro>
<macro name="repeater-box">
<!-- button to add primary -->
<x:div class="addBoxButton">
<action action="add" ref="${path}"/>
</x:div>
</macro>
</layout>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2007 Municipality of Ancona (Italy)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.comune.ancona.it/schema/pagetemplate" xmlns="http://www.comune.ancona.it/schema/pagetemplate">
<xs:element name="component">
<xs:complexType>
<xs:sequence>
<xs:element name="pagetemplate">
<xs:complexType>
<xs:sequence>
<xs:element name="page" type="recursiveChild" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="myComponentType" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="box" type="recursiveChild"/>
<xs:complexType name="recursiveChild">
<xs:sequence>
<xs:element ref="box" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="component" type="xs:string"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
<!-- Define Component Type -->
<xs:simpleType name="myComponentType">
<xs:restriction base="xs:string">
<xs:enumeration id="pagetemplate" value="pagetemplate"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
********************************************
Hippocms-dev: Hippo CMS development public mailinglist