Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Introduction to the XSD Editor"

 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
<table width="100%" cellspacing="5" cellpadding="2" border="0">
+
<TABLE WIDTH="800" CELLSPACING=12 align=center>
 
<tr>
 
<tr>
 
<td valign="top" align="right">&nbsp;</td><td valign="top">
 
<td valign="top" align="right">&nbsp;</td><td valign="top">
<p>
 
  
<b>By Keith Chong and Craig Salter</b>
+
<b>By Trung Ha</b>
 
<BR>
 
<BR>
December 23, 2004<BR>
+
August 30, 2006<BR>
  
 
<BR>
 
<BR>
Line 14: Line 13:
 
select New -&gt; Examples... to launch the wizard.  Follow the instructions described in the wizard, then click Finish to create the example project.
 
select New -&gt; Examples... to launch the wizard.  Follow the instructions described in the wizard, then click Finish to create the example project.
 
</P>
 
</P>
 +
  
 
<P>
 
<P>
Line 24: Line 24:
 
<BR>
 
<BR>
  
[[Image:xsdeditor-figure1.jpg">]]
+
[[Image:Xsdeditor-figure1.JPG]]
 
</P>
 
</P>
 +
  
 
<P>In order to see these components in detail you can 'drill down' on a component of interest by double clicking on it. For example,  
 
<P>In order to see these components in detail you can 'drill down' on a component of interest by double clicking on it. For example,  
 
if we double click on the 'BookType' component, the editor will display the structure of the 'BookType' type as shown below.
 
if we double click on the 'BookType' component, the editor will display the structure of the 'BookType' type as shown below.
To return to the 'top level' view, press the back button
+
To return to the 'top-level' view, press the back button  
<IMG border="0" src="images/xsdeditor-toplevelbutton.jpg">
+
[[Image:Xsdeditor-toplevelbutton.JPG]]
 
at the top left of the editor, or right clicking within the editor and selecting 'Back to Schema' from the context menu.<BR>
 
at the top left of the editor, or right clicking within the editor and selecting 'Back to Schema' from the context menu.<BR>
  
 
<BR>
 
<BR>
[[Image:xsdeditor-figure2.jpg">]]
+
[[Image:Xsdeditor-figure2.JPG]]
 
</P>
 
</P>
 +
<BR>
  
 
<P>Editing the schema is achieved by invoking context menu actions on selected objects in the Graph view and  
 
<P>Editing the schema is achieved by invoking context menu actions on selected objects in the Graph view and  
using the properties view to modify the properties of the selected object. Follow the steps below to create a new element  
+
using the properties view to modify the properties of the selected object. Go back to the top-level view and follow the steps below to create a new element  
 
declaration and define its content.</P>
 
declaration and define its content.</P>
  
Line 46: Line 48:
 
 
 
<LI>use the properties view to change the name of the element to 'Paper'
 
<LI>use the properties view to change the name of the element to 'Paper'
   [[Image:xsdeditor-figure3.jpg">]]
+
   [[Image:Xsdeditor-figure3.JPG]]
 +
  <BR>
 +
  <BR>
 +
  <BR>
 
</LI>
 
</LI>
 
 
<LI>right click on Paper and select 'Set Type'->'New..." to create a new type for the element.<BR>
+
<LI>
   [[Image:xsdeditor-figure4.jpg">]]
+
 
 +
right click on Paper and select 'Set Type'->'New..." to create a new type for the element.<BR>
 +
   [[Image:Xsdeditor-figure4.JPG]]
 +
  <BR>
 +
  <BR>
 
   <BR>
 
   <BR>
 
 
Line 57: Line 66:
 
<LI>select 'Complex Type' and check 'Create as anonymous type'. Click 'OK'.<BR>
 
<LI>select 'Complex Type' and check 'Create as anonymous type'. Click 'OK'.<BR>
 
    
 
    
[[Image:xsdeditor-figure5.jpg">]]
+
[[Image:Xsdeditor-figure5.JPG]]
 +
  <BR> 
 
   <BR>
 
   <BR>
    
+
   <BR>
<BR>
+
+
 
</LI>
 
</LI>
 
 
Line 76: Line 84:
 
On the Properties sheet, select the 'Inherit From:' combo and then select 'Browse...' as shown below.
 
On the Properties sheet, select the 'Inherit From:' combo and then select 'Browse...' as shown below.
 
 
   [[Image:xsdeditor-figure6.jpg">]]
+
   [[Image:Xsdeditor-figure6.JPG]]
    
+
   <BR>
<BR>
+
  <BR>
    
+
   <BR> 
 
</LI>
 
</LI>
 
      
 
      
Line 85: Line 93:
 
     The Set Type dialog will appear. Select 'PublicationType', and click OK.<BR>
 
     The Set Type dialog will appear. Select 'PublicationType', and click OK.<BR>
 
      
 
      
[[Image:xsdeditor-figure6.jpg">]]
+
[[Image:Xsdeditor-figure7.JPG]]
 
   <BR>
 
   <BR>
    
+
   <BR>
<BR>
+
   <BR> 
    
+
 
</LI>
 
</LI>
 
      
 
      
Line 95: Line 102:
 
     Double click on Paper's type to edit its structure as shown below. Then right click on the '(PaperType)' and select 'Add Element'<BR>
 
     Double click on Paper's type to edit its structure as shown below. Then right click on the '(PaperType)' and select 'Add Element'<BR>
 
      
 
      
[[Image:xsdeditor-figure8.jpg">]]
+
[[Image:xsdeditor-figure8.JPG]]
    <br>
+
  <BR>
 +
  <BR>
 +
  <BR>
 
</LI>
 
</LI>
 
    
 
    
Line 102: Line 111:
 
   Name the newly added element 'URL' because, say, the paper is found on the web.<BR>
 
   Name the newly added element 'URL' because, say, the paper is found on the web.<BR>
 
      
 
      
<BR>
+
[[Image:xsdeditor-figure9.JPG]]
   
+
  <BR>     
[[Image:xsdeditor-figure9.jpg">]]
+
   <BR> 
    <BR>     
+
  <BR>
    
+
 
</LI>
 
</LI>
 
 
<LI>The type of URL can be changed in the main editor panel by clicking on its current type 'string'. A combo box will be shown as below
+
<LI>The type of URL can be changed in the main editor panel by clicking on its current type 'string'. A combo box will be shown as below (For now we don't change the the type of URL yet)
 
<BR>
 
<BR>
 
      
 
      
[[Image:xsdeditor-figure10.jpg">]]
+
[[Image:xsdeditor-figure10.JPG]]
 
     <BR>  
 
     <BR>  
 +
    <BR>
 +
  <BR>
 
</LI>
 
</LI>
  
Line 121: Line 131:
 
<BR>
 
<BR>
 
      
 
      
[[Image:xsdeditor-figure11.jpg">]]
+
[[Image:xsdeditor-figure11.JPG]]
 
     <BR>  
 
     <BR>  
 +
    <BR>
 +
  <BR>
 
</LI>
 
</LI>
  
<LI>The referred element can be editted in the main editor panel by click on 'Book'. A Combo will be shown as below.
+
<LI>We can change the element to be referred to in the main editor panel by click on 'Book'. A Combo will be shown as below.
  
 
<BR>
 
<BR>
 
      
 
      
[[Image:xsdeditor-figure12.jpg">]]
+
[[Image:xsdeditor-figure12.JPG]]
 
     <BR>  
 
     <BR>  
 +
    <BR>
 +
  <BR>
 
</LI>
 
</LI>
  
Line 142: Line 156:
 
</td>
 
</td>
 
</tr>
 
</tr>
[[Image:Example.jpg]][[Image:Example.jpg]]
+
 
 +
</TABLE>

Latest revision as of 19:19, 4 April 2007

 

By Trung Ha
August 30, 2006


This tutorial will use the catalog.xsd from the "Editing and validating XML files" Examples. To create it, select New -> Examples... to launch the wizard. Follow the instructions described in the wizard, then click Finish to create the example project.


Once created, under the PublicationCatalogue folder, locate the Catalogue.xsd file and double click the file to open it in the XML Schema Editor. As shown below, an Outline and Properties view is provided in addition to the editor pane. At the bottom of the editor area you'll see that there is a 'Source' and a 'Design' tab at the bottom of the editor area. The 'Source' tab is used for basic XML source editing. The 'Design' tab is used for higher level graphical editing. Select the 'Design' tab so that you're looking at the Graph view. As shown below you should see a 'top-level' view of the XML Schema that summarizes all of the components (e.g. elements and types) that are defined in the schema.

Xsdeditor-figure1.JPG


In order to see these components in detail you can 'drill down' on a component of interest by double clicking on it. For example, if we double click on the 'BookType' component, the editor will display the structure of the 'BookType' type as shown below. To return to the 'top-level' view, press the back button Xsdeditor-toplevelbutton.JPG at the top left of the editor, or right clicking within the editor and selecting 'Back to Schema' from the context menu.

Xsdeditor-figure2.JPG


Editing the schema is achieved by invoking context menu actions on selected objects in the Graph view and using the properties view to modify the properties of the selected object. Go back to the top-level view and follow the steps below to create a new element declaration and define its content.

  1. right click on the header of the 'Elements' section of the top level schema and choose 'Add Element'
  2. use the properties view to change the name of the element to 'Paper' Xsdeditor-figure3.JPG


  3. right click on Paper and select 'Set Type'->'New..." to create a new type for the element.
    Xsdeditor-figure4.JPG


  4. select 'Complex Type' and check 'Create as anonymous type'. Click 'OK'.
    Xsdeditor-figure5.JPG


  5. Double click on 'Paper' to explore this element, note that 'PaperType' is surrounded by parenthesis to indicate anonymity of this type. Click on this type to invoke the properties sheet for its.

  6. On the Properties sheet, select the 'Inherit From:' combo and then select 'Browse...' as shown below. Xsdeditor-figure6.JPG


  7. The Set Type dialog will appear. Select 'PublicationType', and click OK.
    Xsdeditor-figure7.JPG


  8. Double click on Paper's type to edit its structure as shown below. Then right click on the '(PaperType)' and select 'Add Element'
    Xsdeditor-figure8.JPG


  9. Name the newly added element 'URL' because, say, the paper is found on the web.
    Xsdeditor-figure9.JPG


  10. The type of URL can be changed in the main editor panel by clicking on its current type 'string'. A combo box will be shown as below (For now we don't change the the type of URL yet)
    Xsdeditor-figure10.JPG


  11. Right click on '(PaperType)', select 'Add Element Ref' to create element reference. Initally, the editor will pick a random element to be referred. In this case, it's 'Book' as shown below.
    Xsdeditor-figure11.JPG


  12. We can change the element to be referred to in the main editor panel by click on 'Book'. A Combo will be shown as below.
    Xsdeditor-figure12.JPG


  13. Now that we've finished editing the XML Schema you can save the file.

Back to the top