DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> XML學習教程 >> XML詳解 >> Applying Design Patterns to XML Schema Files
Applying Design Patterns to XML Schema Files
編輯:XML詳解     

The goal of this tutorial is to apply different design patterns to an XML schema file. You can use XML schema tools to apply one of the following design patterns to an XML schema file:

  Venetian Blind. In the Venetian Blind design, there is a single global element; all other elements are local. Element declarations are nested within a single global declaration, using named complex types and element groups. Complex types and element groups can be reused throughout the schema. Only the root element must be defined within the global namespace.

  Russian Doll. In the Russian Doll design, there is a single global element; all other elements are local. Element declarations are nested within a single global declaration and element declarations can only be used once. Only the root element must be defined within the global namespace.

  Salami Slice. In the Salami Slice design, all elements are global. There is no nesting of element declarations and element declarations can be reused throughout the schema. All elements must be defined within the global namespace.

  Garden of Eden. The Garden of Eden design is a combination of the Venetian Blind and Salami Slice designs. All elements and types are defined in the global namespace with the elements referenced as needed.

  For more information about design patterns, see Introducing Design Patterns in XML Schemas.

 Prerequisites

  Creating a Project and Opening a Sample XML Schema

  (Optional) Exploring XML Schemas

  (Optional) Working With XML Schemas Using the Schema VIEw

  (Optional) Working With XML Schemas Using the Design VIEw

  (Optional) Analyzing XML Schemas

  (Optional) RetrIEving and Referencing External XML Resources

  Adding the Purchase Order Sample XML Schema

  In this tutorial, you will use the Purchase Order sample XML schema that is bundled with the IDE.

  To add a sample XML schema to the mySchemaPrj project:

  In the Projects window, if the mySchemaPrj project node is not expanded, expand it now.

  Expand the SourcePackages node, select the <defaultpackage> node, right-click and choose New > Other.

  The New File wizard opens. The Project drop-down list contains the name of the project where you are adding the file, in this case, mySchemaPrj.

  In the CategorIEs list, select the XML node.

  In the File Types list, select Purchase Order schema and click Next.

  Accept the default values in the Name and Location page of the wizard (File Name: newpo, Folder: src) and click Finish.

  In the Projects window, the <defaultpackage> node under the SourcePackages node now contains a subnode labeled newpo.xsd. The newly created subnode is selected and the Source Editor contains a tab for the XML schema file, newpo.xsd.

Applying a Design Pattern

  You can use the Design Pattern wizard to quickly determine which pattern is currently applIEd to the schema and select a new pattern to apply.

  To apply a design pattern to an XML schema file:

  In the Projects window, expand the mySchemaPrj project node, the SourcePackages node, and the <defaultpackage> node.

  Select the newpo.xsd file node.

  If the Navigator window is not open, from the IDE main menu, choose Window > Navigating > Navigator.

  In the Navigator window, from the view drop-down list, select Design VIEw.

  Notice that there are two global elements and three global complex types in the current version of the schema file.

Applying Design Patterns to XML Schema Files

  In the Projects window, right-click the newpo.xsd file node and choose Apply Design Pattern from the pop-up menu.

  The Apply Design Pattern dialog box opens. Notice the warning message at the bottom of the dialog box that informs you that the selected design pattern is the same as the current design pattern, which is Garden of Eden.

Applying Design Patterns to XML Schema Files

  Under Global Element, select the Create a Single Global Element radio button and under Type, select the Do not Create Type(s) radio button.

  This defines Russian Doll as the design pattern to apply to the schema file. Notice that the Example box shows you an example of the design pattern.

Applying Design Patterns to XML Schema Files

  Click Finish.

  The IDE applIEs the new design pattern to the newpo XML schema file.

  In the Projects window, select the newpo.xsd file node and in the Navigator window, from the view drop-down list, select Design VIEw.

  In the Russian Doll design pattern, there is a single global element. Notice that since the IDE applIEd the Russian Doll pattern, there is only one global element, purchaSEOrder.

Applying Design Patterns to XML Schema Files


 

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved