Page 1 of 1

xml schema annotations and tag sense

Posted: Tue Jul 11, 2006 6:44 pm
by mikemille
I'm using the oxygen eclipse plugin and I'm trying to figure out how to create an xml schema with annotations that show up in the tag sense of an xml document linked to the schema.

For example, here's part of the xml schema:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:annotation><xs:documentation>can u see me</xs:documentation></xs:annotation>
<xs:element name="viewInstructions">
<xs:complexType>
<xs:sequence>
<xs:annotation><xs:documentation>can u see me</xs:documentation></xs:annotation>
<xs:element ref="presentationPreferences"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:annotation><xs:documentation>can u see me</xs:documentation></xs:annotation>
<xs:element name="presentationPreferences">
<xs:complexType>
<xs:sequence>
<xs:annotation><xs:documentation>can u see me</xs:documentation></xs:annotation>
<xs:element ref="styles" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="styles">
<xs:complexType>
<xs:sequence>
<xs:element ref="import"/>
</xs:sequence>
<xs:attribute name="switchBranchId" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
</xs:schema>
Then I link my xml to the above schema:

Code: Select all


<viewInstructions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="add-product.xsd">
The tag sense displays properly showing me the possible tags, but the yellow comment block does not appear with my annotations in it.

Can anyone give me a simple example of how to make this work.

Thank you.

Posted: Tue Jul 11, 2006 7:13 pm
by george
Hi,

The annotations should be on the element or attribute declaration or on the enumeration facet in order to be presented by the content completion. Look at the personal.xsd schema from the oXygen samples folder for an example.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="personnel">
<xs:annotation>
<xs:documentation>Defines the personnel as a collection of person elements.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="person" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique1">
<xs:selector xpath="person"/>
<xs:field xpath="name/given"/>
<xs:field xpath="name/family"/>
</xs:unique>
<xs:key name="empid">
<xs:selector xpath="person"/>
<xs:field xpath="@id"/>
</xs:key>
<xs:keyref name="keyref1" refer="empid">
<xs:selector xpath="person"/>
<xs:field xpath="link/@manager"/>
</xs:keyref>
</xs:element>

<xs:element name="person">
<xs:annotation>
<xs:documentation>Specify information about a person.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="email" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="url" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="link" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required">
<xs:annotation>
<xs:documentation>Specify a required unique ID for this person.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="note" type="xs:string">
<xs:annotation>
<xs:documentation>If there is anything to note about this person.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="contr" default="false">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="salary" type="xs:integer">
<xs:annotation>
<xs:documentation>Specifies the salary for this person.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>

<xs:element name="name">
<xs:annotation>
<xs:documentation>Specify the person family and given name.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element ref="family"/>
<xs:element ref="given"/>
</xs:all>
</xs:complexType>
</xs:element>

<xs:element name="family" type="xs:string">
<xs:annotation>
<xs:documentation>The person last name.</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="given" type="xs:string">
<xs:annotation>
<xs:documentation>The person first name.</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="email" type="xs:string">
<xs:annotation>
<xs:documentation>Email address for this person.</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="url">
<xs:annotation>
<xs:documentation>Enter an URL for this person.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="href" type="xs:string" default="http://">
<xs:annotation>
<xs:documentation>Enter an URL for this person.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>

<xs:element name="link">
<xs:annotation>
<xs:documentation>Specify who is the manager and who are the subordinates for this person.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="manager" type="xs:IDREF">
<xs:annotation>
<xs:documentation>The manager ID.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="subordinates" type="xs:IDREFS">
<xs:annotation>
<xs:documentation>Space separated list with the subordinates IDs.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>

<xs:notation name="gif" public="-//APP/Photoshop/4.0" system="photoshop.exe"/>
</xs:schema>
Best Regards,
George

Posted: Tue Jul 11, 2006 8:58 pm
by mikemille
Thank you...it works now.

At first it wasn't showing up after your suggested changes, but I linked the schema to another xml file and the comments started popping up. I needed to close and reopen the original xml file to start seeing the comments. Must be cached or something.

Thanks again for the help.