[opencms-dev] xsd: defintion of attributes

schuchhardt at inverso.de schuchhardt at inverso.de
Fri May 5 16:30:52 CEST 2006


Hi everybody,

I´m trying to realize the following xml-file to be editable in OpenCms 
with
structured content. Till now I worked with the examples in the 
documentation and everything was ok.
I searched the mailing list but I found nothing similar. 
Besides I´ve  got the opinion that it is only possible to implement 
nothing execpt the given examples .
The complex types for example seem not to be allowed to have more than the 
language attribute.
When I try to define some further attributes to complex types of the xsd, 
I alwyas get errors.

Has anybody succesfully written schema definitions for a xml file like 
that?

        <?xml version="1.0" encoding="ISO-8859-1"?>
        <Productinhalt Version="2.1.0" Name="Konfiguration">
                <Product Key="02001"  Name="" ProductServer="" 
ProductPort="52224" ProductPath="">
                </Product>
                <Product Key="23001" Name="" ProductServer="" 
ProductPort="52224" ProductPath="">
                </Product>
        </Productinhalt>


My last working schema looked like this, but it is only possible with 
diffentent elements, not with several attributes.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified">
<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
        <xsd:element name="Productinhalts" type="OpenCmsProductinhalts" />
 
        <xsd:complexType name="OpenCmsProductinhalts">
                <xsd:sequence>
                        <xsd:element name="Productinhalt" 
type="OpenCmsProductinhalt" minOccurs="0" maxOccurs="unbounded"/>
                </xsd:sequence>
        </xsd:complexType>

        <xsd:complexType name="OpenCmsProductinhalt">
                <xsd:sequence>
                        <xsd:element name="Key" type="OpenCmsString" />
                        <xsd:element name="Name" type="OpenCmsString" />
                        <xsd:element name="ProductServer" 
type="OpenCmsString" />
                        <xsd:element name="ProductPort" 
type="OpenCmsString" />
                        <xsd:element name="ProductPath" 
type="OpenCmsString" />
                </xsd:sequence>
                <xsd:attribute name="language" type="OpenCmsLocale" 
use="required" />
        </xsd:complexType> 
 
        <xsd:annotation>
                <xsd:appinfo> 
                        <resourcebundle 
name="de.inverso.vkb.vp.workplace"/>
                        <mappings/>
                        <defaults/>
                        <layouts/>
                </xsd:appinfo>
        </xsd:annotation> 
 </xsd:schema>


Result xml file:

<?xml version="1.0" encoding="UTF-8"?>
<Productinhalts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="opencms://system/modules/de.inverso.vkb.vp/schemas/vp_content.xsd">
  <Productinhalt language="en">
    <Product>
      <Key><![CDATA[02001]]></Key>
      <Name/>
      <ProductServer/>
      <ProductPort><![CDATA[52224]]></ProductPort>
      <ProductPath/>
    </Product>
    <Product>
      <Key><![CDATA[23001]]></Key>
      <Name/>
      <ProductServer/>
      <ProductPort><![CDATA[52224]]></ProductPort>
      <ProductPath/>
    </Product>
  </Productinhalt>
</Productinhalts>


Thanks for your help!

Best regards,

Nadine Schuchhardt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060505/899b8baa/attachment.htm>


More information about the opencms-dev mailing list