xml_modeling
xml_modeling
SAP PowerDesigner
Document Version: 16.7.08 – 2024-07-03
XML Architecture
SAP PowerDesigner Documentation Collection
© 2024 SAP SE or an SAP affiliate company. All rights reserved.
2 XML Diagrams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1 XML Diagram Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Constructing Schemas in an XSL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
2.2 Elements (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Creating an Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Element Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 Attributes (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Creating an Attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Attribute Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Any Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.4 Group Particles (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Creating a Group Particle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Group Particle Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.5 Simple Types (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Creating a Simple Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Simple Type Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.6 Complex Types (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Creating a Complex Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Complex Type Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Applying a Complex Type to an Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.7 Groups (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Creating a Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Creating a Reference to a Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Group Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.8 Attribute Groups (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Creating an Attribute Group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
XML Architecture
2 PUBLIC Content
Attribute Group Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.9 Any Elements (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Creating an Any Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Any Element Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.10 Constraints: Keys, Uniques, and KeyRefs (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Creating a Constraint. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Constraint Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54
2.11 Derivations: Extensions, Restrictions, Lists and Unions (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Deriving by Extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Deriving by Restriction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Deriving by List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Deriving by Union. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.12 Annotations (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.13 Notations (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Creating a Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Notation Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.14 Entities (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Creating an Entity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Entity Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.15 Instructions: Import, Include and Redefine (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Creating an Import, Include, or Redefine Instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Import, Include, and Redefine Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.16 Business Rules (XSM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4 Checking an XSM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1 Group Particle Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
4.2 Model Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.3 Data Source Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.4 Entity Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.5 Include Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
4.6 Simple Type Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.7 Complex Type Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
4.8 Element Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.9 Group Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.10 Attribute Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.11 Notation Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.12 Attribute Group Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
XML Architecture
Content PUBLIC 3
4.13 Import Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.14 Redefine Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
4.15 Key Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.16 KeyRef Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.17 Unique Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.18 Extension Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
4.19 Restriction Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
4.20 Simple Type List Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.21 Simple Type Union Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
4.22 Annotation Checks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
XML Architecture
4 PUBLIC Content
1 Getting Started with XML Modeling
An XML model (XSM) helps you analyze an XML Schema Definition (.XSD), Document Type Definition (.DTD) or
XML-Data Reduced (.XDR) file. You can model, reverse-engineer, and generate each of these file formats.
Since XML structures can be very complex, it can be easier to visualize them through diagrams. With its
Browser tree view and diagram, an SAP® PowerDesigner® XSM gives you a global and schematic view of all the
elements composing your XSD, DTD, or XDR:
A PowerDesigner XSM allows you to generate and reverse engineer XSD, DTD and XDR files and also generate
an XML model from a Physical Data Model (PDM), Object Oriented Model (OOM), or another XSM:
XML Architecture
Getting Started with XML Modeling PUBLIC 5
DTD, XSD or XDR
• A DTD file is a basic way to describe the structure of an XML document. It is a raw list of all the legal
elements making up an XML document. An extract of a DTD file follows:
• An XSD file (or schema) is an elaborated way to describe the structure of an XML document. It can support
namespaces, derivations, keys, simple and complex user-defined data types and a robust collection of
predefined data types. An extract of an XSD file follows:
An XSD file always starts with the <schema> tag (root element). All objects created in the model will
appear in the XSD file between the schema start-tag and end-tag
XML Architecture
6 PUBLIC Getting Started with XML Modeling
• An XDR file is a simplified XSD file (or schema). It does not support simple and complex user-defined data
types. An extract of an XDR file follows:
An XDR file always starts with the <schema> tag (root element). All objects created in the model will
appear in the XDR file between the schema start-tag and end-tag
Suggested Bibliography
Context
Note
In addition to creating an XSM from scratch with the following procedure, you can also reverse-engineer a
model from an existing XSD, a DTD or an XDR file (see Reverse Engineering an XML Schema into an XSM
[page 74]).
The New Model dialog is highly configurable, and your administrator may hide options that are not relevant for
your work or provide templates or predefined models to guide you through model creation. When you open the
dialog, one or more of the following buttons will be available on the left hand side:
• Categories - which provides a set of predefined models and diagrams sorted in a configurable category
structure.
XML Architecture
Getting Started with XML Modeling PUBLIC 7
• Model types - which provides the classic list of PowerDesigner model types and diagrams.
• Template files - which provides a set of model templates sorted by model type.
Procedure
By default, PowerDesigner creates a link in the model to the specified file. To copy the contents of the
resource and save it in your model file, click the Embed Resource in Model button to the right of this field.
XML Architecture
8 PUBLIC Getting Started with XML Modeling
Embedding a file in this way enables you to make changes specific to your model without affecting any
other models that reference the shared resource.
6. [optional] Click the Select Extensions button and attach one or more extensions to your model.
7. Click OK to create and open the XML model .
Note
You open the model property sheet by right-clicking the model in the Browser and selecting Properties.
Property Description
Name/Code/Comment Identify the model. The name should clearly convey the model's purpose to non-technical
users, while the code, which is used for generating code or scripts, may be abbreviated,
and should not normally include spaces. You can optionally add a comment to provide
more detailed information about the model. By default the code is auto-generated from
the name by applying the naming conventions specified in the model options. To decouple
name-code synchronization, click to release the = button to the right of the Code field.
Filename Specifies the location of the model file. This box is empty if the model has never been
saved.
Author Specifies the author of the model. If you enter nothing, the Author field in diagram title
boxes displays the user name from the model property sheet Version Info tab. If you enter a
space, the Author field displays nothing.
Version / Repository Specify a user-defined version name and the read-only repository version number of the
model. You can control which of these version values is displayed in a diagram Title symbol
through the display preferences for the Title symbol.
Default diagram Specifies the diagram displayed by default when you open the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords,
separate them with commas.
XML Architecture
Getting Started with XML Modeling PUBLIC 9
• Detail - [XSD only] Contains the following properties:
Property Description
Target Name- Specifies a URI as the namespace for all the model objects. All the schema elements with this
space prefix in their start-tag will be associated with the namespace. For example: http://www.mycom-
pany.com/myproduct/XMLmodel
Language Specifies the language used in the model. For example: en, en-GB, en-US, de, fr
ID Specifies the ID of the model. Its value must be of type ID and unique within the file containing the
model. For example: XMOD1
Default Specifies defaults for the Form and Block and Final model object properties.
• Items - lists the model's global objects (which have no parent symbol in the diagram, and are directly linked
to the <schema> tag). The list reflects the order in which global objects are declared in the schema. You
can change the order of declaration by selecting an item in the list and using the arrowed buttons, at the
bottom-left corner of the tab, to move it in the list. The following tools are available on this tab:
Tool Description
Add Element
Add Group
Add Attribute
Add Notation
• External Schemas - [XSD only] Allows you to link to and reuse in your model global objects from other
schemas. The following tools are available on this tab:
Tool Description
Add Include
Add Import
XML Architecture
10 PUBLIC Getting Started with XML Modeling
Tool Description
Add Redefine
Add Annotation
• Namespaces - [XSD and XDR only] Lists the namespaces used to declare objects used in the model.
• Preview - Displays a preview of the XSD, DTD or XDR file generated from the XSM.
Click the Preview tab in the property sheet of the model, elements, and various other model objects in order to
view the code that will be generated for it.
XML Architecture
Getting Started with XML Modeling PUBLIC 11
Tools Description
• New ( Ctrl + N ) - Reinitializes the field by removing all the existing content.
• Open... ( Ctrl + O ) - Replaces the content of the field with the content of the selected file.
• Insert... ( Ctrl + I ) - Inserts the content of the selected file at the cursor.
• Save ( Ctrl + S ) - Saves the content of the field to the specified file.
• Save As... - Saves the content of the field to a new file.
• Select All ( Ctrl + A ) - Selects all the content of the field.
• Find... ( Ctrl + F ) - Opens a dialog to search for text in the field.
• Find Next... ( F3 ) - Finds the next occurence of the searched for text.
• Find Previous... ( Shift + F3 ) - Finds the previous occurence of the searched for text.
• Replace... ( Ctrl + H ) - Opens a dialog to replace text in the field.
• Go To Line... ( Ctrl + G ) - Opens a dialog to go to the specified line.
• Toggle Bookmark ( Ctrl + F2 ) - Inserts or removes a bookmark (a blue box) at the cursor
position. Note that bookmarks are not printable and are lost if you refresh the tab
• Next Bookmark ( F2 ) - Jumps to the next bookmark.
• Previous Bookmark ( Shift + F2 ) - Jumps to the previous bookmark.
Edit With ( Ctrl + E ) - Opens the previewed code in an external editor. Click the down arrow to select
a particular editor or Choose Program to specify a new editor. Editors specified here are added to the list
Save ( Ctrl + S ) - Saves the content of the field to the specified file.
Cut ( Ctrl + X ), Copy ( Ctrl + C ), and Paste ( Ctrl + V ) - Perform the standard clipboard
actions.
Undo ( Ctrl + Z ) and Redo ( Ctrl + Y ) - Move backward or forward through edits.
You can debug the GTL templates that generate the code shown in the Preview tab. To do so, open the
target or extension resource file, select the Enable Trace Mode option, and click OK to return to your
model. You may need to click the Refresh tool to display the templates.
Select Generation Targets ( Ctrl + F6 ) - Lets you select additional generation targets (defined in
extensions), and adds a sub-tab for each selected target. For information about generation targets, see
Customizing and Extending PowerDesigner > Extension Files > Generated Files (Profile) > Generating Your
Files in a Standard or Extended Generation .
XML Architecture
12 PUBLIC Getting Started with XML Modeling
1.3 Customizing your Modeling Environment
The PowerDesigner XML model provides various means for customizing and controlling your modeling
environment.
You can set XSM model options by selecting Tools Model Options or right-clicking the diagram
background and selecting Model Options.
You can set the following options on the Model Settings page:
Option Description
Name/Code case Specifies that the names and codes for all objects are case sensitive, allowing you to have two
sensitive objects with identical names or codes but different cases in the same model. If you change case
sensitivity during the design process, we recommend that you check your model to verify that your
model does not contain any duplicate objects.
Enable links to re- Displays a Requirements tab in the property sheet of every object in the model, which allows you to
quirements attach requirements to objects (see Requirements Management ).
Generate tables as Specifies how PDM tables are generated to the XSM during model-to-model generation or when
creating objects through drag-and-drop in the Mapping Editor. You can choose between:
• Elements - [default] each table is generated as an untyped element directly linked to its
columns generated as attributes or sub-elements.
• Elements with complex types - each table is generated as an element typed by a complex type,
generated in parallel, to contain the columns.
Generate columns as Specifies how PDM columns are generated to the XSM during model-to-model generation or when
creating objects through drag-and-drop in the Mapping Editor. You can choose between:
For information about controlling the naming conventions of your models, see Core Features Guide > Modeling
with PowerDesigner > Objects > Naming Conventions.
PowerDesigner display preferences allow you to customize the format of object symbols, and the information
that is displayed on them. To set XML model display preferences, select Tools Display Preferences or
right-click the diagram background and select Display Preferences.
XML Architecture
Getting Started with XML Modeling PUBLIC 13
In the Display Preferences dialog, select the type of object in the list in the left pane, and modify its appearance
in the right pane.
You can control what properties it will display on the Content tab, and how it will look on the Format tab. If the
properties that you want to display are not available for selection on the Content tab, click the Advanced button
and add them using the Customize Content dialog.
For detailed information about controlling the appearance and content of object symbols, see Core Features
Guide > Modeling with PowerDesigner > Diagrams, Matrices, and Symbols > Display Preferences.
Each XSM is linked to a definition file that extends the standard PowerDesigner metamodel to provide objects,
properties, data types, and generation parameters and templates specific to the language being modeled.
Definition files and other resource files are XML files located in the Resource Files directory inside your
installation directory, and can be opened and edited in the PowerDesigner Resource Editor.
Caution
The resource files provided with PowerDesigner inside the Program Files folder cannot be modified
directly. To create a copy for editing, use the New tool on the resource file list, and save it in another
location. To include resource files from different locations for use in your models, use the Path tool on the
resource file list.
To open your model's definition file and review its extensions, select Language Edit Current Language .
For detailed information about the format of these files, see Customizing and Extending PowerDesigner >
Object, Process, and XML Language Definition Files .
Note
Some resource files are delivered with "Not Certified" in their names. We will perform all possible validation
checks, but we do not maintain specific environments to fully certify these resource files. We will support
them by accepting bug reports and providing fixes as per standard policy, with the exception that there will
be no final environmental validation of the fix. You are invited to assist us by testing fixes and reporting any
continuing inconsistencies.
You can change the XML language being modeled in your XSM at any time.
Context
Simple types and complex types are only supported by XSDs (schemas). When changing an XSD into a DTD
or an XDR, simple types and global complex types (directly linked to the <schema> tag) disappear from the
XML Architecture
14 PUBLIC Getting Started with XML Modeling
diagram and the Browser tree view. Local complex types (within an element) are expanded in the diagram,
beneath their containing element. In this example, HighDefinition is a global complex type, reused as data type
for the deluxeTV element:
Note
You may be required to change the XML language if you open a model and the associated definition file is
unavailable.
Procedure
XML Architecture
Getting Started with XML Modeling PUBLIC 15
2. Select a XML language from the list.
By default, PowerDesigner creates a link in the model to the specified file. To copy the contents of the
resource and save it in your model file, click the Embed Resource in Model button to the right of this field.
Embedding a file in this way enables you to make changes specific to your model without affecting any
other models that reference the shared resource.
3. Click OK.
A message box opens to tell you that the XML language has been changed.
4. Click OK to return to the model.
You can customize and extend PowerDesigner metaclasses, parameters, and file generation with extensions,
which can be stored as part of your model or in separate extension files (*.xem) for reuse with other models.
To access extensions defined in a *.xem file, simply attach the file to your model. You can do this when creating
a new model by clicking the Select Extensions button at the bottom of the New Model dialog, or at any time by
selecting Model Extensions to open the List of Extensions and clicking the Attach an Extension tool.
In each case, you arrive at the Select Extensions dialog, which lists the extensions available, sorted on sub-tabs
appropriate to the type of model you are working with:
XML Architecture
16 PUBLIC Getting Started with XML Modeling
To quickly add a property or collection to an object from its property sheet, click the menu button in the
bottom-left corner (or press F11) and select New Attribute or New List of Associated Objects. For more
information, see Core Features Guide > Modeling with PowerDesigner > Objects > Extending Objects.
To create a new extension file and define extensions in the Resource Editor, select Model Extensions ,
click Add a Row, and then click Properties. For detailed information about working with extensions, see
Customizing and Extending PowerDesigner > Extension Files .
Traceability links provide a flexible means for creating a connection between any object in any type of model
and any other object in the same model or any other model open in your workspace. Traceability links have
no formal semantic meaning, but can be followed when performing an impact analysis or otherwise navigating
through the model structure.
To create a traceability link between objects in the same diagram, select the Link/Traceability Link tool in the
Toolbox. Click inside the symbol of the object that is dependent and, while continuing to hold down the mouse
button, drag the cursor and release it on the symbol of the object on which it depends. In this example, the
Work entity is shown as being dependent on School through a traceability link:
To create a traceability link to any object in any model that is open in the Workspace, open the property sheet
of the dependent object, click its Traceability Links tab, and click the Add Objects tool. Use the Model list to
select a different model, select the object to point to and click OK to create the link and return to the dependent
object's Traceability Links tab. You can optionally specify a type for any traceability link in the Link Type column.
Click the Types and Grouping tool to perform various actions on this tab:
XML Architecture
Getting Started with XML Modeling PUBLIC 17
• To make a link type available for selection in the Link Type column, click the Types and Grouping tool and
select New Link Type. Enter a Name for the link type and, optionally, a Comment to explain its purpose, and
then click OK.
Note
Traceability link types created in this way are stored as stereotypes in an extension file embedded in the
model. To work directly with this file click the Types and Grouping tool and select Manage Extensions.
For detailed information about working with these files, see Customizing and Extending PowerDesigner
> Extension Files .
• To control the display and grouping of links, click the Types and Grouping tool and select:
• No Grouping - to display all the links in a single list.
• Group by Object Type - to display links to different types of objects on separate sub-tabs. To add a link
to a new object type, click the plus sign on the leftmost sub-tab.
• Group by Link Type - to display different link types on separate sub-tabs. To add a new link type, click
the plus sign on the leftmost sub-tab.
Note
To see all of the objects that point to an object via traceability links, open its property sheet, click its
Dependencies tab, and click the Incoming Traceability Links sub-tab.
XML Architecture
18 PUBLIC Getting Started with XML Modeling
2 XML Diagrams
An XML diagram provides a graphical view of the elements that comprise an XML schema definition in a tree
format.
Note
To create an XML diagram in an existing XSM, right-click the model in the Browser and select New XML
Model Diagram . To create a new model, select File New Model , choose XML Model as the model
type and XML Model Diagram as the first diagram, and then click OK.
The following example shows the diagram of an XSM which models an XML schema for Resume documents:
• Expand - to expand the first level of the hierarchy below the symbol.
• Expand All - to expand the whole hierarchy below the symbol.
• Collapse - to hide the hierarchy below the symbol.
• Arrange Symbols- to reorganize the hierarchy below the symbol.
XML Architecture
XML Diagrams PUBLIC 19
Note
The Symbol Group Symbols command only acts on free symbols in an XML diagram.
If an XML model is too large or too complex, you can create several diagrams to have partial views of the model
and focus on certain objects.
For example, the original Resume diagram could be split into five diagrams, corresponding to the five main
objects of the model (Main, Contact, Achievement, Description and Address).
An XML model represents the structure of a potential or existing XSD, DTD, or XDR through a tree structure of
elements. PowerDesigner supports all the objects necessary to build XML diagrams.
Element The basic object of an XML model. An element can contain other
elements or attributes. See Elements (XSM) [page 23].
Attribute N/A N/A Additional information about an element or a complex type. Defined
by a built-in data type or a simple data type. See Attributes (XSM)
[page 29].
XML Architecture
20 PUBLIC XML Diagrams
Object Tool Symbol Description
Sequence Group particles arranges child elements, so that all must appear
at least once in the order of their declaration, only one must be
Choice
chosen, or any can appear in any order. See Group Particles (XSM)
All [page 34].
Simple Type N/A N/A [XSD only] Used in the case of elements or attributes with text-only
content. See Simple Types (XSM) [page 37].
Complex Type [XSD only] Used to introduce elements or attributes within an ele-
ment declaration. See Complex Types (XSM) [page 38].
Attribute Group N/A N/A A group of attributes, defined once and reused in the model through
references. See Attribute Groups (XSM) [page 46].
Constraint N/A N/A [XSD only] Specifies uniqueness of element values. See Con-
straints: Keys, Uniques, and KeyRefs (XSM) [page 51].
Derivation N/A N/A Extends or restricts the values of elements and simple and complex
types. See Derivations: Extensions, Restrictions, Lists and Unions
(XSM) [page 57].
Instruction N/A N/A An import, include, or redefine instruction. See Instructions: Import,
Include and Redefine (XSM) [page 68].
Entity N/A N/A [DTD only] Specifies a predefined value or external XML or non-XML
file. See Entities (XSM) [page 66].
Notation N/A N/A Defines and processes non-XML objects within an XML model. See
Notations (XSM) [page 65].
XML Architecture
XML Diagrams PUBLIC 21
2.1.1 Constructing Schemas in an XSL
You construct a schema in an XSL by building a tree structure of elements and group particles. To link a child
object to a parent object, click the child object tool in the Toolbox and then click the symbol of the parent object
in the diagram. You can reuse structures of elements in your schema by creating a group or complex type and
referencing them.
(Any)
(creates a reference to
a group)
(All)
Note
If the tool cannot be used in the current point in the diagram, the cusror displays a forbidden sign. If an
object can be created as a sibling or a child to the object under the cursor, it displays an arrow indicating
the corresponding direction.
XML Architecture
22 PUBLIC XML Diagrams
The following table lists the children that you can create under sequence, choice, and all group particles:
(Any)
No link
No link
No link
No link
Caution
A group particle (sequence, choice, all) cannot be created from scratch in a diagram. It must be the child
element of an element, a group or a complex type.
Elements are the basic building blocks of an XML model, which organizes them into a tree structure. Elements
can contain other elements (via group particles) and attributes, and can reference groups, attribute groups and
simple and complex types.
• Global elements - have no parent element, and are directly linked to the <schema> root element. They can
be reused in the model through referencing elements.
• Local elements - have a parent element in a diagram, and are unique within their parent scope. They
reference (and, thus, be defined by) a global element by selecting the global element in the Reference
property on the General tab of their property sheet.
XML Architecture
XML Diagrams PUBLIC 23
Note
In a model targeted with the XML-Data Reduced language, local elements are first declared separately, like
global elements (with the <ElementType> tag and a name attribute), then within their parent element
(with the <element> tag and a type attribute). For example:
Parent elements are linked to their child elements through group particles (sequence, choice or all), which
contain a group of child elements (see the Group type property in Element Properties [page 25]).
You can derive an XSD element data type to extend or restrict its values (see the Derivation property in Element
Properties [page 25]).
You can create an element from the Toolbox, Browser, or Model menu. Elements can be created as root
elements anywhere in the diagram and, via group particles, as children of elements, complex types, and
groups.
Tool Action
Click any part of a top-level element symbol to create a sequence group particle (see Group Particles
(XSM) [page 34]) and a child element:
Click the upper part of a child element symbol to create a sibling element above it:
XML Architecture
24 PUBLIC XML Diagrams
Tool Action
Click the lower part of a child element symbol to create a sibling element below it:
Click the middle part of a child element symbol to create a sequence group particle and child element to
the child element:
• Select Model Elements to access the List of Elements, and click the Add a Row tool.
• Right-click the model or package in the Browser, and select New Element .
• Open the property sheet of a group particle (see Group Particles (XSM) [page 34]), click the Items tab,
and use the Add Element tool.
For information about creating children under the element, see Constructing Schemas in an XSL [page 22].
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit an element's properties, double-click its diagram symbol or Browser or list entry. The property
sheet tabs and fields listed here are those available by default, before any customization of the interface by you
or an administrator.
The General tab of an XSD or DTD element property sheet displays the following properties (for XDR element
properties, see the subsequent table):
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
XML Architecture
XML Diagrams PUBLIC 25
Property Description
Reference Specifies a global element to reuse. Select an element in the current model from the list or click the
Browse tool to select an element from any model open in the workspace.
Disables all other properties. To locate the referenced element in the diagram, right-click the referenc-
ing element and select Find Referenced Element.
Group type Specifies that the object has child elements, and how they are used (see Group Particles (XSM) [page
34]). You can choose between:
Type / IDREF type Specifies the data type. Select a built-in data type from the list or click the Browse tool to select
a simple type defined in any model open in the workspace. If you select IDREF or IDREFS, the
IDREF type property is displayed, allowing you to select the element to reference for documentation
purposes.
For an XSD element, selecting a data type will delete any group particle or attribute previously
defined. Do not select a data type if you want to define attributes or child elements within the current
element.
Embedded type [XSD only] Specifies a locally defined data type, which applies to the current element only. Automati-
cally set to Complex if you define a derivation for the element data type.
Content [XSD only] Specifies the type of content of the object. You can select:
• Complex – elements or elements and character data. Click the Properties tool to specify an ID
(unique within the model) for the complex content, and select the Mixed check box if character
data can appear between child elements.
• Simple – character data or a simple type (but no elements). Click the Properties tool to specify an
ID for the simple content.
Derivation [XSD only] Specifies a derivation method for the data type to extend or restrict its values. Resets the
Type property to <None>. Click the Properties tool to further define the derivation (see Derivations:
Extensions, Restrictions, Lists and Unions (XSM) [page 57]).
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
XML Architecture
26 PUBLIC XML Diagrams
Detail Tab
Property Description
Persistent Specifies how the element will be generated to a PDM. You can choose between:
• Generate table - the element will be generated as a table (with a reference to its parent, if
appropriate).
• Migrate columns - the attributes and child elements of the element will be migrated to its
parent element.
Minimum Specifies the minimum number of times the object can occur. Enter zero to specify that it is
optional.
Maximum Specifies the maximum number of times the object can occur. Select unbounded to specify unlim-
ited instances.
Substitution group Species a global element for which the current element can be substituted. The substitute must
have the the same type or derived type.
Default Specifies a default value for the object. Mutually exclusive with Fixed.
Fixed Specifies a fixed value for the object. Mutually exclusive with Default.
Block Specifies that another object with the same type of derivation cannot be used in place of the
current one.
Form Specifies whether or not the object name must be qualified by the target namespace of the
schema.
ID Specifies the ID of the object, which must be unique within the model.
Abstract Specifies that the object cannot be used in the instance document.
Note
In the case of a model targeted with XDR, the Detail tab is only available for local elements.
• Attributes - lists the attributes and attribute groups associated with the element (see Attributes (XSM)
[page 29]).
• Constraints - lists the constraints associated with the element (see Constraints: Keys, Uniques, and
KeyRefs (XSM) [page 51]).
• Mappings - lists the mappings to objects in other models associated with the element (see Core Features
Guide > Linking and Synchronizing Models > Object Mappings).
XML Architecture
XML Diagrams PUBLIC 27
XDR Element Properties
In a model targeted with the XML-Data Reduced language, elements are defined as follows:
Model Specifies if an element can contain new local elements. Possible values are:
• closed – [default]
• open - if an "Any" element is attached to the element. See Any Elements (XSM) [page 49]
Order Specifies how child elements are organized within a parent element. Possible values are:
Values tab
type [local elements only] Specifies the name of a global element as reference for the local element
minOccurs [local elements only] To specify the minimum number of occurrences for a local element.
Usually set to 0 or 1
maxOccurs [local elements only] To specify the maximum number of occurrences for a local element.
Usually set to 1 or * (unbounded)
XML Architecture
28 PUBLIC XML Diagrams
2.3 Attributes (XSM)
Attributes can be created under elements or complex types or directly at the root or in an attribute group for
reuse.
• Global attributes are defined with the Model menu. In a schema, they are directly linked to the <schema>
tag (root element). They can be reused for any element in the model through references (See "NUMBER"
attribute in the generated schema)
• Local attributes only apply to the elements in which they are created. They can be defined by reference to a
global attribute (See Reference property)
Note
In a model targeted with the XML-Data Reduced language, local attributes are first declared separately, like
global attributes (with the <AttributeType> tag and a name attribute), then within their parent element
(with the <attribute> tag and a type attribute).
In a model targeting XSD, you can derive an attribute data type to extend or restrict its values. For example:
Generated schema:
XML Architecture
XML Diagrams PUBLIC 29
2.3.1 Creating an Attribute
You can create attributes on the Attributes tab of an element, complex type, or attribute group property sheet.
Tool Description
Add Undefined Reference to Attribute Group - Adds a reference to an attribute group defined in the current
model. Select a name from the Reference list or enter a name for a new attribute group to be defined later.
Add Reference to Attribute - Adds references to global attributes defined in the current model that you choose
from a Selection dialog.
XML Architecture
30 PUBLIC XML Diagrams
Tool Description
Add Reference to Attribute Group - Adds references to attribute groups defined in the current model that you
choose from a Selection dialog.
Any Attribute - Adds "any" attribute of a specified namespace ( see Any Attributes [page 33].
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit an attribute's properties, double-click its diagram symbol or Browser or list entry. The property
sheet tabs and fields listed here are those available by default, before any customization of the interface by you
or an administrator.
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Reference Specifies a global attribute to reuse. Select a global attribute in the current model from the list or
click the Browse tool to select an attribute from any model open in the workspace. Disables the Name,
Code, Type, Default, and Fixed properties.
Type / IDREF type Specifies the data type. Select a built-in data type from the list or click the Browse tool to select
a simple type defined in any model open in the workspace. If you select IDREF or IDREFS, the
IDREF type property is displayed, allowing you to select the element to reference for documentation
purposes.
Embedded Type [XSD only] Creates a <simple type> tag in the schema within the <attribute> tag. Resets the
Type property to <None>.
Derivation [XSD only] Specifies a derivation method for the data type to extend or restrict its values. Resets the
Type property to <None>. Click the Properties tool to further define the derivation (see Derivations:
Extensions, Restrictions, Lists and Unions (XSM) [page 57]).
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
XML Architecture
XML Diagrams PUBLIC 31
Detail Tab
The Detail tab of an attribute property sheet displays the following properties:
Property Description
Default Specifies a default value for the object. Mutually exclusive with Fixed.
Fixed Specifies a fixed value for the object. Mutually exclusive with Default.
Form Specifies whether or not the object name must be qualified by the target namespace of the schema.
ID Specifies the ID of the object, which must be unique within the model.
The Values tab of an attribute property sheet is only available in a model targeted with DTD or XDR. You can set
a list of predefined values for an attribute.
Note
In a model targeted with the XML-Data Reduced language, there is also a Values tab in the element property
sheet.
XML Architecture
32 PUBLIC XML Diagrams
XDR Attribute Attribute Description
Values tab
type Specifies the name of a global attribute as a reference for a local attribute.
The Any Attribute check box in the bottom-left corner of the Attributes tab allows you to specify that any
attribute of the specified namespaces can be inserted into an element, a complex type or an attribute group
declaration. It is only available in a model targeted with XSD.
For example:
Click the Properties tool to display the Any Attribute property sheet. The General tab contains the following
properties:
Property Description
ID Specifies the ID of the object, which must be unique within the model.
XML Architecture
XML Diagrams PUBLIC 33
Property Description
Namespace Specifies the namespaces containing the attributes that can be used. You can enter a white space
delimited list with URI references or choose from:
Process contents Specifies how an XML processor should handle validation of XML documents containing the attrib-
utes specified by the Any Attribute. You can choose from:
• Lax - the processor will try to obtain the schema and validate any attribute of the specified
namespaces. If the schema cannot be found, no error will occur.
• Skip - the processor will not try to validate the attributes.
• Strict - the processor must obtain the schema and validate any attribute of the specified name-
spaces.
Child elements are linked to their parent element through a group particle.
Sequence - Child elements must appear at least once in the order of their declaration
XML Architecture
34 PUBLIC XML Diagrams
Tool Symbol Description
Choice - Only one child element can be linked to the parent element
All - Child elements can appear in any order and each of them once or not at all
These particles translate to the following tags in each of the supported languages:
You can create a group particle from the Toolbox or from the property sheet of an element, group, or complex
type.
• Select the Sequence, Choice, or All tool in the Toolbox, and click an element, complex type, group, or group
particle.
Note
A sequence particle is automatically created if you click on an element symbol with the Element or Any
tool (see Creating an Element [page 24]).
• Open the property sheet of an element, group, or complex type, select a Group type on the General tab, and
click OK. The element symbol displays a plus sign on its right side that you can click to reveal the group
particle.
• Open the property sheet of a group particle, click the Items tab, and use the Add Group Particle tool.
For information about creating children under the group particle, see Constructing Schemas in an XSL [page
22].
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
XML Architecture
XML Diagrams PUBLIC 35
2.4.2 Group Particle Properties
To view or edit a group particle's properties, double-click its diagram symbol or Browser or list entry. The
property sheet tabs and fields listed here are those available by default, before any customization of the
interface by you or an administrator.
Property Description
Minimum Specifies the minimum number of times the object can occur. Enter zero to specify that it is optional.
Maximum Specifies the maximum number of times the object can occur. Select unbounded to specify unlimited
instances.
ID Specifies the ID of the object, which must be unique within the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
Items Tab
This tab list the child objects associated with the group particle. You can add additional children directly on this
tab using the following tools:
Tool Description
XML Architecture
36 PUBLIC XML Diagrams
2.5 Simple Types (XSM)
A simple type is a data type definition defined by derivation of an existing simple type (built-in data type
or derived simple type). It can be used by elements or attributes with text-only content; it cannot contain
elements or attributes. You can only create simple types in a model targeting XSD.
• List - contains a white space-separated list of values of an inherited simple type (see Deriving by List [page
62]).
• Restriction - has a range of values restricted to a subset of those of an inherited simple type (see Deriving
by Restriction [page 59]).
• Union - contains a union of values of two or more inherited simple types Deriving by Union [page 63]).
Once defined in a model, a simple type can be reused in the definition of an attribute, an element or a complex
type.
You can create a simple type from the Browser or Model menu. Simple types can only be created at the root of
the model.
• Select Model Simple Types to access the List of Simple Types, and click the Add a Row tool.
• Right-click the model or package in the Browser, and select New Simple Type .
Caution
If the simple type symbol does not appear in the diagram, select Symbol Show Symbols , click the
Simple Type tab, select the simple types that you want to display, and click OK.
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
XML Architecture
XML Diagrams PUBLIC 37
2.5.2 Simple Type Properties
To view or edit a simple type's properties, double-click its diagram symbol or Browser or list entry. The property
sheet tabs and fields listed here are those available by default, before any customization of the interface by you
or an administrator.
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Names and codes must be unique among all simple and complex types.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Derivation [required] [XSD only] Specifies a derivation method for the data type to extend or restrict its values.
Resets the Type property to <None>. Click the Properties tool to further define the derivation (see
Derivations: Extensions, Restrictions, Lists and Unions (XSM) [page 57]).
ID Specifies the ID of the object, which must be unique within the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
A complex type is an element that contains other elements or attributes, and which is used to define a data
type to be reused and derived by extension or restriction.You can only create complex types in a model targeted
with XSD.
Complex types are generally created directly under the <schema> tag, to be reused or derived (by extension
or restriction) in other parts of the schema. Such global complex types are listed in the Browser, and can have
symbols in the diagram. Complex types can also be created within an element, by selecting Complex in the
Embedded Type field of the element property sheet (see Element Properties [page 25]). Such local complex
types can only be seen as part of the schema in the Preview tab of the element property sheet.
In this example, the global Address complex type is selected as the type of the User Address element:
XML Architecture
38 PUBLIC XML Diagrams
The generated schema is as follows:
You can create a complex type from the Toolbox, Browser, or Model menu. Complex types can only be created
at the model root.
For information about creating children under the complex type, see Constructing Schemas in an XSL [page
22].
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
XML Architecture
XML Diagrams PUBLIC 39
2.6.2 Complex Type Properties
To view or edit a complex type's properties, double-click its diagram symbol or Browser or list entry. The
property sheet tabs and fields listed here are those available by default, before any customization of the
interface by you or an administrator.
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Names and codes must be unique among all simple and complex types.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Group type Specifies that the object has child elements, and how they are used (see Group Particles (XSM) [page
34]). You can choose between:
Content [XSD only] Specifies the type of content of the object. You can select:
• Complex – elements or elements and character data. Click the Properties tool to specify an ID
(unique within the model) for the complex content, and select the Mixed check box if character
data can appear between child elements.
• Simple – character data or a simple type (but no elements). Click the Properties tool to specify an
ID for the simple content.
Derivation [XSD only] Specifies a derivation method for the data type to extend or restrict its values. Resets the
Type property to <None>. Click the Properties tool to further define the derivation (see Derivations:
Extensions, Restrictions, Lists and Unions (XSM) [page 57]).
XML Architecture
40 PUBLIC XML Diagrams
Detail Tab
Property Description
Block Specifies that another object with the same type of derivation cannot be used in place of the current
one.
Mixed Specifies that character data can appear between child elements. Only appropriate if the complex
type has complex content.
Abstract Specifies that the object cannot be used in the instance document.
ID Specifies the ID of the object, which must be unique within the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
• Attributes - lists the attributes and attribute groups associated with the complex type (see Attributes
(XSM) [page 29]).
• Mappings - lists the mappings to objects in other models associated with the element (see Core Features
Guide > Linking and Synchronizing Models > Object Mappings).
You apply a complex type to an element by selecting it in the Type list on the General tab of the element
property sheet.
Procedure
1. Open the property sheet of the element to which you want to apply the type.
2. If the type is present in the model, even if only in shortcut form, you can select it directly in the Type list. If
the type is defined in another model open in the workspace, click the Select Object tool to the right of this
field to select it and create a shortcut in the model.
3. Click OK to apply the type and return to the diagram. The complex type symbol appears to the right of the
element
In the following example, the Name is a complex type defined in the model and applied to the Employee/
Name element, while Address is a shortcut to a complex type defined in another model and applied to the
Employee/Address element:
XML Architecture
XML Diagrams PUBLIC 41
4. [optional] Click the plus sign to the right of the complex type to display its child elements. You may need to
move the complex type symbol or other symbols to allow all of them to display without overlap:
You can edit the properties and child elements of any instance of a complex type defined in the model, and
these changes will be propagated to all other instances.
When working with shortcuts to complex types defined in other models, the model containing the complex
type must be open for you to be able to display its children. When the model is open and the children
displayed, you can move them around temporarily in the diagram, but their positions will not be persisted
after you save and close the model.
Complex types and complex type shortcuts and their children are displayed in the Mapping Editor (see
Core Features Guide > Linking and Synchronizing Models > Object Mappings) under each element to which
they are applied, and each instance of the complex type can be mapped independently through generation
(see Generating Other Models from an XSM [page 76]) or manually:
XML Architecture
42 PUBLIC XML Diagrams
2.7 Groups (XSM)
A group of elements is a set of elements arranged by a group particle (all, choice or sequence), which is then
referenced in the model by various elements.
• A group - is created independently, without a parent element, and can be reused multiple times by
elements, complex types or other global groups, through references. In a schema, it is directly linked to the
<schema> tag (root element). See Creating a Group [page 45].
• A reference to a group - is created within an element, complex type or global group, and makes the
referenced group available to its parent. See Creating a Reference to a Group [page 45].
For example:
XML Architecture
XML Diagrams PUBLIC 43
The descriptionLines group is reused in the definition of the product element by clicking the sequence group
particle (S) with the Toolbox Group tool. The Reference property of the referencing group property sheet is then
set to descriptionLines.
In the generated XSD file, the group is first declared with the <group> tag and then reused through a reference
(ref) set to descriptionLines:
• In the generated DTD file, the group is expanded directly within its parent element:
• In the generated XDR file, the group is declared through a <group> tag, within an <ElementType> tag with
its order attribute set to seq:
XML Architecture
44 PUBLIC XML Diagrams
Note
In a model targeted with DTD or XDR language, there are no global or referencing groups, although they
appear on the diagram. Groups are expanded within their parent element and their child elements are
declared individually as global elements. (See generated DTD and XDR files in Groups (XSM) [page 43])
You can create a group from the Toolbox, Browser, or Model menu. Groups are created at the model root to be
referenced by other elements.
For information about creating children under the group, see Constructing Schemas in an XSL [page 22].
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
A reference to a group is created as a child of an element, group or complex type, and makes the referenced
group available to its parent.
• Select the Group tool in the Toolbox, and click on an element, group, or complex type symbol.
• On the Items tab of the property sheet of a group particle, click the Add Reference to Group tool (see Group
Particle Properties [page 36]).
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
XML Architecture
XML Diagrams PUBLIC 45
2.7.3 Group Properties
To view or edit a group's properties, double-click its diagram symbol or Browser or list entry. The property
sheet tabs and fields listed here are those available by default, before any customization of the interface by you
or an administrator.
Property Description
Name/Code/ Identify the object. The name should clearly convey the object's purpose to non-technical users, while
Comment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereotypes
to the list by specifying them in an extension file.
Reference [for references to groups] Specifies the group being referenced. Select a group in the current model
from the list or use the Browse tool to select a group from any model opened in the workspace.
Disables all other properties. To locate the referenced group in the diagram, right-click the referencing
element and select Find Referenced Group.
Group type Specifies that the object has child elements, and how they are used (see Group Particles (XSM) [page
34]). You can choose between:
Minimum Specifies the minimum number of times the object can occur. Enter zero to specify that it is optional.
Maximum Specifies the maximum number of times the object can occur. Select unbounded to specify unlimited
instances.
ID Specifies the ID of the object, which must be unique within the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
An attribute group is a set of attributes, which is referenced in the model by various elements. It is created
independently, without a parent element, and can be reused multiple times by elements, complex types or
XML Architecture
46 PUBLIC XML Diagrams
other global attribute groups, through references. In a schema, it is directly linked to the <schema> tag (root
element). Attribute groups are not supported by XDR.
For example:
The quality attribute group is composed of the guarantee and qualityStandards attributes. The
productA element reuses the quality attribute group via the Attributes tab of its property sheet.
In a schema, a group of attributes is declared with the <attributeGroup> tag and can contain the
<attribute>, <attributeGroup>, and <anyAttribute> tags:
• Generated DTD file:
XML Architecture
XML Diagrams PUBLIC 47
2.8.1 Creating an Attribute Group
You can create an attribute group from the Browser or Model menu. Attribute groups are created at the model
root to be referenced by other elements.
• Select Model Attribute Groups to access the List of Attribute Groups, and click the Add a Row tool.
• Right-click the model or package in the Browser, and select New Attribute Group .
To reference an attribute group, open the property sheet of an element, complex type, or attribute group, click
the Attributes tab, and then click the Add Group with Reference to Group tool (see Element Properties [page
25]).
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit attribute group's properties, double-click its Browser or list entry. The property sheet tabs
and fields listed here are those available by default, before any customization of the interface by you or an
administrator.
Property Description
Name/Code/ Identify the object. The name should clearly convey the object's purpose to non-technical users, while
Comment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereotypes
to the list by specifying them in an extension file.
Reference [for references to attribute groups] Specifies the group being referenced. Select a group in the current
model from the list or use the Browse tool to select a group from any model opened in the workspace.
ID Specifies the ID of the object, which must be unique within the model.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
XML Architecture
48 PUBLIC XML Diagrams
Attributes Tab
This tab lists the attributes and attribute groups associated with the attribute group. For information about the
tools available on this tab, see Creating an Attribute [page 30].
• In a DTD file, Any is declared within an <!ELEMENT> tag with the keyword "ANY":
• In an XDR file, Any is declared through of an <ElementType> tag (resources in the example) with its model
attribute set to "open". Although it is displayed in a diagram, Any is not considered as an object in an XDR
file:
XML Architecture
XML Diagrams PUBLIC 49
2.9.1 Creating an Any Element
You can create an Any element from the Toolbox or from a group particle property sheet.
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit an any element's properties, double-click its diagram symbol or Browser or list entry. The
property sheet tabs and fields listed here are those available by default, before any customization of the
interface by you or an administrator.
Property Description
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Minimum Specifies the minimum number of times the object can occur. Enter zero to specify that it is optional.
Maximum Specifies the maximum number of times the object can occur. Select unbounded to specify unlimited
instances.
ID Specifies the ID of the object, which must be unique within the model.
Namespace Specifies the namespaces containing the elements that can be used. You can enter a white space
delimited list with URI references or choose from:
XML Architecture
50 PUBLIC XML Diagrams
Property Description
Process contents Specifies how an XML processor should handle validation of XML documents containing the elements
specified by the Any element. You can choose from:
• Lax - the processor will try to obtain the schema and validate any element of the specified
namespaces. If the schema cannot be found, no error will occur.
• Skip - the processor will not try to validate the elements.
• Strict - the processor must obtain the schema and validate any element of the specified name-
spaces.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
Constraints indicate that element values must be unique within their specified scope. In a schema, a constraint
is declared with the <unique>, <key>, or <keyRef> tag. Constraints are only available in a model targeted
with XSD.
There are three kinds of identity constraints, each with a selector and field:
• A Unique constraint - specifies that an element or an attribute value (or set of values) must be unique or
null within a specified scope. For example:
Generated schema:
XML Architecture
XML Diagrams PUBLIC 51
The UNIQUENUM unique constraint, defined on the project element, specifies that the numEmployee
attribute must be unique or null within the employee element
• A Key constraint - specifies that an element or an attribute value (or set of values) must be a key within
a specified scope; the data must be unique, not null, and always present within a specified scope. For
example:
Generated schema:
XML Architecture
52 PUBLIC XML Diagrams
The KEYCODE key constraint, defined on the project element, specifies that the code attribute must be
unique, not null and always present within the product element.
• A KeyRef constraint - specifies that an element or attribute value (or set of values) corresponds to the
value of a specified key or unique constraint. A keyRef is a reference to a key or a unique constraint. For
example:
Generated schema:
The KEYREF_UNIGOLD keyRef, defined on the product element, by reference to the UNIGOLD unique
constraint, specifies that the gold attribute must be unique or null within the component_2 element, and
unique or null within the component_1 element.
XML Architecture
XML Diagrams PUBLIC 53
2.10.1 Creating a Constraint
Tool Description
Add Key Constraint - The element value must be a key within the specified scope. The scope of a key is the
containing element in an instance document. A key must be unique, not null, and always present.
Add Unique Constraint - The element value must be unique or null within the specified scope.
Add KeyRef Constraint - The element value corresponds to those of the specified key or unique constraint
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit a constraint's properties, double-click its Browser or list entry. The property sheet tabs and
fields listed here are those available by default, before any customization of the interface by you or an
administrator.
Property Description
Name/Code/ Identify the object. The name should clearly convey the object's purpose to non-technical users, while
Comment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereotypes
to the list by specifying them in an extension file.
ID Specifies the ID of the object, which must be unique within the model.
Reference [keyrefs] Specifies the key or unique constraint being referenced. Select a constraint defined in the
current model (or another model with a specified namespace).
XML Architecture
54 PUBLIC XML Diagrams
Property Description
Selector (XPath) Enter an XPath expression that selects a set of elements across which the values specified in the Fields
tab must be unique. There can only be one selector.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
Fields Tab
The Fields tab lists XPath expressions used to define the constraint. If more than one field is listed, the
combination of fields must be unique.
The XPath expressions permitted to define constraint selectors and fields are limited to a subset of the full
XPath language defined in the W3C Recommendation XML Path Language 1.0:
Syntax Description
/ Root node of the XML document. It is the root element with its ramifications
. Selects the context node. It is the current element (on which an identity
constraint is defined) with its ramifications
employee Selects all the employee child elements of the context node
s:employee Selects all the employee child elements of the context node, defined in the
namespace with the "s" prefix
employee[1] Selects the first employee child element of the context node
employee[last()] Selects the last employee child element of the context node
XML Architecture
XML Diagrams PUBLIC 55
Syntax Description
company//employee Selects the employee descendants of the company child elements of the
context node
//company/employee Selects all the employee elements with company as parent element in the
context node
/book/chapter[2]/section[3] Selects the third section in the second chapter of the book
employee[@dept="doc"] Selects all the employee child elements of the context node with a dept attrib-
ute set to doc
employee[@dept="doc"][3] Selects the third employee child element of the context node with a dept
attribute set to doc
employee[3][@dept="doc"] Selects the third employee child element of the context node only if it has a
dept attribute set to doc
chapter[title] Selects the chapter child elements of the context node with at least one title
child element
chapter[title="About this book"] Selects the chapter child elements of the context node with at least one title
child element with a text content set to About this book
employee[@numEmployee and @dept] Selects all the employee child elements of the context node with the numEm-
ployee and dept attributes
text() Selects all the child nodes of the text context node
The General tab of a selector or field property sheet contains the following properties:
Property Description
XPath For a selector: An XPath expression relative to the parent element being declared. It identifies the child
elements to which the identity applies
For a field: An XPath expression relative to each element selected by the selector of the constraint. It
identifies a single element (with a simple type) whose content or value is used for the constraint
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereotypes
to the list by specifying them in an extension file.
ID Specifies the ID of the object, which must be unique within the model.
XML Architecture
56 PUBLIC XML Diagrams
2.11 Derivations: Extensions, Restrictions, Lists and Unions
(XSM)
You can use derivations to extend or restrict the values of elements and of simple and complex types.
Note
When you define a derivation in an element property sheet, a simple or a complex type is automatically
created within the element declaration (See Preview tab). The Embedded type property is automatically
set to Simple or Complex, and the Content property to Simple or Complex in the case of an embedded
complex type.
You can derive an element or complex type by extension to extend the values of its base type.
Context
For example:
XML Architecture
XML Diagrams PUBLIC 57
The generated schema is the following:
Procedure
1. Open the property sheet of an element or complex type and select Extension in the Derivation list.
The Content field (and, in the case of an element, the Embedded type field) is set to Complex.
2. Click the Properties tool to the right of the Derivation box to open the property sheet of the extension and
complete the following properties:
Property Description
ID ID of the extension. Its value must be of type ID and unique within the model containing the
extension
3. Specify an ID, select a base type, and then click OK to return to the element or complex type.
XML Architecture
58 PUBLIC XML Diagrams
2.11.2 Deriving by Restriction
You can derive an element, simple type, or complex type by restriction to restrict the values of their base type.
Procedure
1. Open the property sheet of an element, simple type, or complex type, and select Restriction in the
Derivation list.
For elements and complex types, the Content field (and, in the case of an element, the Embedded type
field) is set to Complex.
2. Click the Properties tool to the right of the Derivation field to open the restriction property sheet, and
complete the following fields on the General tab:
Property Description
ID ID of the simple type restriction. Its value must be of type ID and unique within the model
containing the simple type restriction
XML Architecture
XML Diagrams PUBLIC 59
Property Description
Base type Data type on which the restriction is based. Select a data type in the Base type list or with the
Browse tool
Embedded type If selected, the base type disappears and a simple type is created in the schema within the
[simple types only] current simple type. Click Apply, and then the Properties tool beside the Embedded type box, to
define a derivation and a base type for the embedded simple type.
3. [optional - simple type restrictions only] Click the Detail tab and enter appropriate facets (constraints on
the set of values of a simple type) for the restriction:
Icon Facet
Length - Exact number of characters or list items allowed. It must be equal to or greater than zero
Whitespace - Way of handling white spaces. You can choose from the following:
• Preserve - white spaces are unchanged.
• Replace - Tabs, line feeds and carriage returns are replaced with spaces.
• Collapse - Contiguous sequences of spaces are collapsed to a single space. Leading and trailing
spaces are removed.
Minimum length - Minimum number of characters or list items allowed. It must be equal to or greater than
zero
Maximum length - Maximum number of characters or list items allowed. It must be equal to or greater
than zero
Minimum exclusive - Lower bound for numeric values. All values are greater than this value
Maximum exclusive - Upper bound for numeric values. All values are lower than this value
Total digits - Exact number of decimal digits allowed. It must be greater than zero
You can optionally click the Properties tool to the right of each field to open the property sheet of the facet
and enter the following properties:
Property Description
ID ID of the facet. Its value must be of type ID and unique within the model containing the facet
XML Architecture
60 PUBLIC XML Diagrams
Property Description
Fixed To prevent a modification of the facet value(s), select the Fixed property
4. [optional - simple type restrictions only] Click the Enumerations tab and enter a set of acceptable values.
Select the F[ixed] check box to prevent the modification of a value.
For example: the meetings simple type, based on the xs:gMonthDay data type, is restricted to the following
dates: 01/20, 03/20, 05/20 and 07/20.
Generated schema:
5. [optional - simple type restrictions only] Click the Patterns tab and enter one or more sequences of
acceptable values. Select the F[ixed] check box to prevent the modification of a value.
XML Architecture
XML Diagrams PUBLIC 61
For example: the zipCode simple type, based on the xs:string data type, is restricted to the following
pattern: two uppercase letters, from A to Z, followed by a five-digit number, each digit ranging from 0 to 9.
Generated schema:
6. Click OK to close the restriction property sheet and return to the element, simple type, or complex type.
You can derive an element or simple type by list to define it as a list of values of a specified data type.
Procedure
1. Open the property sheet of an element or simple type, and select List in the Derivation list.
XML Architecture
62 PUBLIC XML Diagrams
For elements, the Embedded type field is set to Simple.
2. Click the Properties tool to the right of the Derivation box to open the list property sheet and complete the
following properties:
Property Description
ID ID of the simple type list. Its value must be of type ID and unique within the model.
Embedded Type If selected, the type disappears and a simple type is created in the schema within the current
simple type or element. Click Apply, and then the Properties tool beside the Embedded type box, to
define a derivation and a type for the embedded simple type.
3. Click OK to close the list property sheet and return to the element or simple type.
You can derive an element or simple type by union to define it as a collection of built-in and simple data types.
Procedure
1. Open the property sheet of an element or simple type, and select Union in the Derivation list.
Property Description
ID ID of the simple type union. Its value must be of type ID and unique within the model
containing the simple type union.
Member Types White space separated list of built-in data types. Values must be qualified names.
3. [optional] Click the Union Types tab and add appropriate simple types to the union.
4. Click OK to close the union property sheet and return to the element or simple type.
XML Architecture
XML Diagrams PUBLIC 63
2.12 Annotations (XSM)
Annotations allow you to add information about an XSD model. Annotations can be added at the schema level
or on any element or other object within an XML model targeted with XSD.
Creating an Annotation
To create an annotation:
• On the schema element - Open the Items or External Schemas tab in the property sheet of the model,
and click the Add Annotation tool or right-click the model or package in the Browser, and select New
Annotation . You can add documentation and application information as necessary on the Items tab.
• On any other object - Open the Annotations tab and click one of the following tools:
Tool Description
Add Documentation – to contain an URI reference or any well-formed XML content that gives extra
information about XML objects or documents.
Add Application Information - to contain an URI reference or any well-formed XML content that is used
by applications for processing instructions.
Annotation Properties
Property Description
ID [annotation] Specifies the ID of the object, which must be unique within the model.
Source [documentation and application information] Specifies the source of the content as a URI.
Language [documentation] Specifies the language used in the documentation. For example: en, en-GB, en-US,
de, fr.
The Content tab allows you to enter any well-formed XML content and the Preview tab (of the annotation or
parent object) allows you to review the content within the appropriate tags. The following schema annotation
contains a documentation element with well-formed XML content (an extract of a DTD file), and an appinfo
element with a source URI:
XML Architecture
64 PUBLIC XML Diagrams
2.13 Notations (XSM)
Notations allow you to define and process non-XML objects within an XML model.
XML Architecture
XML Diagrams PUBLIC 65
2.13.1 Creating a Notation
• Select Model Notations to access the List of Notations, and click the Add a Row tool.
• Right-click the model or package in the Browser, and select New Notation .
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit a notation's properties, double-click its Browser or list entry. The property sheet tabs and fields
listed here are those available by default, before any customization of the interface by you or an administrator.
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Public URI reference identifying the non-XML object. For example: pictures/gif.
System URI reference identifying the application that will process the non-XML object. For example: user/
local/pictureViewer.
ID ID of the notation. Its value must be of type ID and unique within the model containing the notation.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
Entities enable you to include predefined values, external XML or non-XML files in an XML model targeted with
a DTD.
When an XML processor reads an entity reference in an XML document, it will replace this entity reference by
its value defined in the DTD file of the XML document.
XML Architecture
66 PUBLIC XML Diagrams
An entity reference is the entity name preceded by an ampersand and followed by a semicolon.
In an XML model, you just need to type the name and the value of an entity.
• Select Model Entities to access the List of Entities, and click the Add a Row tool.
• Right-click the model or package in the Browser, and select New Entity .
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit an entity's properties, double-click its diagram symbol or Browser or list entry. The property
sheet tabs and fields listed here are those available by default, before any customization of the interface by you
or an administrator.
Property Description
Name/Code/Com- Identify the object. The name should clearly convey the object's purpose to non-technical users, while
ment the code, which is used for generating code or scripts, may be abbreviated, and should not normally
include spaces. Neither the name nor code should contain colons. You can optionally add a comment
to provide more detailed information about the object. By default the code is generated from the
name by applying the naming conventions specified in the model options. To decouple name-code
synchronization, click to release the = button to the right of the Code field.
XML Architecture
XML Diagrams PUBLIC 67
Property Description
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Value Value of the entity. A string of characters in the case of a predefined value. A URI in the case of an XML
or a non-XML file. For example: http://something.com/pictures/logo.gif.
Public URI reference identifying the non-XML object. For example: pictures/gif.
System URI reference identifying the application that will process the non-XML object. For example: user/
local/pictureViewer.
Notation Used to define and process non-XML objects within an XML model.
Parameter If selected, the entity is parsed within the DTD, and not within the XML document as for a general
entity. A parameter entity allows you to predefine a value within a DTD. This predefined value can then
be easily changed within the DTD.
Keywords Provide a way of loosely grouping objects through tagging. To enter multiple keywords, separate them
with commas.
Import, Include and Redefine allow you to enrich your XML model with external namespaces, schema files or
schema components.
Imports
An import identifies a namespace whose schema components are referenced by the current schema, allowing
you to use components from any schema with different target namespace than the current schema.
XML Architecture
68 PUBLIC XML Diagrams
Includes
An include allows you to include a specified schema file in the target namespace of the current schema,
allowing you to use components from any schema with the same target namespace as the current schema or
with no specified target namespace.
Redefines
A redefine allows you to redefine simple and complex types, groups and attribute groups from an external
schema file in the current schema, allowing you to use components from any schema with the same target
namespace as the current schema or with no specified target namespace.
You can create an import, include, or redefine instruction from the model property sheet or from the Browser
or Model menu.
• Select Model Import , Include, or Redefine to access the relevant list, and click the Add a Row tool.
• Open the External Schemas tab in the property sheet of the model, and click the Add Import, Add Include,
or Add Redefine tool.
XML Architecture
XML Diagrams PUBLIC 69
• Right-click the model or package in the Browser, and select New Import , Include, or Redefine.
For general information about creating objects, see Core Features Guide > Modeling with PowerDesigner >
Objects.
To view or edit an instruction's properties, double-click its Browser or list entry. The property sheet tabs
and fields listed here are those available by default, before any customization of the interface by you or an
administrator.
Property Description
Schema location URI reference for the location of a schema file with an external namespace. You can use the Browse
tool beside the Properties tool to select a schema file among those opened in the current workspace.
For example: ORDER.xsd.
ID ID of the instruction. Its value must be of type ID and unique within the schema containing the
instruction.
Namespace [import only] URI reference for the namespace to import. For example: xml.ordering.
Stereotype Extends the semantics of the object. You can enter a stereotype directly in this field, or add stereo-
types to the list by specifying them in an extension file.
Items Tab
The Items tab, which is available for redefines only, lists the items to be redefined. The following tools are
available:
Tool Description
XML Architecture
70 PUBLIC XML Diagrams
2.16 Business Rules (XSM)
A business rule is a rule that your business follows. It is a written statement specifying what an information
system must do or how it must be structured. It could be a government-imposed law, a customer requirement,
or an internal guideline.
You can attach business rules to your model objects to guide and document the creation of your model. For
example, the rule "an employee belongs to only one division" can help you graphically build the link between an
employee and a division.
For more information, see Core Features Guide > Modeling with PowerDesigner > Objects > Business Rules.
XML Architecture
XML Diagrams PUBLIC 71
3 Generating and Reverse Engineering XML
Schemas and Other Models
PowerDesigner supports the generation and reverse-engineering of XML Schema Definition files (.XSD),
Document Type Definition files (.DTD) and XML-Data Reduced files (.XDR). You can also generate a physical
data model (PDM) from an XSM or generate an XSM from a PDM
PowerDesigner provides a standard interface for generating all the supported XML schemas.
Context
Note
Parameter entities are references to predefined values within a DTD
file (See Parameter property in entity property sheet). During DTD
generation, some object properties containing inadvertently parameter
values will be generated with parameter references. If you are not satis-
fied with this default use of parameter entities, you should clear the
Parameter property before generation.
You can preview the file to be generated by selecting the Preview tab of your XML model property sheet (see
Previewing XML Code [page 11]).
Note
The PowerDesigner generation system is extremely customizable through the use of extensions (see
Extending your Modeling Environment [page 16]). For detailed information about customizing generation,
including adding generation targets, options, and tasks, see Customizing and Extending PowerDesigner >
Extension Files .
XML Architecture
72 PUBLIC Generating and Reverse Engineering XML Schemas and Other Models
Procedure
2. Enter a directory in which to generate the files and specify whether you want to perform a model check. For
more information about checking your model, see Checking an XSM [page 79].
Note
When generating an XDR file, the Generation dialog contains an Options tab, where you can specify
whether or not to generate comments (within a <description> tag). This option is enabled by default.
A Progress box is displayed. The Result list displays the files that you can edit. The result is also displayed
in the Generation tab of the Output window, located in the bottom part of the main window.
4. Click Edit to edit the XSD, DTD or XDR file in your associated editor:
XML Architecture
Generating and Reverse Engineering XML Schemas and Other Models PUBLIC 73
3.2 Reverse Engineering an XML Schema into an XSM
Reverse engineering is the process of extracting an XML structure from an XML schema file into an XSM. You
can reverse engineer XML schema files to create a new XSM or to add objects to an existing XSM.
Context
Note
PowerDesigner uses parser software developed by the Apache Software Foundation (http://
www.apache.org ) for XML reverse engineering.
Procedure
1. To reverse engineer a schema and create a new XSM, select File Reverse Engineer XML Definition
to open the New XML Model dialog box. Specify a model name, choose an XML language from the list, and
then click OK.
Note
If your reverse-engineering will create multiple connected XSM models due to import and include
statements, you may first want to create an empty project ( File New Project ) and reverse-
engineer your files into the project, which will act as a container for the files and allow you to check
them into and out of the repository as a single unit.
or
To reverse engineer a schema into an existing XSM, open the model and select Language Reverse
Engineer <schema> File .
2. When the Reverse Engineering dialog opens, select the file or enter the URL you want to reverse-engineer
(which can be of any type accessible via a browser except for ftp), and select any appropriate options:
Option Description
Show symbols Creates symbols for the reversed objects in the diagram. You can specify to expand all the nodes,
and to display elements, groups, and complex and simple types.
Convert unique Transforms global objects that are referenced only once in the model into child objects. You can
references to ele- perform this conversion at any time by selecting Tools Convert Unique References in the
ments XML model.
XML Architecture
74 PUBLIC Generating and Reverse Engineering XML Schemas and Other Models
3. [XSD only] If the schema contains Import or Include elements, the schema files referenced are listed in
a tree format in the dialog. Files not found display a red overlay. For each file in the tree (including those
which are found), you can click on it to :
• In the File or URL field, change the value to an appropriate local path or valid URL path.
• In the File or URL field, browse to and select an XSM open in the workspace to stand in for the
referenced file.
4. When you have resolved all references and are satisfied, click OK to begin reverse engineering.
If you are reverse engineering to an existing XSM, then the Merge Models dialog box opens to allow
you to control the merging of the new objects into your XSM (see Core Features Guide > Modeling with
PowerDesigner > Comparing and Merging Models).
When the process is complete, a confirmation message is given in the Output window. The principal XML
file is created, and a separate XSM is created for each file that is included or imported. Each import and
include is created as an object in the appropriate model (see Instructions: Import, Include and Redefine
(XSM) [page 68]), and shortcuts are created to reference the elements, types, or other objects defined in
the imported or included schemas.
XML Architecture
Generating and Reverse Engineering XML Schemas and Other Models PUBLIC 75
3.3 Generating Other Models from an XSM
You can generate physical data models (PDMs) and other XSMs from an XSM.
Procedure
1. Select Tools, and then one of the following commands to open the appropriate Model Generation Options
window:
• Generate Physical Data Model... Ctrl+Shift+P
• Generate XML Model... Ctrl+Shift+M
2. On the General tab, select a radio button to generate a new or update an existing model, and complete the
appropriate options.
3. [optional] Click the Detail tab and set any appropriate options. We recommend that you select the Check
model checkbox to check the model for errors and warnings before generation.
4. [optional] Click the Target Models tab and specify the target models for any generated shortcuts.
5. [optional] Click the Selection tab and select or deselect objects to generate.
6. Click OK to begin generation.
Note
For detailed information model generation, see Core Features Guide > Linking and Synchronizing
Models > Generating Models and Model Objects.
XML Architecture
76 PUBLIC Generating and Reverse Engineering XML Schemas and Other Models
Results
The following table details how XSM objects are generated to PDM objects:
XSM PDM
Note
Root elements with a primitive or simple type are not generated except where they are
referenced by other elements or complex types.
If you have a single root element and want to generate its immediate children as tables,
select the Skip single root element option on the PDM Generation Options window Detail
tab.
Simple types Domains. The datatype of the domain depends on the derivation of the simple type:
If the complex type is the restriction or extension of a simple type it will be generated as a
column called Value linked to the domain generated from the simple type.
Attributes Columns with datatypes determined by resolving any derivation. Attributes and attribute
groups defined at the model level are not generated except where they are referenced.
Note
References, substitutions, imports, and includes are always resolved, and attributes and attribute groups
defined at the model level are generated only where they are used. Notations, redefines, anys, and (for
DTDs) entities, are not generated to PDMs. To view the mappings between your XML objects and the
XML Architecture
Generating and Reverse Engineering XML Schemas and Other Models PUBLIC 77
objects generated from them, open the Mapping Editor from the generated model (see Core Features Guide
> Linking and Synchronizing Models > Object Mappings).
XML Architecture
78 PUBLIC Generating and Reverse Engineering XML Schemas and Other Models
4 Checking an XSM
The XML model is a very flexible tool, which allows you quickly to develop your model without constraints. You
can check the validity of your XSM at any time.
Note
We recommend that you check your XML model before generating an XML document or another model
from it . If the check encounters errors, generation will be stopped. The Check model option is enabled by
default in the Generation dialog box.
• Press F4, or
• Select Tools Check Model , or
• Right-click the diagram background and select Check Model from the contextual menu
The Check Model Parameters dialog opens, allowing you to specify the kinds of checks to perform, and the
objects to apply them to. The following sections document the XSM-specific checks available by default. For
information about checks made on generic objects available in all model types and for detailed information
about using the Check Model Parameters dialog, see Core Features Guide > Modeling with PowerDesigner >
Objects > Checking Models .
PowerDesigner provides default model checks to verify the validity of group articles.
Existence of particle A group particle must contain elements, groups, group particles and/or Any.
XML Architecture
Checking an XSM PUBLIC 79
Check Description and Correction
Invalid cardinality You should define a minimum (0 or 1) and a maximum cardinality (1 or unbounded) for a group
particle occurrence.
• Manual correction: Double-click the group particle symbol and type a value for Minimum (0 or
1) and Maximum (1 or unbounded) properties
• Automatic correction: None
PowerDesigner provides default model checks to verify the validity of models built on a schema.
Identifier uniqueness Two or more objects cannot have the same identifier (ID).
Undefined identifier You must define an identifier (ID) for each object in the model.
Shortcut code unique- Two shortcuts with the same code cannot be in the same namespace.
ness
• Manual correction: Change the code of one of the shortcuts
• Automatic correction: None
Missing namespaces There should be at least one namespace defined for the model.
• Manual correction: Type a URI and a prefix in the Namespaces tab of the model property
sheet
• Automatic correction: Adds the target namespace URI and a prefix "ns" followed by a number
(e.g. "ns1")
XML Architecture
80 PUBLIC Checking an XSM
4.3 Data Source Checks
PowerDesigner provides default model checks to verify the validity of data sources.
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
Existence of model A data source must have at least one model in its definition.
• Manual correction: Add a model from the Models tab of the data source property sheet
• Automatic correction: Deletes data source without a model
Data source containing The models in a data source represent a single set of information. This is why the models in the
models with different data source should share the same DBMS or object language.
Object Language or
DBMS types
• Manual correction: Delete models with different DBMS or object language, or modify the
DBMS or object language of models in the data source
• Automatic correction: None
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
XML Architecture
Checking an XSM PUBLIC 81
Check Description and Correction
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
Undefined entity You must define an entity. In the entity property sheet, you must either type a value (string of
characters or URI) in the Value box, or a URI in the Public or System boxes.
• Manual correction: Type a value in the Value box or a URI in the Public or System boxes
• Automatic correction: None
Undefined schema lo- You must define a schema location for an include.
cation
• Manual correction: Define a URI or select a schema file for the schema location. For example:
proforma.xsd
• Automatic correction: None
PowerDesigner provides default model checks to verify the validity of simple types.
Name/Code contains terms not in [if glossary enabled] Names and codes must contain only approved terms drawn
glossary from the glossary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
XML Architecture
82 PUBLIC Checking an XSM
Check Description and Correction
Name/Code contains synonyms of [if glossary enabled] Names and codes must not contain synonyms of glossary
glossary terms terms.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: Replaces synonyms with their associated glossary terms.
PowerDesigner provides default model checks to verify the validity of complex types.
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
Existence of particle A complex type must contain elements, groups, group particles and/or Any.
• Manual correction: Add items to the complex type or delete complex type
• Automatic correction: None
XML Architecture
Checking an XSM PUBLIC 83
4.8 Element Checks
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
Undefined type An element without a reference should have a defined data type.
• Manual correction: In the element property sheet, define a data type with the Type list or the
Browse tool
• Automatic correction: None
Undefined reference An element without a defined data type must have a reference.
• Manual correction: In the element property sheet, define a reference with the Reference list or
the Browse tool
• Automatic correction: None
Existence of attribute An element without a reference, a data type or a substitution group should have at least one
attribute.
Existence of particle An element with an embedded complex type must contain child elements, groups, group particles
and/or Any.
XML Architecture
84 PUBLIC Checking an XSM
Check Description and Correction
Invalid cardinality [only available for model targeted with XDR] You should define a minimum (0 or 1) and a maxi-
mum cardinality (1 or unbounded) for a group particle occurrence.
• Manual correction: Double-click the group particle symbol and type a value for Minimum (0 or
1) and Maximum (1 or unbounded) properties
• Automatic correction: None
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
• Manual correction: In the group property sheet, define a reference with the Reference list or
the Browse tool
• Automatic correction: None
Existence of group par- A group must contain elements, groups, group particles and/or Any.
ticle
• Manual correction: Add items to group or delete group
• Automatic correction: None
XML Architecture
Checking an XSM PUBLIC 85
Check Description and Correction
Invalid cardinality [only available for model targeted with XDR] You should define a minimum (0 or 1) and a maxi-
mum cardinality (1 or unbounded) for a group particle occurrence.
• Manual correction: Double-click the group particle symbol and type a value for Minimum (0 or
1) and Maximum (1 or unbounded) properties
• Automatic correction: None
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
• Manual correction: In the attribute property sheet, define a reference with the Reference list
or the Browse tool
• Automatic correction: None
• Manual correction: In the attribute property sheet, define a data type with the Type list or the
Browse tool
• Automatic correction: None
XML Architecture
86 PUBLIC Checking an XSM
4.11 Notation Checks
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
Undefined notation A notation must have at least one URI defined for Public or System properties.
• Manual correction: In the notation property sheet, define a URI in the Public or System boxes
• Automatic correction: None
PowerDesigner provides default model checks to verify the validity of attribute groups.
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
XML Architecture
Checking an XSM PUBLIC 87
Check Description and Correction
Undefined reference An attribute group without a name or a code must have a reference.
• Manual correction: In the attribute group property sheet, define a reference with the Refer-
ence list or the Browse tool
• Automatic correction: None
Undefined schema lo- An import must have at least a schema location or a namespace defined.
cation and namespace
• Manual correction: In the import property sheet, define a URI for the schema location and/or
the namespace.
• Automatic correction: None
Undefined schema lo- You must define a schema location for a redefine.
cation
• Manual correction: In the redefine property sheet, define a URI or select a schema file for the
schema location. For example: customers.xsd
• Automatic correction: None
XML Architecture
88 PUBLIC Checking an XSM
Check Description and Correction
Existence of compo- A redefine must contain at least one of the following items: simple type, complex type, group or
nent attribute group.
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
• Manual correction: Add at least one field to the key or delete the key. For example: @numEm-
ployee
• Automatic correction: Deletes unassigned key
Undefined selector You must define an XPath expression for a key selector attribute.
• Manual correction: In the key property sheet, define an XPath expression for the selector
attribute. For example: s:company/s:employee
• Automatic correction: None
For more information on XPath expressions, see Constraint Properties [page 54].
XML Architecture
Checking an XSM PUBLIC 89
4.16 KeyRef Checks
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
• Manual correction: In the keyRef property sheet, define a reference to a key or a unique
constraint with the Reference list.
• Automatic correction: None
• Manual correction: Add at least one field to the keyRef or delete the keyRef. For example:
@numEmployee.
• Automatic correction: Deletes unassigned keyRef.
Undefined selector You must define an XPath expression for a keyRef selector attribute.
• Manual correction: In the keyRef property sheet, define an XPath expression for the selector
attribute. For example: s:company/s:employee.
• Automatic correction: None
For more information on XPath expressions, see Constraint Properties [page 54].
XML Architecture
90 PUBLIC Checking an XSM
4.17 Unique Checks
Name/Code contains [if glossary enabled] Names and codes must contain only approved terms drawn from the glos-
terms not in glossary sary.
• Manual correction: Modify the name or code to contain only glossary terms.
• Automatic correction: None.
Name/Code contains [if glossary enabled] Names and codes must not contain synonyms of glossary terms.
synonyms of glossary
• Manual correction: Modify the name or code to contain only glossary terms.
terms
• Automatic correction: Replaces synonyms with their associated glossary terms.
• Manual correction: Add at least one field to the unique constraint or delete the unique con-
straint. For example: @numEmployee.
• Automatic correction: Deletes unassigned unique constraint.
Undefined Selector You must define an XPath expression for a unique constraint selector attribute.
• Manual correction: In the unique constraint property sheet, define an XPath expression for
the unique constraint selector attribute. For example: s:company/s:employee.
• Automatic correction: None
For more information on XPath expressions, see Constraint Properties [page 54].
XML Architecture
Checking an XSM PUBLIC 91
4.18 Extension Checks
Undefined base type You must define a base type when you derive a complex type by extension.
• Manual correction: In the complex type property sheet, click the Properties tool
beside the Derivation box to display the Extension property sheet and select a
base type with the Base type list or the Browse tool
• Automatic correction: None
Undefined base type You must define a base type when you derive a simple or a complex type by restriction.
• Manual correction: In the simple or complex type property sheet, click the Proper-
ties tool beside the Derivation box to display the Extension property sheet and
select a base type with the Base type list or the Browse tool
• Automatic correction: None
Existence of facet A simple type restriction must have at least one facet defined. Facets are defined in the
Detail, Enumerations and Patterns tabs of a simple type restriction property sheet.
• Manual correction: Define one or more facets in the simple type restriction prop-
erty sheet
• Automatic correction: None
XML Architecture
92 PUBLIC Checking an XSM
4.20 Simple Type List Checks
PowerDesigner provides default model checks to verify the validity of simple types.
Undefined base type You must define a base type when you derive a simple type by list.
• Manual correction: In the simple type property sheet, click the Properties tool
beside the Derivation box to display the simple type list property sheet and
select a data type with the Type list or the Browse tool
• Automatic correction: None
PowerDesigner provides default model checks to verify the validity of simple type unions.
Undefined base type You must define at least two data types when you derive a simple type by union.
• Manual correction: In the simple type property sheet, click the Properties tool beside
the Derivation box to display the simple type union property sheet and type a white
space separated list of at least two data types (qualified names) in the Member types
box
• Automatic correction: None
Existence of items An annotation must contain at least one URI for a Documentation or an Application
Information.
XML Architecture
Checking an XSM PUBLIC 93
5 Working with XML and Databases
Many relational databases now support XML so that you can store or retrieve data through XML files. You can
use an XML model to generate an annotated schema that will allow you to store or retrieve data in such a
database.
Database Mapped XML model Targeted XML language Required XEM file
Microsoft SQL Server 2000 Yes XSD or XDR Microsoft SQL Server
and higher
IBM DB2 v8.1 and higher Yes DTD IBM DB2 DAD
By attaching the SQL/XML extensions to an XML model mapped to a PDM, you can also generate SQL/XML
queries to retrieve data in an XML format, from relational databases supporting SQL/XML.
Note
You can also generate PDM tables from an XML schema. For more information, see Generating Other
Models from an XSM [page 76].
SQL/XML is an XML extension of the Structured Query Language, which allows you to retrieve relational
data using extended SQL syntax, and produce an XML result. You can generate SQL/XML queries for global
elements in your XSM, whatever the targeted XML language (XSD, DTD or XDR).
Context
• XMLELEMENT - to edit an element with a name, a list of attributes (optional) and a list of values (optional)
• XMLATTRIBUTES - to edit a list of attributes with names and values
• XMLAGG - to edit in multiple rows a concatenation of elements, from a single XML value corresponding to a
single column
• XMLCONCAT - to edit in the same row a concatenation of elements, from several XML values
corresponding to several columns
XML Architecture
94 PUBLIC Working with XML and Databases
• XMLFOREST - to edit in the same row a concatenation of elements, from several SQL values corresponding
to several columns. The name and value of a column become the name and value of an element
Caution
The following procedure assumes you have an XML model open in the workspace and mapped to a PDM.
Generated SQL/XML queries cannot be parameterized.
Procedure
1. To enable the SQL/XML extensions in your model, select Model Extensions , click the Attach an
Extension tool, select the SQL/XML file (on the General Purpose tab), and click OK to attach it.
2. Select Tools Generate SQL/XML Queries to open the Generation dialog box.
3. Specify the directory in which to generate the file.
4. Click the Selection tab and specify which of the global elements you want to generate queries from. A
separate file will be generated for each global element selected.
5. Click OK to begin the generation.
The Result dialog box is displayed with the path of the query file selected.
6. Click Edit to open the generated query file in your associated editor:
Microsoft SQL Server is an XML-enabled database server, which supports annotations that can be used on XSD
or XDR files, to map XML data to relational data.
Context
An annotated schema is an XML file that allows you to store or retrieve data in an XML format, from relational
databases supporting XML. An XML model allows you to generate an annotated schema (XSD or XDR) for SQL
Server 2000.
XML Architecture
Working with XML and Databases PUBLIC 95
Procedure
1. Map an XSM to a PDM. You can do this manually or by generating an XSM from a PDM (or a PDM from an
XSM).
2. To enable the Microsoft SQL Server extensions in your model, select Model Extensions , click the
Attach an Extension tool, select the Microsoft SQL Server file (on the XML in Database tab), and click
OK to attach it.
3. [optional] Reinforce the mappings of elements and attributes to tables and columns with extended
attributes:
Note
If the element and attribute names match the table and column names, you do not need to define
extended attributes for XML objects.
Annotation Description
encode When an XML element or attribute is mapped to a SQL Server BLOB column, allows requesting a
reference (URI) to be returned and used later to return BLOB data.
hide Hides the element or attribute specified in the schema in the resulting XML document.
is-constant Creates an XML element that does not map to any table. The element is displayed in the query
output.
key-fields Allows specification of columns that uniquely identify the rows in a table.
limit-field Allows limiting the values that are returned on the basis of a limiting value.
limit-value Allows limiting the values that are returned on the basis of a limiting value.
XML Architecture
96 PUBLIC Working with XML and Databases
Annotation Description
max-depth Allows you to specify depth in recursive relationships that are specified in the schema.
overflow-field Identifies the database column that contains the overflow data.
relationship-child Specifies an element as the child table in a reference (To define only in the child element property
sheet).
relationship-child- Specifies an attribute as the foreign key of a child table in a reference (To define only in the child
key element property sheet).
relationship-pa- Specifies an element as the parent table in a reference (To define only in the child element
rent property sheet).
relationship-pa- Specifies an attribute as the primary key of a parent table in a reference (To define only in the child
rent-key element property sheet).
use-cdata Allows specifying CDATA sections to be used for certain elements in the XML document.
prefix Creates valid XML ID, IDREF, and IDREFS. Prepends the values of ID, IDREF, and IDREFS with a
string.
4. [optional] Click the Preview tab of the model property sheet, to preview the annotated schema.
5. Select Language Generate < schema>File to open the Generation dialog box.
6. Specify the directory in which to generate the file and select the XML in Database target on the Targets tab.
XML Architecture
Working with XML and Databases PUBLIC 97
7. Click OK to begin the generation.
The Result dialog box is displayed with the path of the annotated schema file selected.
8. Click Edit to open the generated annotated schema in your associated editor:
XML Architecture
98 PUBLIC Working with XML and Databases
Note the SQL namespace (with the sql prefix) and the SQL annotations for tables (sql:relation), columns
(sql:field) and reference (sql:relationship).
Oracle 9i2 is a database server with a native XML storage and retrieval technology called Oracle XML DB.
There is no mapping between XML data and relational data. Tables, columns and abstract data types (ADT)
are created from annotated schemas (XSDs). Annotated schemas are XML-coded files, targeted with an XML
language and tagged with specific DBMS annotations, that allow you to store or retrieve data in an XML format,
from relational databases supporting XML.
Context
An XML model allows you to generate an annotated schema (XSD) for Oracle 9i2. Oracle 9i2 uses by default
the name of the XML elements present in the annotated schema to generate SQL objects. You can override the
creation of SQL objects by defining extended attributes for elements, complex types and the XML model.
Procedure
1. To enable the Oracle extensions in your model, select Model Extensions , click the Attach an
Extension tool, select the Oracle XML DB (on the XML in Database tab), and click OK to attach it.
2. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of
elements:
Annotation Description
beanClassname Can be used within element declarations. If the element is based on a global complex-
Type, this name must be identical to the beanClassname value within the complexType
declaration. If a name is specified by the user, the bean generation will generate a bean
class with this name, instead of generating a name from the element name
columnProps Specifies the column storage clause that is inserted into the default CREATE TABLE
statement. It is useful mainly for elements that are mapped to tables, namely top-level
element declarations and out-of-line element declarations
defaultTable Specifies the name of the table into which XML instances of this schema should be
stored. This is most useful in cases when the XML is being inserted from APIs where table
name is not specified (for example, FTP and HTTP)
XML Architecture
Working with XML and Databases PUBLIC 99
Annotation Description
javaClassname Used to specify the name of a Java class that is derived from the corresponding bean
class, to ensure that an object of this class is instantiated during bean access. If a
JavaClassname is not specified, Oracle XML DB will instantiate an object of the bean class
directly
maintainDOM If true, instances of this element are stored so that they retain DOM fidelity on output.
This implies that all comments, processing instructions, namespace declarations, and so
on, are retained in addition to the ordering of elements. If false, the output need not be
guaranteed to have the same DOM behavior as the input
maintainOrder If true, the collection is mapped to a VARRAY. If false, the collection is mapped to a
NESTED TABLE
SQLCollSchema Name of the database user owning the type specified by SQLCollType
SQLCollType Specifies the name of the SQL collection type corresponding to this XML element that
has maxOccurs > 1
SQLInline If true this element is stored inline as an embedded attribute (or a collection if maxOccurs
> 1). If false, a REF (or collection of REFs if maxOccurs > 1) is stored. This attribute will
be forced to false in certain situations (like cyclic references) where SQL will not support
inlining
SQLName Specifies the name of the attribute within the SQL object that maps to this XML element
SQLSchema Name of the database user owning the type specified by SQLType
SQLType Specifies the name of the SQL type corresponding to this XML element declaration
tableProps Specifies the TABLE storage clause that is appended to the default CREATE TABLE state-
ment. This is meaningful mainly for global and out-of-line elements
3. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of
complex types:
Annotation Description
beanClassname Can be used within element declarations. If the element is based on a global complex-
Type, this name must be identical to the beanClassname value within the complexType
declaration. If a name is specified by the user, the bean generation will generate a bean
class with this name, instead of generating a name from the element name
SQLSchema Name of the database user owning the type specified by SQLType
SQLType Specifies the name of the SQL type corresponding to this XML element declaration
4. [optional] Specify the following properties on the Extended Attributes tab of the property sheets of the
model:
XML Architecture
100 PUBLIC Working with XML and Databases
Annotation Description
storeVarrayAsTable If true, the VARRAY is stored as a table (OCT). If false, the VARRAY is
stored in a LOB
The Result dialog box is displayed with the path of the annotated schema file selected.
8. Click Edit to open the generated annotated schema in your associated editor:
XML Architecture
Working with XML and Databases PUBLIC 101
Note the Oracle namespace (with the sql prefix) and annotations for tables (sql:SQLName) and ADTs
(sql:SQLType)
IBM DB2 v8.1 (or higher) is a database server with an add-in for XML storage and retrieval called IBM DB2
Extender. XML data (elements, attributes) are mapped to relational data (tables, columns) through Document
Access Definition files (.DAD).
Context
Xcolumn Column mapping - the Root element is mapped to a table, and its attributes or child elements are
mapped to columns identified by an XPath
Xcollection SQL mapping - the DAD file starts with a SQL statement for the table mapped to the Root
element, and each child element or attribute is mapped to a column or a table name
Xcollection RDB mapping - a Relational Database node, with a table and a column name, is associated with
each attribute or child element of the Root element
An XML model targeted with DTD allows you to generate DAD files for IBM DB2.
Procedure
1. Map an XSM to a PDM. You can do this manually or by generating an XSM from a PDM (or a PDM from an
XSM).
XML Architecture
102 PUBLIC Working with XML and Databases
2. To enable the IBM DB2 DAD extensions in your model, select Model Extensions , click the Attach an
Extension tool, select the IBM DB2 DAD file (on the XML in Database tab), and click OK to attach it..
3. [optional] Set extended attributes on global elements to reinforce their mapping to tables and columns
The following properties are listed on the Extended Attributes tab:
NamespaceNode Text zone where each line describes a namespace couple (name = value). The
separator character is '='
ProcessInstruction A text zone that enables the user to enter some instruction
4. [optional] Click the Preview tab of the Root element property sheet, and select the DB2XMLExtender.DAD
File tab to preview the DAD file. If the DAD File tab is not available, click the Select Generation Targets tool
to select IBM DB2 DAD in the Targets list and click OK.
5. Select Language Generate < schema>File to open the Generation dialog box.
6. Specify the directory in which to generate the file and select the XML in Database target on the Targets tab.
XML Architecture
Working with XML and Databases PUBLIC 103
7. [optional] Click the Options tab, and set any appropriate generation options:
Option Description
Character ending an instruction Character ending instructions in the SQL file for stored procedures
Generates procedures deploy- Generation of a SQL script for stored procedures enabling XML data storage and
ment facilitating XML data retrieval
Path of DAD.dtd Path of the DTD file installed with IBM DB2 Extender and describing the specific
syntax of DAD files
Schema validation Validation tag in the DAD files to check the conformity of DAD files with the DAD
syntax
The Result dialog box is displayed with the path of the generated DAD, DTD and SQL files.
9. Click Edit to open the generated DAD file in your associated editor:
• Extract of a DAD file defined with Xcollection as StorageType, and RDB as MappingType:
XML Architecture
104 PUBLIC Working with XML and Databases
• DAD file defined with Xcolumn as StorageType:
XML Architecture
Working with XML and Databases PUBLIC 105
Important Disclaimers and Legal Information
Hyperlinks
Some links are classified by an icon and/or a mouseover text. These links provide additional information.
About the icons:
• Links with the icon : You are entering a Web site that is not hosted by SAP. By using such links, you agree (unless expressly stated otherwise in your
agreements with SAP) to this:
• The content of the linked-to site is not SAP documentation. You may not infer any product claims against SAP based on this information.
• SAP does not agree or disagree with the content on the linked-to site, nor does SAP warrant the availability and correctness. SAP shall not be liable for any
damages caused by the use of such content unless damages have been caused by SAP's gross negligence or willful misconduct.
• Links with the icon : You are leaving the documentation for that particular SAP product or service and are entering an SAP-hosted Web site. By using
such links, you agree that (unless expressly stated otherwise in your agreements with SAP) you may not infer any product claims against SAP based on this
information.
Example Code
Any software coding and/or code snippets are examples. They are not for productive use. The example code is only intended to better explain and visualize the syntax
and phrasing rules. SAP does not warrant the correctness and completeness of the example code. SAP shall not be liable for errors or damages caused by the use of
example code unless damages have been caused by SAP's gross negligence or willful misconduct.
Bias-Free Language
SAP supports a culture of diversity and inclusion. Whenever possible, we use unbiased language in our documentation to refer to people of all cultures, ethnicities,
genders, and abilities.
XML Architecture
106 PUBLIC Important Disclaimers and Legal Information
XML Architecture
Important Disclaimers and Legal Information PUBLIC 107
www.sap.com/contactsap
SAP and other SAP products and services mentioned herein as well as
their respective logos are trademarks or registered trademarks of SAP
SE (or an SAP affiliate company) in Germany and other countries. All
other product and service names mentioned are the trademarks of their
respective companies.