[opencms-dev] XSD contents : minOccurs maxOccurs problems

Territorio Jordan-V. jordan.territorio at gmail.com
Tue May 6 14:17:00 CEST 2008


So I confirm... it's set correctly... but always have the error...

*antargaz_news.xsd*
<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
    <xsd:element name="AntargazNews" type="OpenCmsAntargazNews" />
    <xsd:complexType name="OpenCmsAntargazNews">
        <xsd:sequence>
            <xsd:element name="AntargazNew" type="OpenCmsAntargazNew"
                minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="OpenCmsAntargazNew">
        <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" minOccurs="0"
maxOccurs="unbounded"/>
            <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>

*antargaz_newslist.xsd*
    <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
    <!-- INCLUDE your OpenCmsMyNew XSD file here -->
    <xsd:include

schemaLocation="opencms://system/modules/org.antargaz.modules.first/schemas/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="AntargazNew" type="OpenCmsAntargazNew"
                minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
        <xsd:attribute name="language" type="OpenCmsLocale"
            use="required" />
    </xsd:complexType>

2008/5/6 Bozidar Ilievski <bozidar.ilievski at netcetera.com.mk>:

>
>
> Territorio Jordan-V. wrote:
> > I changed it but this appears :
> > XML validation error :
> > <errors>
> > <error column="11" line="5">cvc-complex-type.4: Attribute 'language'
> > must appear on element 'News'.</error>
> > </errors>
>
> You need the language attribute in all your xsd files.
> It should be set for the type that does not finish with 's'.
>
> This is how the xsd should look like:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
>   <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
>
>    <xsd:element name="XXXs" type="OpenCmsXXXs"/>
>
>   <xsd:complexType name="OpenCmsXXXs">
>     <xsd:sequence>
>       <xsd:element name="XXX" type="OpenCmsXXXs" minOccurs="0"
> maxOccurs="unbounded"/>
>     </xsd:sequence>
>   </xsd:complexType>
>
>    <xsd:complexType name="XXX">
>     <xsd:sequence>
>       <xsd:element name="name_1" type="type_1" minOccurs.... />
>       ...
>       <xsd:element name="name_n" type="type_n" minOccurs.... />
>     </xsd:sequence>
>     <!-- THIS IS WHERE THE LANGUAGE ATTRIBUTE SHOULD BE SET -->
>      <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
>   </xsd:complexType>
>
>    <!-- This part is not required. -->
>   <xsd:annotation>
>     ...
>   </xsd:annotation>
>
> </xsd:schema>
>
> Here XXX is the name of the resource type you define.
>
> If you still have problems, post your xsd files.
>
> > But I think there already this attribute set, doesn't it?
> > ... :s i know i'm noob but opencms is going to make me crazy ^^
> >
> > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >     elementFormDefault="qualified">
> >
> >     <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
> >     <!-- INCLUDE your OpenCmsMyNew XSD file here -->
> >     <xsd:include
> >
> schemaLocation="opencms://system/modules/org.antargaz.modules.first/schemas/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="OpenCmsMyNew"
> >                 minOccurs="0" maxOccurs="unbounded" />
> >         </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
> > <mailto:bozidar.ilievski at netcetera.com.mk>>:
> >
> >
> >     Territorio Jordan-V. wrote:
> >      > It's loaded, it was the path to the MyNew.xsd.
> >      >
> >      > But i have always the same problem than in the first file. I
> >     can't add a
> >      > new "MyNew" block... I can have multiples Text block in the MyNew
> >     block
> >      > but no multiples block MyNew in the MyList.xsd...
> >      >
> >      > In fact i have exactly the same result than the beginning :s
> >      >
> >      > 2008/5/6 Bozidar Ilievski <bozidar.ilievski at netcetera.com.mk
> >     <mailto:bozidar.ilievski at netcetera.com.mk>
> >      > <mailto:bozidar.ilievski at netcetera.com.mk
> >     <mailto:bozidar.ilievski at netcetera.com.mk>>>:
> >      >
> >      >     Hi.
> >      >
> >      >     Territorio Jordan-V. wrote:
> >      >      > 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" />
> >      >
> >      >     I usually enter the absolute location of the referenced
> >     schema file:
> >      >     Example:
> >      >     <xsd:include
> >     schemaLocation="opencms://system/.../my_schema.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"
> >      >
> >      >     or maybe this is your problem.
> >      >     In the previous post, your type was OpenCmsMyNew, not
> OpenCmsNew.
> >      >
> >      >      >                 minOccurs="0" maxOccurs="1" />
> >
> >     This is the reason why you can't add multiple MyNew blocks.
> >
> >     Set maxOccurs="unbounded", and it will work.
> >
> >      >      >         </xsd:sequence>
> >      >      >         <xsd:attribute name="language"
> type="OpenCmsLocale"
> >      >      >             use="required" />
> >      >      >     </xsd:complexType>
> >      >      > </xsd:schema>
> >      >      >
> >
>
> --
> 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/a9ad2ebb/attachment.htm>


More information about the opencms-dev mailing list