[oXygen-user] Empty Schema Element

George Cristian Bina
Fri Feb 20 06:14:35 CST 2009


Hi Christian,

Normally I would define an empty element setting it a type like

     <xs:complexType name="Empty1">
         <xs:sequence/>
     </xs:complexType>

In any case, if you put your simple type that also should work. What I 
believe happens in your case is that you define an element without 
setting its type, like in the case of the test element from the sample 
below. There you find also two empty elements defined with your type and 
with the above type.

test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="root">
         <xs:complexType>
             <xs:choice maxOccurs="unbounded">
                 <xs:element ref="empty1"/>
                 <xs:element ref="empty2"/>
                 <xs:element ref="test"/>
             </xs:choice>
         </xs:complexType>
     </xs:element>

     <xs:element name="empty1" type="Empty1"/>
     <xs:element name="empty2" type="Empty2"/>
     <xs:element name="test"/>

     <xs:complexType name="Empty1">
         <xs:sequence/>
     </xs:complexType>

     <xs:simpleType name="Empty2">
         <xs:annotation>
             <xs:documentation>
                 Elemts of the type »Empty« must have no content.
             </xs:documentation>
         </xs:annotation>
         <xs:restriction base="xs:string">
             <xs:enumeration value=""/>
         </xs:restriction>
     </xs:simpleType>

</xs:schema>


test.xml

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="test.xsd">

   <empty1/>
   <empty2></empty2>
   <test>
     <empty1/>
   </test>
</root>


Best Regards,
George
-- 
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Christian Kosmowski wrote:
> Hi,
> 
> I have a question about Oxygen and XSD Schemas.
> 
> I need to have an Element which has to be empty. No attributes and no 
> child elements.
> 
> I already tried a normal complexType without content and the following 
> simpleType:
> 
> <xs:simpleType name="Empty">
>    <xs:annotation>
>      <xs:documentation>
>        Elemts of the type »Empty« must have no content.
>      </xs:documentation>
>    </xs:annotation>
>    <xs:restriction base="xs:string">
>      <xs:enumeration value=""/>
>    </xs:restriction>
>  </xs:simpleType>
> 
> But in both cases i can type whatever i want to into Elements with the 
> Type Empty. And when i am editing in such an element oxygen gives me a 
> list of all Elements in the whole Schema.
> 
> Does anyone know how to get this working?
> 
> Thanks
> 
> Christian
> 



More information about the oXygen-user mailing list