Exploring XML Schemas
September 2007
This publication is applicable to NetBeans IDE 6.0.
Back to Getting Started With XML Schema Tools
The goal of this tutorial is to explore the sample XML schema that you opened in the previous tutorial, Creating a Project and Opening a Sample XML Schema, using the Schema and Design views of the XML schema editor and the Navigator window. You will also use the Find functionality available in the Schema view.
Contents
Tutorial Requirements
Before you proceed, make sure you review the requirements in this section.
Prerequisites
The XML schema tools tutorials assume that you have some knowledge of, and experience with XML (Extensible Markup Language).
Software Needed for This Tutorial
Before you begin, you need to install the following software on your computer:
- NetBeans IDE 6.0.
Select the Download All option. The Download All option includes SOA Pack and GlassFish V2, which are required for this tutorial.
Prerequisites
top
About the Schema View
After completing the steps in Creating a Project and Opening a Sample XML Schema, the Projects window shows a node for your mySchemaPrj project and the sample XML schema is open in the Schema view of the XML schema editor.
The Schema view allows you to visualize and edit an XML schema in a scalable fashion. The Schema view is the view that opens in the Source Editor when you first double-click a schema file (.xsd) node in the Projects window.

The Schema view has the following parts:
- Editor toolbar. The Editor toolbar is located at the top of the view, just below the tab for the XML schema file. The Editor toolbar has the following buttons:
- Navigation buttons. The Source, Schema, and Design buttons let you switch to those views of the XML schema.
- View buttons: Column button
and tree button
.
The Schema view has two subviews: the column view and the tree view of schema components. The column view is the default view. To switch between the column and tree views, use the column and tree buttons in the editor toolbar.
- Advanced Search XML button:
Use this button to find words in your schema.
- Validate XML button:
Use this button to validate the XML in your schema.
- Breadcrumb area. This area appears immediately below the Editor toolbar when you are using the columns view of the Schema view. This area allows you to retrace your steps by clicking a breadcrumb. The first entry in this area is always labeled "Schema" for the root of the schema.
If the entries extend beyond the visible area, the IDE enables the scroll buttons so that you can continue to navigate through the breadcrumbs.
- Schema content area. This area contains the column view or the tree view of the XML schema. The nodes in both views let you drill down into the schema. Each folder node represents slices of the schema, such as attributes, complex types, and elements.
- Column view. In this view, the Schema content area initially contains one column. Each time you select a node that has children, another column is added to the right of the column where you made your selection. The nodes that have child nodes are indicated by a black arrow next to the node in the column. If a node has no child nodes, that arrow is light gray.
- Tree view. In this view, the Schema content area contains one tree view of the XML schema. You can drill down on schema components by expanding the nodes.
Exploring the XML Schema in the Schema View
To explore the XML schema in the column view of the Schema view:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- In the Schema view, click the column button
to make sure you are in the column mode of the view.
- Maximize the view by right-clicking the tab for the file and choosing Maximize Window from the pop-up menu.
Maximizing the view lets you see more information about the schema in the column view of the Schema view.
- In the first column of the Schema view, select the Elements node, and then in the second column, select the autoLoanApplication node.
The IDE adds a new column to the right of the column where you selected the node. This new column shows you the detail of the node you selected.
- In the column that shows the detail of autoLoanApplication, select the complexType node, and then in the next column, select the sequence node.
- In the column that shows the detail of the sequence, select the tradeIn node.
The IDE adds another column to the right of the last column. This new column shows you the detail of the node you selected, tradeIn.
- Continue drilling down on the element definition by clicking nodes in the last column of the Schema view.
Remember that you can use the links in the breadcrumb area at any time to retrace your steps.
To explore the XML schema in the tree view of the Schema view:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- In the Schema view, click the tree button
to make sure you are in the tree mode of the view.
- In the Schema view, expand the Elements node, then expand the autoLoanApplication node.
Each time you expand a node, the IDE shows you that node's contents.
- Continue expanding child nodes to see their content.
top
Using Find
You can use Find functionality in the Schema view to quickly find components of a schema. You can either click the Advanced Search button
or press Ctl-F to produce the Find box
to begin your search. The following instructions are for using the Find box.
To find components by matching name:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- Maximize the view by right-clicking the tab for the file and choosing Maximize Window from the pop-up menu. Maximizing the view lets you see more information about the schema in the column view of the Schema view.
- In the Schema view, click the column button
to make sure you are in the column mode of the view.
- Press Ctrl-F.
- In the Find box, click the magnifying glass icon
and select Component Name from the list.
In this case, the IDE will look for components whose name attribute matches the string you enter in the Find box.
- Click in the Find box, type residence, and press Enter.
The IDE selects the first matching occurrence (as it appears in the source) of residence.
All the named components whose name contains residence as a substring, without case matching, are highlighted in light orange. Since this is not a usage search, components that reference the residence component may or may not be highlighted, depending on their names.
- Click the Find Next and Find Previous buttons in the Find bar to cycle through matching occurrences.
- Reset the find criteria by clicking the Clear button in the Find bar.
To find components by matching attributes:
- Press Ctl-F.
- Click the magnifying glass icon in the Find box,
and select Attribute Declaration from the list.
In this case, the IDE will look for components with attributes that match the string you enter in the Find box.
- Click in the Find box, type minoccur, and press Enter.
The IDE selects the first matching occurrence (as it appears in the source).
- In the Schema view, right-click the selection (tradeIn) and choose Go To > Source.
The IDE switches to the Source view and the cursor is positioned at the following line:
<xs:element name="tradeIn" minOccurs="0">
because the string minOccurs matches your find criteria.
- In the Source view, with the cursor in the <xs:element name="tradeIn" minOccurs="0"> line, right-click and choose Go To > Schema.
The IDE switches back to the Schema view, where the Find results are still highlighted.
- Click the Find Next and Find Previous buttons in the Find bar to cycle through matching occurrences.
- Close the Find bar by clicking the red "x" icon
in the Find bar.
- Restore the view by right-clicking the tab for the file and choosing Restore Window from the pop-up menu.
top
About the Design View
The Design view lets you graphically construct the structure of an instance document while the IDE codes the schema for you behind the scenes.

The Design view has the following parts:
- Editor toolbar. The Editor toolbar is located at the top of the view, just below the tab for the XML schema file. In the Design view, this toolbar has three navigation buttons: the Source, Schema, and Design buttons let you switch to those views of the XML schema.
- Schema design area. The top of this area shows the namespace of the XML schema. The area below the namespace contains the structured view of the schema. There are two top-level nodes: Elements and Complex Types. In the schema design area, you can perform the following actions:
- Select a schema component by clicking its node. If you select an expanded schema component that has child components, the IDE draws a box around the selected component and its child components.
- You can expand and collapse nodes by clicking the arrow to the left of the node label.
- For schema components with attributes, you can show and hide those attributes by clicking the Show Attributes icon,
, or the Hide Attributes icon,
, to the right of the component name in the node.
- Select a node, right-click and choose an action from the right-click pop-up menu.
When the Design view is active, the Palette (3) contains two sections that let you add components to the schema: XML Components and XML Schema Components. The editor only allows drag-and-drop to relevant areas of the schema design area. The editor provides you with visual clues to let you know where you are adding the component and also provides textual feedback in the design area.
top
Exploring the XML Schema in the Design View
The Design view of the XML schema editor does not require you to be an expert in the XML schema language, but it does offer numerous capabilities for advanced users.
To explore the XML schema in the Design view:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- In the Schema view, click the Design button to switch to the Design view of the XML schema editor.
The view switches to the Design view and the Palette is open. If the Palette is not visible, choose Window > Palette.
- Expand and collapse nodes in the schema design area to see the details of the schema components.
top
Using the Views in the Navigator Window to Navigate Schema Files
The Navigator window provides a compact view of the currently selected file and simplifies navigation between different parts of the file. For XML schema files, the Navigator has three views: Design, Schema, and XML.
- The Design View of the Navigator window shows the global elements and global complex type definitions in the schema. This corresponds to the layout of the Design view of the XML schema editor.
The following illustration shows the Design View of the Navigator window and the Design view of the XML schema editor.

- The Schema View of the Navigator window shows a tree similar to the one in the tree view of the Schema view of the XML schema editor.
The following illustration shows the Schema View of the Navigator window and the Schema view of the XML schema editor.

- The XML View of the Navigator window shows a structure that corresponds to the structure of the schema file.
The following illustration shows the XML View of the Navigator window and the Source view of the XML schema editor.

You can use different techniques to navigate directly to schema components from the Navigator window.
Before you continue:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- In the Schema view, click the column button
to make sure you are in the column mode of the view.
- If the Navigator window is not visible in the IDE, choose Window > Navigating > Navigator.
To navigate from the Design View of the Navigator window to a view in the XML schema editor:
- In the Navigator window, from the view drop-down list, select Design View.
- To navigate to the Design view of the XML schema editor, double-click a node in the Navigator window, or select a node in the Navigator window and press Enter.
The Design view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is the current selection in the Design view.
- To navigate to the Schema view of the XML schema editor, select a node in the Navigator window, right-click and choose Go To > Schema.
The Schema view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is the current selection in the Schema view.
- To navigate to the Source view of the XML schema editor, select a node in the Navigator window, right-click and choose Go To > Source.
The Source view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is highlighted in the Source view.
To navigate from the Schema View of the Navigator window to a view in the XML schema editor:
- In the Navigator window, from the view drop-down list, select Schema View.
- To navigate to the Design view of the XML schema editor, select a node in the Navigator window, right-click and choose Go To > Design.
The Design view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is the current selection in the Design view.
- To navigate to the Schema view of the XML schema editor, do one of the following:
- Double-click a node in the Navigator window.
- Select a node in the Navigator window, right-click and choose Go To > Schema.
- Select a node in the Navigator window and press Enter.
The Schema view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is the current selection in the Schema view.
- To navigate to the Source view of the XML schema editor, select a node in the Navigator window, right-click and choose Go To > Source.
The Source view of the XML schema editor becomes the active view and the schema component you selected in the Navigator window is highlighted in the Source view.
top
Switching Between XML Schema Editor Views
You can use the right-click pop-up menu to quickly switch between the Source, Schema, and Design views in the XML schema editor.
To switch between XML schema editor views:
- If mySchemaPrj is not open in the IDE, open it now and then open the newLoanApplication schema file.
- Maximize the view by right-clicking the tab for the file and choosing Maximize Window from the pop-up menu. Maximizing the view lets you see more information about the schema in the column view of the Schema view.
- In the Schema view, click the column button
to make sure you are in the column mode of the view.
- In the first column of the view, select the Complex Types node.
- In the second column, select the DurationType node, right-click and choose Go To > Source.
The IDE replaces the Schema view with the Source view and highlights the first line of the block for the DurationType complex type.
- In the Source view, position the cursor in the definition of the years element within the DurationType complex type definition.
The line looks like this:
<xs:element name="years" type="xs:positiveInteger"/>
- Right-click and choose Go To > Schema.
The IDE replaces the Source view with the Schema view and highlights the years element in the view.
- Right-click the years node and choose Go To > Design.
The IDE replaces the Schema view with the Design view and highlights the years element in the view.
- In the Design view, select the autoLoanApplication global element node at the top of the schema design area.
- Right-click and choose Go To > Schema.
The IDE replaces the Design view with the Schema view and highlights the autoLoanApplication element in the second column of the view.
top
Next Step
The steps in Working With XML Schemas Using the Schema View show you how to add, edit, and delete schema components, how to undo and redo your actions, how to take advantage of drag-and-drop functionality, and how to use cut, copy, and paste functions.
You can also see the following:
top