[opencms-dev] XSD contents : minOccurs maxOccurs problems
Territorio Jordan-V.
jordan.territorio at gmail.com
Tue May 6 11:17:04 CEST 2008
I must do something wrong...
org.opencms.xml.CmsXmlException: Unmarshalling XML document failed.
at org.opencms.xml.CmsXmlUtils.unmarshalHelper(CmsXmlUtils.java:654)
at org.opencms.xml.CmsXmlUtils.unmarshalHelper(CmsXmlUtils.java:617)
here is the new code for the list :
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
<!-- I think the problem is there... -->
<xsd:include schemaLocation="./antargaz_news.xsd" />
<xsd:element name="MyNewsLists" type="OpenCmsMyNewsLists" />
<xsd:complexType name="OpenCmsMyNewsLists">
<xsd:sequence>
<xsd:element name="MyNewsList" type="OpenCmsMyNewsList"
minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="OpenCmsMyNewsList">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="News" type="OpenCmsNew"
minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="language" type="OpenCmsLocale"
use="required" />
</xsd:complexType>
</xsd:schema>
2008/5/6 Bozidar Ilievski <bozidar.ilievski at netcetera.com.mk>:
> Hi.
>
> Territorio Jordan-V. wrote:
> > Hi,
> >
> > I try to make a schemas for editing some blocks of informations, with: a
> > title, a text and an image. So i created a xsd schemas to be able to
> > create structured as I want. Here is my info_article.xsd :
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > elementFormDefault="qualified">
> >
> > <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
> >
> > <xsd:element name="MyNews" type="OpenCmsMyNews" />
> >
> > <xsd:complexType name="OpenCmsMyNews">
> > <xsd:sequence>
> > <xsd:element name="MyNew" type="OpenCmsMyNew"
> > minOccurs="0" maxOccurs="unbounded" />
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <xsd:complexType name="OpenCmsMyNew">
> > <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> > <xsd:element name="Title" type="OpenCmsString" />
> > <xsd:element name="Image" type="OpenCmsVfsFile"
> > minOccurs="0" maxOccurs="1" />
> > <xsd:element name="Text" type="OpenCmsHtml"/>
> > <xsd:element name="Image" type="OpenCmsVfsFile"
> > minOccurs="0" maxOccurs="1" />
> > </xsd:sequence>
> > <xsd:attribute name="language" type="OpenCmsLocale"
> > use="required" />
> > </xsd:complexType>
> >
> > <xsd:annotation>
> > <xsd:appinfo>
> > <mappings>
> > <mapping element="Title" mapto="property:Title" />
> > </mappings>
> > <layouts>
> > <layout element="Image" widget="ImageGalleryWidget" />
> > </layouts>
> > </xsd:appinfo>
> > </xsd:annotation>
> > </xsd:schema>
> >
> > The problem is when I edit news pages, the Editor just show one block
> > "OpenCmsMyNew" and I can't build an other... If I modify the code in
> > this way :
> > <xsd:element name="Text" type="OpenCmsHtml" minOccurs="0"
> > maxOccurs="unbounded"/>
> > I'm able to create as many paragraph as i want, but i cant do the same
> > thing with the "MyNew" block...
> >
> > Is there somebody to help ?
>
> You can have one OpenCmsMyNew for every language you define in the
> system. That is how XSD resource types work in OpenCms.
>
> If you want to have 0..unbound OpenCmsMyNew for one language, you need
> to define new resource type, and in it you reference this one.
> Example:
>
> ...
> <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
> <!-- INCLUDE your OpenCmsMyNew XSD file here -->
>
> <xsd:element name="MyNewsLists" type="OpenCmsMyNewsLists" />
>
> <xsd:complexType name="OpenCmsMyNewsLists">
> <xsd:sequence>
> <xsd:element name="MyNewsList" type="OpenCmsMyNewsList"
> minOccurs="0" maxOccurs="unbounded" />
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="OpenCmsMyNewsList">
> <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> <xsd:element name="News" type="OpenCmsMyNew" minOccurs="0"
> maxOccurs="1" />
> </xsd:sequence>
> <xsd:attribute name="language" type="OpenCmsLocale"
> use="required" />
> </xsd:complexType>
> ...
>
> > Anyway, someone could tell me why this is forbidden :
> > <xsd:complexType name="OpenCmsMyNews">
> > <xsd:sequence>
> > <xsd:element name="Title" type="OpenCmsString" /> <!-- a
> > main title and an introduction before displaying news -->
> > <xsd:element name="Text" type="OpenCmsHtml"/>
> > <xsd:element name="MyNew" type="OpenCmsMyNew"
> > minOccurs="0" maxOccurs="unbounded" />
> > </xsd:sequence>
> > </xsd:complexType>
> >
> > <xsd:complexType name="OpenCmsMyNew">
> > <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> > <xsd:element name="Title" type="OpenCmsString" />
> > <xsd:element name="Image" type="OpenCmsVfsFile"
> > minOccurs="0" maxOccurs="1" />
> > <xsd:element name="Text" type="OpenCmsHtml"/>
> > <xsd:element name="Image" type="OpenCmsVfsFile"
> > minOccurs="0" maxOccurs="1" />
> > </xsd:sequence>
> > <xsd:attribute name="language" type="OpenCmsLocale"
> > use="required" />
> > </xsd:complexType>
> >
> > thank you all
> >
> Yes, that is forbidden.
> You first define complex type that ends with 's'.
> This type consists of 0..unbound elements that are of type with the same
> name, without the last 's'.
> This second type can have sequence of other elements, and it must have
> language attribute.
>
> Regards,
> Bobi.
>
> --
> Bozidar Ilievski | bozidar.ilievski at netcetera.com.mk
> phone +389 -2- 30 64 532 | fax +389 -2- 30 79 495
> Netcetera | 1000 Skopje | Macedonia | http://netcetera.com.mk
>
> _______________________________________________
> 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
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
--
TERRITORIO Jordan-Victor
Ingénieur d'Intégration Java
TEAMLOG – Ingenieurs 2000
+33 6 30 66 54 69
jot at teamlog.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080506/59586e4c/attachment.htm>
More information about the opencms-dev
mailing list