[opencms-dev] recursive element in schema
Seckin Pulatkan
seckin.pulatkan at sqills.com
Tue Jun 24 15:57:35 CEST 2008
Hi,
I am trying to create a schema for a type which may have itself as a
child element (recursive).
This is an xsd that can be used on OpenCMS that I can create element
with this xsd on workplace.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:include
schemaLocation="opencms://opencms-xmlcontent.xsd"/>
<xsd:element name="Chapters" type="OpenCmsChapters"/>
<xsd:complexType name="OpenCmsChapters">
<xsd:sequence>
<xsd:element name="Chapter"
type="OpenCmsChapter" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OpenCmsChapter">
<xsd:sequence>
<xsd:element name="Title"
type="OpenCmsString" />
<xsd:element name="Text"
type="OpenCmsHtml" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="language"
type="OpenCmsLocale" use="optional"/>
</xsd:complexType>
<xsd:annotation>
<xsd:appinfo>
<resourcebundle
name="org.test.frontend.template.workplace"/>
<mappings>
<mapping element="Title"
mapto="property:Title" />
</mappings>
<layouts>
<layout element="Text"
widget="HtmlWidget" configuration="height:100px" />
</layouts>
</xsd:appinfo>
</xsd:annotation>
</xsd:schema>
A chapter may have sub-chapters of OpenCmsChapter type as in above
schema. So I add reference to the element Chapters
<xsd:complexType name="OpenCmsChapter">
<xsd:sequence>
<xsd:element name="Title"
type="OpenCmsString"/>
<xsd:element name="Text"
type="OpenCmsHtml" minOccurs="0"/>
<xsd:element ref="Chapters"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="language"
type="OpenCmsLocale" use="optional"/>
</xsd:complexType>
or
<xsd:complexType name="OpenCmsChapter">
<xsd:sequence>
<xsd:element name="Title"
type="OpenCmsString"/>
<xsd:element name="Text"
type="OpenCmsHtml" minOccurs="0"/>
<xsd:element name="SubChapters"
type="OpenCmsChapter" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="language"
type="OpenCmsLocale" use="optional"/>
</xsd:complexType>
Or
<xsd:element name="SubChapter" type="OpenCmsChapter"/>
<xsd:complexType name="OpenCmsChapter">
<xsd:sequence>
<xsd:element name="Title"
type="OpenCmsString"/>
<xsd:element name="Text"
type="OpenCmsHtml" minOccurs="0"/>
<xsd:element ref="SubChapter"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="language"
type="OpenCmsLocale" use="optional"/>
</xsd:complexType>
But all changes get error from the workplace while creating a file with
this type.
First change: Invalid OpenCms content definition XML schema structure.
Second change: Invalid OpenCms content definition XML schema structure:
Schema type "OpenCmsChapter" unknown.
Third change: Invalid OpenCms content definition XML schema structure:
Exactly 1 root element is required, not
"opencms://opencms-xmlcontent.xsd".
Can you help me to figure out the problem?
Thanks,
Seckin
Ps: Is there an official forum for OpenCms so I can check previous
questions before sending it again?
S. Pulatkan
Senior Application Developer
Sqills
@ - revolutions
T +31 (0)88 774 55 70
M +31 (0)6 45 10 80 30
E seckin.pulatkan at sqills.com <mailto:seckin.pulatkan at sqills.com>
A Hengelosestraat 52
7514 AJ Enschede (NL)
I www.sqills.com <http://www.sqills.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080624/37f53dd0/attachment.htm>
More information about the opencms-dev
mailing list