AW: [opencms-dev] Nested Structured Content and Locale

Nick Panienski panienski at codecentric.de
Wed May 2 09:39:27 CEST 2007


Hi Eric, you have to declare the third complex type in another schema. Include this schema in your original one and you can use your definiting for your third complex type.
 
Example:

test.xsd:
 
<?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:include schemaLocation="opencms://system/modules/de.company.module/schemas/testElements.xsd" />
	
	<xsd:element name="ABCTests" type="OpenCmsABCTests"/>
	
	<xsd:complexType name="OpenCmsABCTests">
		<xsd:sequence>
			<xsd:element name="ABCTest" type="OpenCmsABCTest" minOccurs="0" maxOccurs="unbounded"/>
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="OpenCmsABCTest">
		<xsd:sequence>
			<xsd:element name="test" type="OpenCmsTest" minOccurs="0" maxOccurs="unbounded" />			
		</xsd:sequence>
		<xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
	</xsd:complexType>
	
</xsd:schema>

testElement.xsd:

<?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="Tests" type="OpenCmsTests"/>
	
	<xsd:complexType name="OpenCmsTests">
		<xsd:sequence>
			<xsd:element name="test" type="OpenCmsTest" minOccurs="0" maxOccurs="unbounded"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="OpenCmsTest">
		<xsd:sequence>
			<xsd:element name="text" type="OpenCmsString" minOccurs="0" maxOccurs="1" />		
			<xsd:element name="link" type="OpenCmsString" minOccurs="0" maxOccurs="3" />
		</xsd:sequence>
		<xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
	</xsd:complexType>
 
	<xsd:annotation>
		<xsd:appinfo>
			<layouts>
				<layout element="link" widget="VfsFileWidget" />
			</layouts>	
		</xsd:appinfo>
	</xsd:annotation>  	

</xsd:schema>

HTH

--
Mit freundlichen Grüßen
Nick Panienski
Consultant

codecentric GmbH
Grünewalder Str. 29-31
42657 Solingen

Telefon  +49 (212)  24 94 330
Fax      +49 (212)  24 94 334
Mobil    +49 (151) 167 06 496
eMail    panienski at codecentric.de
Internet http://www.codecentric.de <http://www.codecentric.de/> 

Geschäftsführer: Peter Gierse, Mirko Novakovic und Rainer Vehns
Sitz der Gesellschaft: Solingen
Registergericht: Amtsgericht Wuppertal, HRB 19214



 


________________________________

	Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von bessette
	Gesendet: Dienstag, 1. Mai 2007 21:10
	An: opencms-dev at opencms.org
	Betreff: Re: [opencms-dev] Nested Structured Content and Locale
	
	

	How did you get nested content in a schema? Whenever I try, I get the following error:

	Exactly 2 complex type definitions are required, not 3.

	Here's my test schema:

	<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
		elementFormDefault="qualified">
	
		<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd" />
	
		<xsd:element name="contents" type="OpenCmsContents" />
	
		<xsd:complexType name="OpenCmsNestedcontents">
			<xsd:sequence>
				<xsd:element name="content" type="OpenCmsContent"
					minOccurs="0" maxOccurs="unbounded" />
			</xsd:sequence>
		</xsd:complexType>
	
		<xsd:complexType name="OpenCmsContent">
			<xsd:sequence>
				<xsd:element name="nestedcontent" type="OpenCmsNestedcontent" maxOccurs="5"/>
			</xsd:sequence>
			<xsd:attribute name="language" type="OpenCmsLocale"
				use="required" />
		</xsd:complexType>
	
		<xsd:complexType name="OpenCmsNestedcontent">
			<xsd:sequence>
				<xsd:element name="Key" type="OpenCmsString" />
				<xsd:element name="Value" type="OpenCmsString" />
			</xsd:sequence>
		</xsd:complexType>
	
	</xsd:schema>
	

	Thanks,
	Eric


________________________________

	View this message in context: Re: Nested Structured Content and Locale <http://www.nabble.com/Nested-Structured-Content-and-Locale-tf3644477.html#a10274285> 
	Sent from the OpenCMS - Dev mailing list archive <http://www.nabble.com/OpenCMS---Dev-f654.html>  at Nabble.com.
	




More information about the opencms-dev mailing list