XML Model User's Guide Sybase® PowerDesigner® 11.
DOCUMENT ID: DC20014-01-1110-01 LAST REVISED: June 2005 Copyright © 1991-2005 Sybase, Inc. All rights reserved. Information in this manual may change without notice and does not represent a commitment on the part of Sybase, Inc. and its subsidiaries. Sybase, Inc. provides the software described in this manual under a Sybase License Agreement. The software may be used only in accordance with the terms of the agreement.
Contents About This Book ............................................................................................ix 1 XML Model Basics..............................................................1 Functional overview .................................................................. 2 What is an XML model? ........................................................... 3 About XML.......................................................................... 4 Objects in an XML model .......................
Defining Any Attribute properties...................................... 61 Defining identity constraints .................................................... 64 Defining a unique constraint............................................. 64 Defining a key constraint .................................................. 66 Defining a keyRef constraint ............................................ 67 Creating an identity constraint..........................................
Defining an include......................................................... 127 Defining a redefine ......................................................... 128 Defining business rules......................................................... 132 What is a business rule? ................................................ 132 Defining business rule properties ................................... 132 Creating a business rule.................................................
Understanding object mapping ...................................... 166 Defining data sources in an XML model ........................ 166 Mapping XML Model objects to PDM objects ................ 169 Mapping XML Model objects to OOM objects................ 171 Creating a mapping for an XML object........................... 172 Modifying the mapping of an attribute ............................ 175 Manipulating XML objects graphically................................... 176 Local objects .....................
5 Exchanging data with databases supporting XML ......215 Why use XML in databases? ................................................ 216 Generating an annotated schema for Microsoft SQL Server 2000 .......................................................................... 217 Mapping XML objects to PDM objects ........................... 217 Reinforcing mapping with extended attributes ............... 225 Generating an annotated schema for Oracle 9i2..................
viii PowerDesigner
About This Book Subject This book describes the PowerDesigner XML Model environment.
About This Book ♦ Object Oriented Model (OOM) to model a software system using an object-oriented approach for Java or other object languages ♦ Business Process Model (BPM) to model the means by which one or more processes are accomplished in operating business practices ♦ XML Model (XSM) to model the structure of an XML file using a DTD or an XML schema ♦ Requirements Model (RQM) to list and document the customer needs that must be satisfied during a development process ♦ Information Liquidity Mod
About This Book Repository Getting Started Repository User’s Guide central repository. Typographic conventions To learn the basics of the Repository. To work in a multi-user environment using a PowerDesigner documentation uses specific typefaces to help you readily identify specific items: ♦ monospace text (normal and bold) Used for: Code samples, commands, compiled functions and files, references to variables. Example: declare user_defined…, the BeforeInsertTrigger template.
About This Book xii PowerDesigner
C H A P T E R 1 XML Model Basics About this chapter Contents XSM User's Guide This chapter presents PowerDesigner XML Model. It provides you with an introduction to the basic notions of XML modeling.
Functional overview Functional overview With the graphical interface and the Browser tree view of PowerDesigner XML Model, you can design an XML diagram which represents the content of an XML Schema Definition file (.XSD), a Document Type Definition file (.DTD) or an XML-Data Reduced file (.XDR). Since XML structures can be very complex, it is much easier to visualize them through comprehensive and explicit diagrams, than to read XML-coded pages.
Chapter 1 XML Model Basics What is an XML model? An XML model is a graphical representation of an XML Schema Definition file (.XSD), a Document Type Definition file (.DTD) or an XML-Data Reduced file (.XDR). With its Browser tree view and diagram, an XML model gives you a global and schematic view of all the elements composing an XSD, a DTD or an XDR file. This is very helpful when you need to understand, check or modify the complex structure of an XSD, a DTD or an XDR file.
What is an XML model? About XML Why use XML? DTD, XSD or XDR The eXtensible Markup Language is used for different reasons: ♦ It describes and structures data, whereas HTML only displays data ♦ It uses a self-describing and personalized syntax ♦ It can be exchanged between incompatible systems, since data is stored in plain text format The structure of an XML model is described by a DTD, an XSD or an XDR file: ♦ A DTD file is a basic way to describe the structure of an XML document.
Chapter 1 XML Model Basics Extract of an XSD file: An XSD file always starts with the tag (root element). All objects created in the model will appear in the XSD file between the schema start-tag and end-tag ♦ An XDR file is a simplified XSD file (or schema). It does not support simple and complex user-defined data types Extract of an XDR file: An XDR file always starts with the tag (root element).
What is an XML model? An XML model is a tree structure of child elements attached to parent elements. Elements are the basic describing items of an XML model. They can be made of other elements combined in different ways through group particles. Elements are specified by attributes and data types which can be predefined or user-defined. Simple and complex data types can be defined as global (directly linked to the tag) or local (embedded in an element declaration).
Chapter 1 XML Model Basics Tool Object Description — Notation A notation is used to define and process nonXML objects within an XML model These tools are available in the palette of the diagram window. The main objects of an XML model are represented by symbols in its diagram. Objects in a diagram Some objects may not appear in a diagram because they do not have a symbol or this symbol has been deleted or hidden. Always check the existence of objects in the Browser tree view.
What is an XML model? How to link a child object to a parent object in an XML model? XML objects do not support standard link objects. To link a child object to a parent object, you must click the child object tool in the palette and then click the symbol of the parent object in the diagram. This will automatically create a link between both objects.
Chapter 1 Tool Sequence symbol Choice symbol XML Model Basics All symbol No link No link No link No link No link All 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.
Defining the XML model environment Defining the XML model environment The XML model environment includes a set of parameters and configuration options that define various aspects of the model content and behavior. You can set these parameters: ♦ At model creation ♦ After creating a model with default options and parameters ♦ When creating a model template Choosing the XML language of an XML model An XML language contains specifications for a particular language.
Chapter 1 XML Model Basics Changing the XML language of an XML model If you change the XML language of an XML model, you have to define the status of the language: XML language Description Share To use the shared XML language stored in the XML Languages directory of your installation. Any changes made to the XML language are available to the linked XML model Copy To create a copy of the XML language in the model.
Defining the XML model environment 4 Click OK. A message box informs you that the current XML language has been changed. 5 Click OK. Changes concerning simple and complex types 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 tag) disappear from the diagram and the Browser tree view.
Chapter 1 XML Model Basics Selecting extended model definitions at model creation Extended model definitions (.XEM files) provide means for customizing and extending PowerDesigner metaclasses, parameters and generation. Extended model definitions are typed like models in PowerDesigner. You create an extended model definition for a specific type of model and you cannot share these files between heterogeneous models.
Defining the XML model environment For more information on extended model definitions, see chapter Extended Model Definitions Reference Guide, in the Advanced User Documentation. Defining model options Name/Code case sensitive You can define the case sensitivity of names and codes for all objects in the current model. When this check box is selected, it implies that you can have two objects with identical name or code but different case in the same namespace.
Chapter 1 XML Model Basics To define XML model options: 1 Select Tools→Model Options. or Right-click the diagram background and select Model Options in the contextual menu. The Model Options dialog box opens to the Model Settings pane. 2 Select or clear the Name/Code case sensitive check box in the All Objects groupbox. 3 Click OK. XML model extended dependencies Extended dependencies are links between objects of an XML model.
Defining the XML model environment You can type stereotypes directly in the Stereotype column of the object property sheet or select a value from the dropdown listbox if you have previously defined stereotypes in an embedded or imported extended model definition (.XEM). For more information on extended model definitions, see chapter Extended Model Definitions Reference Guide in the Advanced User Documentation.
Chapter 1 XML Model Basics Defining an XML model This section presents the main operations you have to perform before starting to build or work on an XML model. Defining model properties The model property sheet displays the definition of the current model. Only the specific pages of an XML model are explained in this section. For information on the generic pages of a model property sheet, see section Using property sheets in chapter Using the PowerDesigner Interface in the General Features Guide.
Defining an XML model If you want to display the XML language, click the Properties tool beside the XML language box in the General page to display the property sheet of the XML language. 3 Click OK.
Chapter 1 XML Model Basics Model Detail page The Detail page of a model property sheet (only available in a model targeted with XSD) displays the following properties: Property Description Target Namespace Namespace of all the model objects. Its name is a URI which does not refer to any file but only to an assigned name. A prefix can be assigned to the namespace. All the schema elements with this prefix in their start-tag will be associated with the namespace. For example: http://www.mycompany.
Defining an XML model Model Items page The Items page of the model property sheet displays the list of global objects (with no parent symbol in the diagram, directly linked to the tag) created in the model. This list reflects the order in which global objects are being declared in the schema.
Chapter 1 Tool XML Model Basics Tooltip Description Add Annotation Adds an annotation to the model, to provide documentation or application information. Only available in a model targeted with XSD For more information on these items, see chapter Building an XML model. Model External Schemas page A schema is an XML-written text defining the content and structure of an XML document. An XML model is a graphic representation of a schema.
Defining an XML model Model Namespaces page A namespace is a URI indicating a location where objects are declared. The prefix of a namespace, followed by a colon (:) and the name of an object, indicates that this object is declared in that namespace. Namespaces are not supported by DTDs. You can use the following tools to attach namespaces from other models or schema files to the current model: Tool ♦ 22 Tooltip Description Add Namespaces from XML Models Adds namespaces of other XML models.
Chapter 1 ♦ XSM User's Guide XML Model Basics In the case of a model targeted with XDR, two namespaces are predefined in the list of namespaces.
Defining an XML model Model Preview page The Preview page of the model property sheet displays a preview of the XSD, DTD or XDR file generated from the XML model. Example of an XSD file (or schema file): The schema file starts with the XML declaration followed by the (root element) declaration. All objects created in the model will appear in the schema file between the schema start-tag and end-tag.
Chapter 1 XML Model Basics Creating an XML model using the New model option When you create a new XML model using the New model option, you have to select an XML language. You can then select one of the following options: Option Description Share To use the shared XML language stored in the XML Languages directory of your installation. Any changes made to the XML language are available to the linked XML model Copy To create a copy of the XML language in the model.
Defining an XML model 6 If you want to attach one or more extended model definitions to the model, click the Extended Model Definitions tab, and select the extended model definitions of your choice. For more information on attaching extended model definitions to a model, see section Selecting extended model definitions at model creation. 7 Click OK. A new XML model is created in the Workspace. 8 Select Model→Model Properties.
Chapter 1 XML Model Basics Creating an XML model using the New model from template option To create a new XML model using the New model from template option: 1 Select File→New to display the New dialog box. 2 Select XML Model in the list of model types. 3 Select the New model from template radio button in the upper right part of the dialog box to display the Template page. 4 Select a model template from the list.
Defining an XML model Opening an existing XML model An XML model has the file extension .XSM. Choose XML language If PowerDesigner cannot find the XML language attached to the XML model you want to open, the Choose XML Language dialog box appears to let you select another XML language to attach to the model. You can select the XML language from the XML language dropdown listbox. To open an existing XML model: 1 Select File→Open. or Click the Open tool. A standard Windows Open file dialog box appears.
Chapter 1 XML Model Basics Saving and closing an XML model Saving an XML model To save an XML model, choose one of the following options: ♦ Select File→Save ♦ Click the Save tool in the standard toolbar ♦ Right-click the XML model in the Browser tree view and select Save in the contextual menu If it is the first time you save an XML model, a standard Windows Save As dialog box appears: Type a file name, choose a folder in your directory and click Save.
Defining an XML model 30 PowerDesigner
C H A P T E R 2 Building an XML model About this chapter Contents XSM User's Guide This chapter describes how to build an XML model (XSM). It explains the role of each object in an XML model and how to create and modify them.
XML diagram basics XML diagram basics You can create XML diagrams in an XML model. Defining an XML diagram An XML diagram is a graphical view of an XML model. The following example shows the diagram of the Resume XML model: The main objects of an XML model are represented by symbols in its diagram.
Chapter 2 Building an XML model Objects in a diagram Some objects may not appear in a diagram because they do not have a symbol or this symbol has been deleted or hidden. Always check the existence of objects in the Browser tree view. 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.
XML diagram basics Creating an XML diagram There are two ways to create an XML diagram: ♦ From a new XML model ♦ From an existing XML model For information on creating an XML diagram from a new XML model, see section Creating an XML model in chapter XML Model Basics. For information on creating an XML diagram from an existing XML model, see section Creating a new diagram in chapter Managing Models in the General Features Guide.
Chapter 2 Building an XML model Defining elements Elements are the basic building blocks of an XML model. An XML model is a tree structure of elements where child elements are attached to parent elements.
Defining elements Generated schema: In a schema, elements are declared with tags. Defining element properties To display an element property sheet, double-click its symbol in a diagram.
Chapter 2 Building an XML model Element general properties There are global and local elements: ♦ Global elements have no parent element in a diagram. They are directly linked to the tag (root element) in a schema. They can be reused in the model through referencing elements (See “XML_declaration” in the Defining elements example) ♦ Local elements have a parent element in a diagram. They are unique within their parent scope.
Defining elements Property Description Reference Name of a global element. The current element will have the same properties as the global element. The Reference property is only available for child elements. Use the dropdown listbox to select a global element in the current model. Use the Browse tool to select a global element from any model opened in the current workspace. If you select a global element from another model, a shortcut is created with the referencing element.
Chapter 2 Building an XML model Defining elements in XDR files In a model targeted with the XML-Data Reduced language, elements are defined by different attributes: XDR attribute for an element XSM User's Guide Description Property or page in element property sheet Model To specify if a global element can contain new local elements. Set to closed by default. Set to open if an Any symbol is attached to the element symbol — Content To specify the content of a global element.
Defining elements Example of an XDR file: Element detail properties The Detail page of an element property sheet displays the following properties: 40 Property Description Minimum Minimum number of times the element can occur. To specify that the element is optional, set this attribute to zero Maximum Maximum number of times the element can occur. For an unlimited number of times, select unbounded Substitution group Name of a global element for which the current element can be substituted.
Chapter 2 Building an XML model Property Description Nillable Property defining if the element is null or not In the case of a model targeted with XDR, the Detail page is only available for local elements. Element attributes properties Attributes give additional information about an element.
Defining elements Element constraints properties Identity constraints allow you to indicate that element values must be unique within their specified scope. You can use the Constraints page of an element property sheet to add the following constraints to an element declaration: Tool Tooltip Description 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.
Chapter 2 Building an XML model Attributes Mapping page The Attributes Mapping page allows you to define the mapping between PDM columns or OOM class attributes and the element attributes. Tool Tooltip Description Add Mapping Use this tool to select the attributes in the current element that will be mapped to PDM columns or OOM class attributes.
Defining elements 3 Click the Pointer tool in the palette. or Right-click to recover the Pointer. 4 Double-click the element symbol in the diagram. The element property sheet appears. 5 Type a name and a code for the element. 6 Select a data type for the element. You can use the Type dropdown listbox or the Browse tool. 7 Click OK. The element symbol appears in the diagram, with its data type (between brackets) right under its name.
Chapter 2 Building an XML model How to link a child object to an element? XML objects do not support standard link objects. To link a child object to an element, you must click the child object tool in the palette and then click the element symbol in the diagram. This will automatically create a link between both objects.
Defining elements Tool Action If you click an element symbol with the Complex Type tool, a complex type symbol appears superposed, but not linked, to the element symbol.
Chapter 2 Building an XML model For example: Generated schema: In a schema, attributes are declared with tags.
Defining elements Attribute general properties There are global and local attributes: ♦ Global attributes are defined with the Model menu. In a schema, they are directly linked to the 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.
Chapter 2 Building an XML model Defining attributes in XDR files Property Description Reference Name of an attribute in the current model or another model opened in the workspace. A reference allows you to reuse an attribute with all its properties without having to define it again. Use the dropdown listbox to select an attribute in the current model. Use the Browse tool to select an attribute from any model opened in the workspace.
Defining elements Example of an XDR file: Attribute detail properties The Detail page of an attribute property sheet displays the following properties: Property Description Default Default value. Enter a default value only if there is no fixed value Fixed Fixed value. Enter a fixed value only if there is no default value Use Indicator of how the attribute is used. If you select Optional, the attribute is optional and may have any value. If you select Prohibited, the attribute cannot be used.
Chapter 2 Building an XML model Element values with XDR In a model targeted with the XML-Data Reduced language, there is also a Values page in the element property sheet. Adding an attribute to an element To add an attribute to an element: 1 Double-click the element symbol in the diagram. The element property sheet appears. XSM User's Guide 2 Click the Attributes tab to display the Attributes page. 3 Click the Add Attribute tool to add an attribute to the list. or Click an empty row in the list.
Defining elements The element symbol appears in the diagram with the attribute name. In the example, indicates that no data type has been defined for the attribute.
Chapter 2 Building an XML model Child elements are linked to their parent element through a group particle. Defining group particles Group particles indicate how child elements are related with their parent element.
Defining elements Group particles properties To display a group particle property sheet, double-click its symbol in a diagram. General properties Items list The General page of a group particle property sheet displays the following properties: Property Description Type Type of the group particle. You can change its type by selecting a value in the dropdown listbox and clicking OK Minimum Minimum number of times the group particle can occur.
Chapter 2 Building an XML model You can access directly to the Items page of a group particle property sheet through the contextual menu. Right-click a group particle symbol in the diagram and select Items in the contextual menu. Creating a group particle There are different ways to create a group particle. From an element property sheet The same procedure applies for groups and complex types.
Defining elements 7 Click OK. The group particle symbol appears selected, with an Expand tab on its right side. 8 Click an empty space in the diagram, to deselect the group particle symbol, and click the Expand tab to reveal the child element symbols and their link. Name and code uniqueness To respect the name and code uniqueness within a namespace, child elements are defined within an internal namespace which is their parent element.
Chapter 2 Building an XML model The child elements appear one by one in the diagram, linked to the group particle symbol. 5 Right-click to recover the Pointer. Clicking an element symbol with the Element tool When you click an element symbol with the Element tool, a sequence symbol (by default) appears in the diagram between the parent element and the child element. To add other child elements, click the sequence symbol with the Element tool.
Defining elements Tool Sequence symbol Choice symbol A referencing group is created. You must now select a group for the reference A referencing group is created. You must now select a group for the reference No link No link All symbol No link No link No link No link No link No link No link All Pointer indications When you cannot click a symbol or an empty space in a diagram, the Pointer displays a forbidden sign (See complex type in Tool column).
Chapter 2 Building an XML model ♦ Generated XSD file: In an XSD file, Any is declared with the tag. ♦ Generated DTD file: In a DTD file, Any is declared within an tag with the keyword “ANY”. ♦ Generated XDR file: In an XDR file, Any is declared through of an tag (resources in the example) with its model attribute set to “open”. Although it appears in a diagram, Any is not considered as an object in an XDR file.
Defining elements Property Description ID ID of the Any. Its value must be of type ID and unique within the model containing the Any. Only available in a model targeted with XSD Namespace Namespaces containing the objects that can be used. If you select ##any, objects from any namespace can be used. If you select ##other, objects from any namespace other than the target namespace of the schema can be used. If you select ##local, objects that are not qualified with a namespace can be used.
Chapter 2 Building an XML model 5 Define the Any properties in the different pages of the property sheet. 6 Click OK. Modifying the Any display preference You can modify the Stereotype display preference for Any by selecting Tools→Display Preferences. Defining Any Attribute properties The Any Attribute feature allows you to insert any attribute of specified namespaces into an element, a complex type or an attribute group declaration. It is only available in a model targeted with XSD.
Defining elements For example: Caution Any Attribute only appears in a schema (see the Preview page of a model property sheet). The Any Attribute feature is available via a check box in the bottom-left corner of an Attributes page. To display an Any Attribute property sheet, select the Any Attribute check box and then click the Properties tool.
Chapter 2 Building an XML model Any Attribute general properties The General page of an Any Attribute property sheet displays the following properties: XSM User's Guide Property Description ID ID of the Any Attribute. Its value must be of type ID and unique within the model containing the Any Attribute Namespace Namespaces containing the attributes that can be used. If you select ##any, attributes from any namespace can be used.
Defining identity constraints Defining identity constraints Identity constraints enable you to indicate that element values must be unique within their specified scope. There are three kinds of identity constraints: unique, key and keyRef. Each identity constraint has two specific attributes: selector and field. In a schema, an identity constraint is declared with its corresponding tag: , or . Identity constraints are only available in a model targeted with XSD.
Chapter 2 Building an XML model The UNIQUENUM unique constraint, defined on the project element, specifies that the numEmployee attribute must be unique or null within the employee element To display a unique property sheet, double-click its name or its icon in the Browser tree view. Unique general properties The General page of a unique property sheet displays the following properties: Property Description Name Name of the unique constraint.
Defining identity constraints Defining a key constraint A key constraint specifies that an element or an attribute value (or set of values) must be a key within a specified scope. A key means that data should be unique, not null and always present within a specified scope. For example: Generated schema: 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.
Chapter 2 Building an XML model Key general properties The General page of a key property sheet displays the following properties: Property Description Name Name of the key constraint. It must be a no-colon-name (See Glossary) Code Code of the key constraint. It must be a no-colon-name Comment Descriptive label of the key constraint Stereotype Sub-classification used to extend the semantics of an object without changing its structure.
Defining identity constraints 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, as well as it must be unique or null within the component_1 element (See UNIGOLD). To display a keyRef property sheet, double-click its name or its icon in the Browser tree view.
Chapter 2 Building an XML model KeyRef general properties The General page of a keyRef property sheet displays the following properties: Property Description Name Name of the keyRef constraint. It must be a no-colon-name (See Glossary) Code Code of the keyRef constraint. It must be a no-colon-name Comment Descriptive label of the keyRef constraint Stereotype Sub-classification used to extend the semantics of an object without changing its structure.
Defining identity constraints To create an identity constraint from an element property sheet: 1 Click the Constraints tab of an element property sheet. 2 Click the Add Unique, Add Key or Add KeyRef Constraint tool in the Constraints page. An identity constraint appears in the list with predefined name and code (a unique constraint in the example). 3 Modify the name and the code of the identity constraint. 4 Click OK.
Chapter 2 Building an XML model XPath abbreviated syntax You can use the following abbreviated syntax to define an XPath expression: XSM User's Guide 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 ..
Defining identity constraints Syntax Description /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 attribute 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 ch
Chapter 2 Building an XML model 2 Click Apply. 3 Click the Properties tool beside the XPath box. The selector property sheet appears. 4 Define the selector properties in the different pages of the property sheet. 5 Click OK. Defining an identity constraint field The Fields page of an identity constraint lets you type one or more XPath expressions to specify the values used to define an identity constraint (unique, key or keyRef).
Defining identity constraints Defining field general properties The General page of a field property sheet displays the following properties: Property Description XPath An XPath expression relative to each element selected by the selector of the identity constraint. It identifies a single element (with a simple type) whose content or value is used for the identity constraint Stereotype Sub-classification used to extend the semantics of an object without changing its structure.
Chapter 2 Building an XML model The field property sheet appears. XSM User's Guide 6 Define the field properties in the different pages of the property sheet. 7 Click OK.
Defining groups Defining groups You can define groups of elements or attributes in an XML model. Defining a group of elements A group of elements is a set of elements arranged by a group particle (all, choice or sequence). You create a group of elements when you need to reuse a set of elements in several parts of your model. Once you have defined a group, you can reuse it elsewhere in the model through referencing groups (see Reference property in Group property sheet).
Chapter 2 Building an XML model ♦ In the generated XSD file, the group is first declared with the 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 tag, within an tag with its order attribute set to seq: Defining group properties There are global and referencing groups: ♦ XSM User's Guide Global groups a
Defining groups ♦ Referencing groups are created in a diagram within an element, a complex type or a global group. You must select a global group for their Reference property (See the following table) Groups in DTD and XDR files 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.
Chapter 2 Building an XML model Once you have defined the reference of a referencing group, you can locate the referenced group in the diagram by right-clicking the referencing group symbol and selecting Find Referenced Group in the contextual menu. The referenced group appears with handles in the diagram. You can access directly to the Preview page of a group property sheet. Rightclick a group (or a referencing group) symbol in the diagram and select Preview in the contextual menu.
Defining groups 5 Type a name and a code for the group. 6 Click OK. 7 Select a group particle tool in the palette (Sequence, Choice or All). 8 Click the group symbol in the diagram. The group particle symbol appears attached to the group symbol. 9 Select the Element tool in the palette. 10 Click the group particle symbol in the diagram for each child element you want to create. The child element symbols appear attached to the group particle symbol.
Chapter 2 Building an XML model How to link a child object to a group of elements? XML objects do not support standard link objects. To link a child object to a group, you must click the child object tool in the palette and then click the group symbol in the diagram. This will automatically create a link between both objects. See the following table for allowed links: Tool Action Result If you click a group symbol with the Element tool, a sequence group particle and a child element symbol are created.
Defining groups Pointer indications When you cannot click a symbol or an empty space in a diagram, the Pointer displays a forbidden sign (See complex type in Tool column). When there is a possibility to create a symbol above, below or next to another one, the Pointer displays an arrow indicating the corresponding direction (See element in Tool column). Modifying the group display preference You can modify the Stereotype display preference for a group by selecting Tools→Display Preferences.
Chapter 2 Building an XML model ♦ Generated XSD file: In a schema, a group of attributes is declared with the tag. It can contain the following tags: , or . ♦ Generated DTD file: Attribute groups are not supported by XDR. Defining attribute group properties To display an attribute group property sheet, double-click its name or its icon in the Browser tree view.
Defining groups The General page of an attribute group property sheet displays the following properties: Attribute group attributes properties Property Description Name Name of the attribute group. It must be a no-colon-name (See Glossary). Required when the attribute group is global Code Code of the attribute group. It must be a no-colon-name.
Chapter 2 Building an XML model Tool Tooltip Description Add Attribute Group with Reference to Attribute Group from a Selection Adds one or several attribute groups with a reference to attribute groups defined in the current model.
Defining groups 3 Type a name and a code for the attribute group. 4 Click OK. 5 Select the Attributes page. 6 Select different tools to add items to the attribute group. 7 Click Apply. 8 Double-click on the left of a row to display an item property sheet. 9 Type a name and a code for the item. 10 Repeat steps 8 and 9 for each item. 11 Click OK.
Chapter 2 Building an XML model Managing external shortcuts through references and data types External shortcuts allow you to share objects between different models. You can define external shortcuts in an XML model, but you cannot use them directly in the model, except as substitution groups for elements (see Detail page in element property sheet). You can define external shortcuts for any global object (with no parent object in the diagram), except for imports, includes, redefines and annotations.
Managing external shortcuts through references and data types Example of shortcuts through a reference and a data type: 88 PowerDesigner
Chapter 2 Building an XML model Defining simple types You can only define simple types in a model targeted with XSD. What is a simple type? A simple type is a data type definition for elements or attributes with textonly content. A simple type cannot contain elements or attributes. A simple type is defined by derivation of an existing simple type (built-in data type or derived simple type).
Defining simple types Defining simple type properties To display a simple type property sheet, double-click its name or its icon in the Browser tree view. The General page of a simple type property sheet displays the following properties: Property Description Name Name of the simple type. It must be a no-colon-name (See Glossary). If specified, it must be unique among all simple types and complex types Code Code of the simple type. It must be a no-colon-name.
Chapter 2 Building an XML model The simple type property sheet appears. 3 Type a name and a code for the simple type. 4 Click OK. The simple type symbol appears in the diagram. Caution If the simple type symbol does not appear in the diagram, select Show Symbols in the Symbol menu, then click the Simple Type tab and select the simple type box to display its symbol in the diagram.
Defining complex types Defining complex types You can only define complex types in a model targeted with XSD. What is a complex type? A complex type is a data type definition used to define attributes and child elements of a parent element. It is a template for a data type definition that can be reused and derived by extension or restriction. A complex type has a global scope when it has no parent element in the diagram and when it is directly linked to the tag.
Chapter 2 Building an XML model Caution Global complex types appear in the model as objects, with their corresponding symbol in the diagram. Local complex types only appear in the schema (see Preview page of an element property sheet). Defining complex type properties To display a complex type property sheet, double-click its symbol in a diagram.
Defining complex types Complex type detail properties The Detail page of a complex type property sheet displays the following properties: Property Description Final Property to prevent derivation of the current complex type Block Property to prevent another complex type with the specified type of derivation from being used in place of the current complex type Mixed If selected, this property indicates that character data is allowed to appear between the child elements of the current complex type.
Chapter 2 Building an XML model Tool Tooltip Description Add Attribute Group with Reference to Attribute Group from a Selection Adds one or several attribute groups with a reference to attribute groups defined in the current model. Select one or several attribute groups in the Selection dialog box Any Attribute Adds any attribute of a specified namespace You can access directly to the Attributes page of a complex type property sheet through the contextual menu.
Defining complex types Icon Tool Description Create from Sources To copy abstract data type attributes or class attributes to the current complex type attributes Generate Mapping To automatically generate a mapping between abstract data type attributes or class attributes and complex type attributes with same name or code in the data source and the current model For more information on complex type mapping, see section Mapping objects in an XML model in chapter Working with an XML model.
Chapter 2 Building an XML model To create a complex type from the palette: 1 Select the Complex Type tool in the palette. 2 Click an empty space in the diagram. A complex type symbol appears in the diagram at the click position. 3 Click the Pointer tool in the palette. or Right-click to recover the Pointer. 4 Double-click the complex type symbol in the diagram. The complex type property sheet appears. 5 Type a name and a code for the complex type. 6 Click OK.
Defining complex types 10 Click the group particle symbol in the diagram for each child element you want to create. The child element symbols appear attached to the group particle symbol. 11 Double-click a child element symbol to display its property sheet. 12 Type a name and a code for the child element. 13 Repeat steps 11 and 12 for each child element. 14 Click OK. How to link a child object to a complex type? XML objects do not support standard link objects.
Chapter 2 Building an XML model Tool Action Result If you click a complex type symbol with the Group tool, a referencing group is created. You can modify the group particle via its property sheet. You must now select a group for the reference If you click a complex type symbol with the Complex Type tool, a second complex type symbol appears superposed, but not linked, to the first complex type symbol.
Defining complex types Defining simple content properties A simple content allows you to extend or restrict the values of a complex type supporting character data or a simple type. It cannot contain elements. Simple content general property The General page of a simple content property sheet allows you to define an id for the simple content. The id value must be of type ID and unique within the model containing the simple content.
Chapter 2 Building an XML model Defining complex content properties A complex content allows you to extend or restrict the values of a complex type with mixed content (character data and elements) or elements only. Complex content general properties The General page of a complex content property sheet displays the following properties: Property Description ID ID for the complex content.
Defining derivations Defining derivations You use derivations when you want to extend or restrict the values of simple and complex types. An XML model allows you to derive: ♦ Simple types by restriction, list or union ♦ Complex types by extension or restriction Derivation in element property sheet 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 page).
Chapter 2 Building an XML model Generated schema: Defining extension general properties The General page of an extension property sheet displays 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 Base Type Data type on which the extension is based To define a derivation by extension: 1 Select Extension in the Derivation dropdown listbox of an element or a complex type property sheet.
Defining derivations 4 Type an ID and select a base type. 5 Click OK. Deriving by restriction You derive a simple type or a complex type by restriction when you want to restrict the values of their base type. Restriction on a simple type The property sheet of a simple type restriction displays several specific pages: ♦ General ♦ Detail ♦ Enumerations ♦ Patterns Detail, Enumerations and Patterns pages are described in the next section, Defining restriction facets.
Chapter 2 Building an XML model Restriction general properties The General page of a simple type restriction property sheet displays the following properties: 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 Base type Data type on which the restriction is based.
Defining derivations Icon Facet Description Fraction digits Maximum number of decimal digits in the fractional part Whitespace Way of handling white spaces. If the value is Preserve, white spaces are unchanged. If the value is Replace, tabs, line feeds and carriage returns are replaced with spaces. If the value is Collapse, contiguous sequences of spaces are collapsed to a single space. Leading and trailing spaces are removed A facet icon appears in the title bar of a facet property sheet.
Chapter 2 Building an XML model 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: Restriction patterns properties The Patterns page of a simple type restriction property sheet allows you to enter the exact sequence of acceptable values for the simple type restriction. Select F (for Fixed) at the end of a row if you want to prevent the modification of a value.
Defining derivations 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: Creating a restriction on a simple type You derive a simple type by restriction when you want to restrict the values of its base type.
Chapter 2 Building an XML model 2 Select Restriction in the dropdown listbox of the Derivation box. 3 Click Apply. 4 Click the Properties tool beside the Derivation box. The restriction property sheet appears. 5 XSM User's Guide Type an ID and a base type for the simple type restriction.
Defining derivations If you select Embedded type, the base type disappears and a simple type is created in the schema within the 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. 6 Click the Detail tab to display the Detail page. 7 Type a value in a facet box. 8 Click Apply. 9 Click the Properties tool beside the facet box.
Chapter 2 Building an XML model 10 Type an ID and select the Fixed box, if needed. 11 Click OK. Enumeration and Pattern facets For Enumeration and Pattern facets, click their corresponding tabs in the restriction property sheet and double-click the arrow left of an enumeration or a pattern value to display its property sheet.
Defining derivations The Content box is set to Complex. 2 Click Apply. 3 Click the Properties tool beside the Derivation box. The restriction property sheet appears. 4 Type an ID and a base type for the complex type restriction. 5 Click OK. Deriving by list You derive a simple type by list when you want to define it as a list of values of a specified data type.
Chapter 2 Building an XML model To define a simple type derivation by list: 1 Select List in the Derivation dropdown listbox of a simple type property sheet. 2 Click Apply. 3 Click the Properties tool beside the Derivation box. The simple type list property sheet appears. 4 Enter an ID and a type for the simple type list. If you select Embedded type, the type disappears and a simple type is created in the schema within the current simple type.
Defining derivations Union general properties Union types properties The General page of a simple type union property sheet displays the following properties: 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.
Chapter 2 Building an XML model Defining annotations You define annotations when you want to add information about an XML model.
Defining annotations This global annotation is composed of a documentation, with a well-formed XML content (extract of a DTD file), and an application information. Annotations are only available in models targeted with XSD. Defining annotation properties To display an annotation property sheet, double-click its name or icon in the Browser tree view. Annotation general property The General page of an annotation property sheet displays the ID of the annotation.
Chapter 2 Building an XML model You can display a documentation property sheet: ♦ By double-clicking its name or icon in the Browser tree view ♦ By double-clicking left of its row in the Items page of an annotation property sheet Documentation general properties The General page of a documentation property sheet displays the following properties: Property Description Source Source of the documentation. It must be a URI reference Language Language used in the documentation.
Defining annotations Application information content The Content page of an application information property sheet allows you to write or paste any well-formed XML content. Creating an annotation You can create a global annotation from the Items page or the External Schemas page of a model property sheet. To create a global annotation from the Items page of a model property sheet: 1 In the Browser tree view, double-click the name or the icon of a model to display its property sheet.
Chapter 2 Building an XML model XSM User's Guide 6 Type an ID for the annotation. 7 Click OK.
Defining notations Defining notations Notations allow you to define and process non-XML objects within an XML model. For example: picture files with a .GIF extension. Generated schema: Notations are not available on models targeted with XDR. Defining notation properties To display a notation property sheet, double-click its name or its icon in the Browser tree view. The General page of a notation property sheet displays the following properties: 120 Property Description Name Name of the notation.
Chapter 2 Building an XML model Creating a notation You can create a notation: ♦ From the Browser tree view ♦ From the List of Notations in the Model menu To create a notation from the Browser tree view: 1 Right-click the name or the icon of the model to display the contextual menu. 2 Select New→Notation in the contextual menu. The notation property sheet appears. XSM User's Guide 3 Type a name, a code and other properties for the notation. 4 Click OK.
Defining entities Defining entities 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. An entity reference is the entity name preceded by an ampersand and followed by a semicolon. For example: &glossary; will be replaced by See Glossary.
Chapter 2 Building an XML model Property Description 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.
Defining entities 124 4 Type a value. 5 Click OK.
Chapter 2 Building an XML model Defining import, include and redefine Import, Include and Redefine allow you to enrich your XML model with external namespaces, schema files or schema components. Import, Include and Redefine are only available in a model targeted with XSD. Defining an import An import identifies a namespace whose schema components are referenced by the current schema. With an import, you can use schema components from any schema with different target namespace than the current schema.
Defining import, include and redefine Property Description Comment Descriptive label of the import Stereotype Sub-classification used to extend the semantics of an object without changing its structure. It can be predefined or userdefined Creating an import You can create an import: ♦ From the Browser tree view ♦ From the List of Imports in the Model menu To create an import from the Browser tree view: 1 Right-click the name or the icon of the model to display the contextual menu.
Chapter 2 Building an XML model Defining an include An include allows you to include a specified schema file in the target namespace of the current schema. With an include, you can use schema components from any schema with the same target namespace as the current schema or with no specified target namespace. In a schema, an include is declared with the tag. For example: Defining include properties To display an include property sheet, double-click its name or its icon in the Browser tree view.
Defining import, include and redefine Creating an include You can create an include: ♦ ♦ From the Browser tree view From the List of Includes in the Model menu To create an include from the Browser tree view: 1 Right-click the name or the icon of the model to display the contextual menu. 2 Select New→Include in the contextual menu. The include property sheet appears. 3 Type a schema location and an ID. 4 Click OK.
Chapter 2 Building an XML model With a redefine, you can use schema components from any schema with the same target namespace as the current schema or with no specified target namespace. In a schema, a redefine is declared with the tag. For example: Defining redefine properties To display a redefine property sheet, double-click its name or its icon in the Browser tree view.
Defining import, include and redefine Redefine items properties The Items page of a redefine property sheet displays a list of items to be redefined.
Chapter 2 Building an XML model XSM User's Guide 3 Define redefine properties in the different pages. 4 Click OK.
Defining business rules Defining business rules You can define business rules in an XML model and attach them to objects. What is a business rule? A business rule is a written statement specifying what an XML model must contain or how it must be structured to support business needs. A business rule is a rule that your business follows. It could be a governmentimposed law, a customer requirement, or an internal guideline. Modeling guides Business rules guide and document the creation of an XML model.
Chapter 2 Building an XML model You can define several types of business rules in an XML model: Type Description Example Constraint Additional check constraint on a value The start date should be inferior to the end date of a project Definition Properties of an element in the XML model A customer is a person identified by a name and an address Fact Certainty, existence in the XML model A client may place one or more orders Formula Calculation used in the XML model The total order is the sum o
Defining business rules To create a business rule from the List of Business Rules: 1 Select Model→Business Rules to display the List of Business Rules. 2 Click the Add a Row tool. or Click a blank line in the list. A rule appears with generic name, code and rule type (Definition, by default). 3 Type a name and a code for the business rule. 4 Click Apply. 5 Double click the arrow at the beginning of the line. The business rule property sheet appears.
Chapter 2 Building an XML model 6 In the General page, select a business rule type in the Type dropdown listbox. 7 Click OK. Applying a business rule to an XML object Once you have defined a business rule in the List of Business Rules, you can apply this business rule to an XML object.
Defining business rules To apply a business rule to an XML object: 1 Double-click an object in the model to display the object property sheet. 2 Click the Rules tab to display the Rules page. 3 Click the Add Rules tool to display the list of business rules. The Selection window appears. It contains a list of all the business rules of the model, with the exception of those that already belong to the object.
Chapter 2 Building an XML model 4 Select the business rules you want to add to the object. 5 Click OK. The business rules are added to the object and appear in the list of business rules for the object. 6 Click OK. U Column in the List of business rules When you apply a business rule to an object, the U (Used) column beside this business rule is automatically checked in the List of business rules to indicate that the business rule is used by at least one object in the model.
Defining business rules 138 PowerDesigner
C H A P T E R 3 Working with an XML model About this chapter This chapter describes how you can work with an XML model and how you can generate an XML model from a PDM or an OOM. When building an XML model, you can check the validity of your model at any time, with the Check Model feature. You can also map XML objects to PDM or OOM objects, merge XML models and edit reports.
Checking an XML model Checking an XML model The XML Model is a very flexible tool. It should allow you to build your model without any controls or constraints on data exchange and consistency of the system. However, you can use the Check Model feature at any time to control the consistency and correctness of the model you are building.
Chapter 3 Working with an XML model These messages represent two different levels of problem severity. You can modify the level of problem severity for each object parameter verified by the Check model. This severity level can depend on the degree of normalization you want to achieve in your model. Automatic correction You can specify if you want PowerDesigner to automatically correct an error using the Automatic Correction feature.
Checking an XML model Checking an XML model You can check the validity of an XML model at any time. To check an XML model: 1 Select Tools→Check Model. or Right-click the diagram background and select Check Model from the contextual menu. The Check Model Parameters dialog box opens to the Options page. 2 Expand an object parameter node. The object parameters verified by the Check Model are displayed with the symbols indicating a degree of problem severity.
Chapter 3 7 Working with an XML model Click an object tab at the bottom of the Selection page. The corresponding object page displays all the objects in the current XML model. 8 Select check boxes only for objects you want to be checked. 9 Clear check boxes for objects that you do not want to be checked. Selecting all or clearing all check boxes You can select all object check boxes by clicking the Select All tool. You can clear all object check boxes by clicking the Deselect All tool. 10 Click OK.
Checking an XML model The Check Model Result List displays errors and warnings based on the check options you have defined. Dockable result window When you right-click an object parameter in the Result List, a contextual menu appears listing correction options. Among these, you can also select options to clear, dock or hide the result window.
Chapter 3 Working with an XML model Making corrections based on XML model check results You use the Check Model feature to locate and correct problems in an XML model.
Checking an XML model Making manual corrections to an XML model Some errors cannot be corrected automatically, they have to be corrected manually. To make manual corrections to an XML model: 1 Select an object parameter from the Result List. 2 Right-click the object parameter and select Correct from the contextual menu to display the object property sheet. 3 Select the appropriate tab and make the necessary correction. 4 Close the property sheet.
Chapter 3 Working with an XML model XML Model objects verified by Check Model The Check Model verifies the validity of XML model objects. When errors are encountered during a check model, corrections can be made manually or automatically. Manual corrections depend on how you are using your model. Some checks are not available if the object is not supported in the model.
XML Model objects verified by Check Model Model check This check only applies to models built on a schema. During a model check, the following object controls are made. Identifier uniqueness Two or more objects cannot have the same identifier (ID). Manual correction Automatic correction Give a unique identifier to each object — Undefined identifier You must define an identifier (ID) for each object in the model.
Chapter 3 Working with an XML model Missing namespaces There should be at least one namespace defined for the model. Manual correction Automatic correction Type a URI and a prefix in the Namespaces page of the model property sheet Adds the target namespace URI and a prefix “ns” followed by a number (e.g. “ns1”) Business rule check in an XSM During a business rule check, the following object controls are made.
XML Model objects verified by Check Model Data source name and code uniqueness There cannot be two data sources with identical names and/or codes in a model. Manual correction Automatic correction Rename one of the data sources Renames the data source by appending a number to its name or code Existence of model A data source must have at least one model in its definition.
Chapter 3 Working with an XML model Embedded file name uniqueness A model cannot contain two embedded files with identical names. Manual correction Automatic correction Rename one of the embedded files Renames the file by appending a number to its name Existence of external file location An external file should have a valid path location. Manual correction Automatic correction Define a valid path location — Entity check During an entity check, the following object controls are made.
XML Model objects verified by Check Model Include check During an include check, the following object control is made. Undefined schema location You must define a schema location for an include. Manual correction Automatic correction Define a URI or select a schema file for the schema location. For example: proforma.xsd — Simple type check During a simple type check, the following object control is made.
Chapter 3 Working with an XML model Existence of attribute A complex type should have at least one attribute. Manual correction Automatic correction Define an attribute for the complex type — Existence of particle A complex type must contain elements, groups, group particles and/or Any. Manual correction Automatic correction Add items to the complex type or delete complex type — Element check During an element check, the following object controls are made.
XML Model objects verified by Check Model Undefined reference An element without a defined data type must have a reference. Manual correction Automatic correction In the element property sheet, define a reference with the Reference dropdown listbox or the Browse tool — Existence of attribute An element without a reference, a data type or a substitution group should have at least one attribute.
Chapter 3 Working with an XML model Group check During a group check, the following object controls are made. Group name and code uniqueness A model cannot contain two groups with identical names and/or codes. Manual correction Automatic correction Rename one of the groups Renames the group by appending a number to its name or code Undefined reference A group without a name or a code must have a reference.
XML Model objects verified by Check Model Attribute check During an attribute check, the following object controls are made. Attribute name and code uniqueness The parent of an attribute cannot contain two attributes with identical names and/or codes. Manual correction Automatic correction Rename one of the attributes Renames the attribute by appending a number to its name or code Undefined reference An attribute without a name or a code must have a reference.
Chapter 3 Working with an XML model Notation name and code uniqueness A model cannot contain two notations with identical names and/or codes. Manual correction Automatic correction Rename one of the notations Renames the notation by appending a number to its name or code Undefined notation A notation must have at least one URI defined for Public or System properties.
XML Model objects verified by Check Model Existence of attributes An attribute group must contain at least one attribute. Manual correction Automatic correction Add attributes to attribute group or delete attribute group Deletes unassigned attribute group Import check During an import check, the following object control is made. Undefined schema location and namespace An import must have at least a schema location or a namespace defined.
Chapter 3 Working with an XML model Existence of component A redefine must contain at least one of the following items: simple type, complex type, group or attribute group. Manual correction Automatic correction Add items to the redefine — Key check During a key check, the following object controls are made. Key name and code uniqueness An element cannot contain two keys with identical names and/or codes.
XML Model objects verified by Check Model For more information on XPath expressions, see section Defining an identity constraint selector in chapter Building an XML model. KeyRef check During a keyRef check, the following object controls are made. KeyRef name and code uniqueness An element cannot contain two keyRefs with identical names and/or codes.
Chapter 3 Working with an XML model Undefined selector You must define an XPath expression for a keyRef selector attribute. Manual correction Automatic correction In the keyRef property sheet, define an XPath expression for the selector attribute. For example: s:company/s:employee — For more information on XPath expressions, see section Defining an identity constraint selector in chapter Building an XML model. Unique check During a unique constraint check, the following object controls are made.
XML Model objects verified by Check Model Undefined Selector You must define an XPath expression for a unique constraint selector attribute. Manual correction Automatic correction In the unique constraint property sheet, define an XPath expression for the unique constraint selector attribute. For example: s:company/s:employee — For more information on XPath expressions, see section Defining an identity constraint selector in chapter Building an XML model.
Chapter 3 Working with an XML model Replication check During a replication check, the following object control is made. Partial object replication A replica object is partially synchronized with its replicated object.
XML Model objects verified by Check Model Undefined base type You must define a base type when you derive a simple or a complex type by restriction. Manual correction Automatic correction In the simple or 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 dropdown listbox or the Browse tool — Existence of facet A simple type restriction must have at least one facet defined.
Chapter 3 Working with an XML model Simple type union check During a simple type union check, the following object control is made. Undefined base type You must define at least two data types when you derive a simple type by union.
Mapping objects in an XML model Mapping objects in an XML model Object mapping is the ability to establish a correspondence between objects belonging to heterogeneous models and diagrams.
Chapter 3 Working with an XML model Data source properties in an XML model To display a data source property sheet, double-click its name or its icon in the Browser tree view.
Mapping objects in an XML model 5 Click the Properties tool to display the data source property sheet. 6 In the General page, select a model type in the Model Type dropdown listbox. 7 In the Models page, click the Add Models tool. A model selection dialog box appears. Select the model(s) for the current data source. 8 Click OK in each of the dialog boxes. The data source appears in the Browser tree view.
Chapter 3 Working with an XML model Mapping XML Model objects to PDM objects You can map elements or complex types and their corresponding attributes to PDM objects.
Mapping objects in an XML model In the Mapping page, you can use the following tools to select a data source for the current element: Tool Description Adds a mapping between the current element and an existing data source. The first time you define a mapping for an element, the Mapping for dropdown listbox is empty.
Chapter 3 Working with an XML model You have to use the Mapping page of a complex type property sheet to define complex type mappings. For more information on how to select a data source, see section Mapping elements. Complex Type Sources page The Complex Type Sources page allows you to associate one or several abstract data types in the data source to the current complex type. You can use the Add Objects tool to select abstract data types from the PDMs opened in the current workspace.
Mapping objects in an XML model For more information on how to select a data source, see section Mapping elements. Element Sources page The Element Sources page allows you to associate one or several classes in the data source to the current element. You can use the Add Objects tool to select classes from the OOMs opened in the current workspace.
Chapter 3 Working with an XML model 2 Select the Mapping tab to display the Mapping page. 3 Click the Add a Mapping for a Data Source tool to select a data source for the mapping. or Select a data source in the Mapping For dropdown listbox if you have already selected one or several data sources. Caution You cannot create a mapping for an XML object if you have not previously defined a data source containing at least one source model.
Mapping objects in an XML model 8 Select the Attributes Mapping tab in the Mapping page. 9 Click the Add Mapping tool to display an attribute selection box. Create From Sources and Generate Mapping tools Click the Create From Sources tool to automatically create attributes from the columns selected in the data source.
Chapter 3 Working with an XML model Modifying the mapping of an attribute You can modify the default mapping created for an attribute. The Attribute Mappings property sheet can be used to fine tune the mapping between an attribute in the current element and columns or attributes in data source tables or classes. In the Mapped To box, you can see the column or attribute expression. By default, columns or attributes used in this expression are prefixed by their tables or classes.
Manipulating XML objects graphically Manipulating XML objects graphically The graphical interface of PowerDesigner allows you to manipulate XML objects within or between the Browser tree view and the diagram window. A global object is right under the model item in the Browser tree view. It has no parent symbol in the diagram. A local object is under a group particle item in the Browser tree view. It has a parent symbol in the diagram.
Chapter 3 Working with an XML model Global objects You can move global objects within or between the Browser tree view and the diagram window. Move Select Tools→General Options to make sure that Move is the Default action of the Drag & Drop option. Within Browser You can move a global object within the Browser to convert it into a local object (under a group particle item), but you cannot move a global object within its own structure (as a child of itself).
Manipulating XML objects graphically If the new global object does not appear in the diagram, select Symbol→Show Symbols and click the corresponding tab to select the object symbol. Example before local to global conversions within the Browser Job is a child element of the Customer element. Nickname is the attribute of the Name element. After conversions Job became Job2, a global element. Nickname became a global attribute.
Chapter 3 Working with an XML model Comparing and merging XML models You can compare and merge two XML models with the same XML language. The comparison process allows you to highlight the differences between two XML models. The merge process allows you to form a single model that combines design efforts performed independently by several team members.
Generating an XML model from a Physical Data Model Generating an XML model from a Physical Data Model This section explains how to generate an XML model from a Physical Data Model. Generating XML Model objects When you generate an XML model from a PDM, PowerDesigner translates PDM objects into specified XML Model objects as follows: PDM object Generated object in an XML model Domain Simple type Table Element.
Chapter 3 Working with an XML model Select Symbol→Show Symbols to reveal the other generated XML Model objects (simple types and complex types). XML model naming conventions If the code of the generated XML Model objects does not correspond to the target language naming conventions, you can define a code naming convention script to convert object names into codes. For more information on conversion scripts, see section .convert_name & .
Generating an XML model from a Physical Data Model Update existing XML model You can generate a PDM into an existing XML model. If you choose to update an existing XML model when the current PDM has never been generated, the Select model dropdown listbox is empty by default. You have to click the Ellipsis button to display the Select a model dialog box in which you can select a model.
Chapter 3 Working with an XML model Option Description Save generation dependencies When selected, PowerDesigner keeps track of the identity of each generated object. It is useful when merging two XML models which have been generated from the same PDM. Objects can be compared and recognized as the same object, even if the object has been modified in the merged XML model Convert names into codes When selected, object codes are generated from names using the corresponding conversion script.
Generating an XML model from a Physical Data Model Generating a new XML model from a PDM You can generate an XML model from a PDM or from a package in a PDM. PowerDesigner creates a new XML model containing all the objects that you selected to generate in the XML model. The newly created XML model appears in the browser and the corresponding diagram opens in the work area. You can only generate an XML model from the active PDM diagram.
Chapter 3 Working with an XML model 5 Click the Detail tab to define options and generation parameters. 6 Click the Target Models tab to select the target models of shortcuts in the current model. 7 Click the Selection tab to display the Selection page. 8 Select the name of a PDM from the Select Location dropdown listbox. Generating an XML model from a package To generate an XML model from a package, select the package name from the dropdown listbox in the upper left corner of the dialog box.
Generating an XML model from a Physical Data Model You can only generate an XML model from the active PDM diagram window. To update an existing XML model by generating from a PDM: 1 Select Tools→Generate XML Model to display the XML Model Generation Options dialog box. If you do not have an XML model opened in the current workspace, the Update existing XML Model option is not available. 2 Select the Update existing XML Model radio button.
Chapter 3 Working with an XML model 4 Click the Detail tab to define options and generation parameters. 5 Click the Target Models tab to select the target models of shortcuts in the current model. 6 Click the Selection tab to display the Selection page. 7 Select the name of a PDM from the Select Location dropdown listbox. The default XML model is generated from this PDM.
Generating an XML model from an Object-Oriented Model Generating an XML model from an ObjectOriented Model This section explains how to generate an XML model from an ObjectOriented Model. Generating XML Model objects When you generate an XML model from an OOM, PowerDesigner translates OOM objects into specified XML Model objects as follows: OOM Object Generated object in an XML model Class Element.
Chapter 3 Working with an XML model XML model naming conventions If the code of the generated XML model objects does not correspond to the target language naming conventions, you can define a code naming convention script to convert object names into codes. For more information on conversion scripts, see section .convert_name & .convert_code macros in chapter Managing Models of the General Features Guide.
Generating an XML model from an Object-Oriented Model Update existing XML model You can generate an OOM into an existing XML model. If you choose to update an existing XML model when the current OOM has never been generated, the Select model dropdown listbox is empty by default. You have to click the Ellipsis button to display the Select a model dialog box in which you can select a model.
Chapter 3 Working with an XML model Option Description Save generation dependencies When selected, PowerDesigner keeps track of the identity of each generated object. It is useful when merging two XML models which have been generated from the same OOM. Objects can be compared and recognized as the same object, even if the object has been modified in the merged XML model Convert names into codes When selected, object codes are generated from names using the corresponding conversion script.
Generating an XML model from an Object-Oriented Model Generating a new XML model from an OOM You can generate an XML model from an OOM or from a package in an OOM. PowerDesigner creates a new XML model containing all the objects that you selected to generate in the XML model. The newly created XML model appears in the browser and the corresponding diagram opens in the work area. You can only generate an XML model from the active OOM diagram.
Chapter 3 Working with an XML model 5 Click the Detail tab to define options and generation parameters. 6 Click the Target Models tab to select the target models of shortcuts in the current model. 7 Click the Selection tab to display the Selection page. 8 Select the name of an OOM from the Select Location dropdown listbox. Generating an XML model from a package To generate an XML model from a package, select the package name from the dropdown listbox in the upper left corner of the dialog box.
Generating an XML model from an Object-Oriented Model You can only generate an XML model from the active OOM diagram window. To update an existing XML model by generating from an OOM: 1 Select Tools→Generate XML Model to display the XML Model Generation Options dialog box. If you do not have an XML model in the current workspace, the Update existing XML Model option is not available. 2 Select the Update existing XML Model radio button.
Chapter 3 Working with an XML model 4 Click the Detail tab to define options and generation parameters. 5 Click the Target Models tab to select the target models of shortcuts in the current model. 6 Click the Selection tab to display the Selection page. 7 Select the name of an OOM from the Select Location dropdown listbox. The default XML model is generated from this PDM.
Editing an XML model report Editing an XML model report You can edit a report of your XML model. The Report Editor allows you to use a predefined report template or to build your own report. For more information on reports, see the Reports User’s Guide. What is a report? A report is an easy to consult document that shows parts or the global content of a model. You can print a report in order to have it on a paper support, or you can generate it in RTF or HTML format for a better reusability.
Chapter 3 Working with an XML model The List of Reports appears. It displays the alphabetical list of all reports saved in the model. If there are no existing reports, all the tools in the List of Reports dialog box are grayed, except for the New Report tool. 2 Select the New Report tool. The New Report dialog box appears. It displays a default report name. XSM User's Guide 3 Type a report name in the Report name box, if you want to modify the default name.
Editing an XML model report Language in a template When you use a template created in a language different from the one you select to create your report, only user-defined items such as Title or Text paragraph will keep the language of the template. Other items will be displayed in the report language. 6 Click OK. The Report Editor window appears. A section is created by default at the bottom of the Report items pane, which is filled with the template you have selected.
Chapter 3 Working with an XML model In the following structure, the graphical representation of the diagram will appear in the report just before the descriptive paragraphs. To have a preview of your report, click the Print Preview tool in the Report Editor window.
Editing an XML model report 200 PowerDesigner
C H A P T E R 4 Generating and reverse engineering an XSD, a DTD or an XDR file About this chapter This chapter describes how to generate and reverse engineer an XML Schema Definition file (.XSD), a Document Type Definition file (.DTD) or an XML-Data Reduced file (.XDR). The same procedures apply to all XML languages.
Generating an XSD, a DTD or an XDR file Generating an XSD, a DTD or an XDR file PowerDesigner allows you to generate an XSD, a DTD or an XDR file from an XML model. File preview You can have a preview of an XSD, a DTD or an XDR file by clicking the Preview tab of an XML model property sheet.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file Defining generation parameters You can define various parameters before generating an XSD, a DTD or an XDR file. Check model You can check your model before generation if you select the Check model check box. This check box is available for all XML languages. The generation stops if an error is found. You must correct this error before starting the generation again.
Generating an XSD, a DTD or an XDR file Defining generation options If you do not see the Options page in the Generation dialog box, it means that no option has been defined in the corresponding XML language (.XSL file). You can however customize your XML language at any time, and add any options you may need during generation. You define generation options in the Generation/Options category of the XML language available from Language→Edit Current Language.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file How to generate an XSD, a DTD or an XDR file? The type of generated file depends on which XML language the model has been targeted with: Model targeted with Generated file XML Schema Definition 1.0 XSD Document Type Definition 1.0 DTD XML-Data Reduced 1.0 XDR The XML language of an XML model is displayed in the status bar (bottomright corner of the screen) and in the model property sheet.
Generating an XSD, a DTD or an XDR file 2 Type a destination directory for the generated file in the Directory box. or Click the Select a Path button beside the Directory box and browse to select a directory path. In the case of an XDR file, the Generation dialog box displays an Options page where the generation of comments (see Comment property in the General page of an object property sheet) is set by default.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file A Result box appears indicating that the XSD, DTD or XDR file has been generated in the destination directory. The result is also displayed in the Generation page of the Output window, located in the bottom part of the main window. XSM User's Guide 5 Click Edit to edit the XSD, DTD or XDR file with a plain text editor. 6 Click Close in the Result box.
Reverse engineering an XSD, a DTD or an XDR file Reverse engineering an XSD, a DTD or an XDR file PowerDesigner allows you to reverse engineer an XML Schema Definition file, a Document Type Definition file or an XML-Data Reduced file to create or update an XML model. What is reverse engineering? Reverse engineering is the process of examining and recovering data or source code from a file that is then used to build or update an XML model.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file Reverse engineering options The Options page of the Reverse Engineering dialog box displays the following options: Option Description Show symbols If selected, the generated model appears in the diagram (not only in the Browser tree view) Expand nodes If selected, global objects (with no parent object in the diagram) appear in the diagram with their nodes expanded (child objects) Show elements If selected, the elements appear
Reverse engineering an XSD, a DTD or an XDR file The New XML Model dialog box appears. 2 In the General page, select an XML language in the XML language dropdown listbox. 3 Select the Share or Copy radio button. 4 In the Extended Model Definitions page, you can select one or several extended model definitions to be reverse engineered with the XSD, DTD or XDR file.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file 6 In the Options page, click the Select a File tool beside the File name box to select the XSD, DTD or XDR file you want to reverse engineer. Select or clear options (See Reverse engineering options). 7 In the Target Models page, select the Add Models tool if you want to maintain the shortcuts defined between the XSD, DTD or XDR file you are reverse engineering and other XML models.
Reverse engineering an XSD, a DTD or an XDR file 9 Click OK. The XML diagram corresponding to the reverse engineered XSD, DTD or XDR file appears in the diagram window. The Browser tree view reveals the new XML model with all its objects. The result is also displayed in the Reverse page of the Output window, located in the bottom part of the main window. Reverse engineering to an existing XML model To reverse engineer an XSD, a DTD or an XDR file to an existing XML model: 1 Select File→Open.
Chapter 4 Generating and reverse engineering an XSD, a DTD or an XDR file The Merge Models dialog box appears, with the newly generated XML model in the left pane, and the existing XML model in the right pane. You can select or clear object check boxes in the right pane for objects that you want to include or delete in the model to be merged. For more information on merging models, see section Merging models, in chapter Comparing and Merging Models of the General Features Guide. 9 Click OK.
Reverse engineering an XSD, a DTD or an XDR file 214 PowerDesigner
C H A P T E R 5 Exchanging data with databases supporting XML About this chapter Contents XSM User's Guide This chapter describes how to use an XML model to store or retrieve data in databases supporting XML.
Why use XML in databases? Why use XML in databases? XML is becoming a universal data exchange format. An XML file can be read with any plain text editor. Most of relational databases (RDB) now support XML so that you can store or retrieve data through XML files. With an XML model, you can generate an annotated schema that will allow you to store or retrieve data in a relational database supporting XML.
Chapter 5 Exchanging data with databases supporting XML Generating an annotated schema for Microsoft SQL Server 2000 Microsoft SQL Server 2000 is an XML-enabled database server. It supports annotations that can be used on XSD or XDR files, to map XML data to relational data. An annotated schema is an XML-coded file, targeted with an XML language and tagged with specific DBMS annotations, that allows you to store or retrieve data in an XML format, from relational databases supporting XML.
Generating an annotated schema for Microsoft SQL Server 2000 To generate an annotated schema by mapping through the XML Builder Wizard: 1 In the PDM menu bar, select Tools→XML Builder Wizard. The Model Selection dialog box appears. 218 2 Select the new model option. Type a name and a code for the new model, and select XML Schema Definition 1.0 or XML-Data Reduced 1.0 in the XML language dropdown listbox. or Select the existing model option. Select a model in the XML Model dropdown listbox.
Chapter 5 Exchanging data with databases supporting XML The Tables and Views Selection dialog box appears with the PDM tables list. All tables are selected by default. XSM User's Guide 4 Click the Deselect All tool and select the tables you want to generate into XML elements. 5 Click Next.
Generating an annotated schema for Microsoft SQL Server 2000 The XML Hierarchy Design dialog box appears. 6 220 Click the Element radio button, if you want to create columns as elements. or Click the Attribute radio button, if you want to create columns as attributes.
Chapter 5 7 Exchanging data with databases supporting XML Drag and drop tables from left to right panel, and build an XML hierarchy. For more information on building an XML hierarchy, see section Generating an XML model via the XML Builder Wizard, in chapter Generating from a PDM, in the PDM User’s Guide. 8 Click Finish. The new XML model appears in the workspace with the generated elements and attributes.
Generating an annotated schema for Microsoft SQL Server 2000 In the case of an existing XML model, the generated elements appear next to the existing elements. Extended model definitions The SQL/XML extended model definition is automatically attached to the generated XML model. You can attach the XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema.
Chapter 5 Exchanging data with databases supporting XML 11 In the XML in Database page, select Microsoft SQL Server. Note: In the General Purpose page, you can select the XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema. 12 Click OK. Microsoft SQL Server appears in the List of Extended Model Definitions. 13 Click OK.
Generating an annotated schema for Microsoft SQL Server 2000 The Generation dialog box appears with Microsoft SQL Server selected in the Targets page. 15 Click the Select a Path button, beside the Directory box, to select a path for the annotated schema file. 16 Click OK. The Result dialog box appears with the path of the annotated schema file selected. 17 Click Edit.
Chapter 5 Exchanging data with databases supporting XML The annotated schema appears in the editor window. Note the SQL namespace (with the sql prefix) and the SQL annotations for tables (sql:relation), columns (sql:field) and reference (sql:relationship). 18 Click Close in the Result dialog box. Reinforcing mapping with extended attributes If you want to modify or reinforce the mapping resulting from the the XML Builder Wizard, you can define extended attributes for XML objects.
Generating an annotated schema for Microsoft SQL Server 2000 To generate an annotated schema by reinforcing mapping with extended attributes: 1 Double-click an element symbol in the diagram to display its property sheet. 2 In the Extended Attributes page, type the name of a database column in the Value column of the field annotation, if you want to map the element with a database column.
Chapter 5 XSM User's Guide Exchanging data with databases supporting XML Annotation E A Description key-fields 9 — Allows specification of columns that uniquely identify the rows in a table limit-field 9 9 Allows limiting the values that are returned on the basis of a limiting value limit-value 9 9 Allows limiting the values that are returned on the basis of a limiting value mapped 9 9 Allows schema items to be excluded from the result max-depth 9 — Allows you to specify depth in r
Generating an annotated schema for Microsoft SQL Server 2000 5 Select Language→Generate XML Schema Definition File. or Select Language→Generate XML-Data Reduced File. The Generation dialog box appears with Microsoft SQL Server selected in the Targets page. 6 Click the Select a Path button, beside the Directory box, to select a path for the annotated schema file. 7 Click OK. The Result dialog box appears with the path of the annotated schema file selected.
Chapter 5 8 Exchanging data with databases supporting XML Click Edit. The annotated schema appears in the editor window. Note the SQL namespace (with the sql prefix) and the SQL annotations for tables (sql:relation), columns (sql:field) and reference (sql:relationship). 9 XSM User's Guide Click Close in the Result dialog box.
Generating an annotated schema for Oracle 9i2 Generating an annotated schema for Oracle 9i2 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).
Chapter 5 Exchanging data with databases supporting XML The Extended Model Definition Selection dialog box appears. 3 In the XML in Database page, select Oracle XML DB 9.2. 4 Click OK. Oracle XML DB 9.2 appears in the List of Extended Model Definitions. 5 Click OK. The extended model definition appears in the Browser tree view, in a folder attached to the XML model. 6 XSM User's Guide Double-click an element symbol in the diagram to display its property sheet.
Generating an annotated schema for Oracle 9i2 7 In the Extended Attributes page, type the name of a table or a column in the Value column of the SQLName annotation, if you want to create a table or a column from the selected element. You can define a value for the following annotations: 232 Annotation Description beanClassname Can be used within element declarations.
Chapter 5 Exchanging data with databases supporting XML 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.
Generating an annotated schema for Oracle 9i2 11 In the Extended Attributes page, type the name of an abstract data type (ADT) in the Value column of the SQLType annotation, if you want to create an ADT from the selected complex type. You can define a value for the following annotations: Annotation Description beanClassname Can be used within element declarations. If the element is based on a global complexType, this name must be identical to the beanClassname value within the complexType declaration.
Chapter 5 Exchanging data with databases supporting XML 15 In the Extended Attributes page, you can select a value (false or true) for the following annotations: Annotation Description mapUnboundedStringToLob If true, unbounded strings are mapped to CLOB by default. Similarly, unbounded binary data get mapped to BLOB, by default.
Generating an annotated schema for Oracle 9i2 The Result dialog box appears with the path of the generated schema file. 20 Click Edit. The annotated schema appears in the editor window. Note the Oracle namespace (with the sql prefix) and annotations for tables (sql:SQLName) and ADTs (sql:SQLType) 21 Click Close in the Result dialog box.
Chapter 5 Exchanging data with databases supporting XML Generating a DAD file for IBM DB2 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).
Generating a DAD file for IBM DB2 The Model Selection dialog box appears. 238 2 Select the new model option. Type a name and a code for the new model, and select Document Type Definition 1.0 in the XML language dropdown listbox. or Select the existing model option. Select a model in the XML Model dropdown listbox. This model must be targeted with DTD. 3 Click Next.
Chapter 5 Exchanging data with databases supporting XML The Tables and Views Selection dialog box appears with the PDM tables list. All tables are selected by default. XSM User's Guide 4 Click the Deselect All tool and select the tables you want to generate into XML elements. 5 Click Next.
Generating a DAD file for IBM DB2 The XML Hierarchy Design dialog box appears. 6 240 Click the Element radio button, if you want to create columns as elements. or Click the Attribute radio button, if you want to create columns as attributes.
Chapter 5 7 Exchanging data with databases supporting XML Drag and drop tables from left to right panel and build an XML hierarchy. For more information on building an XML hierarchy, see section Generating an XML model via the XML Builder Wizard, in chapter Generating from a PDM, in the PDM User’s Guide. 8 Click Finish. The new XML model appears in the workspace with the generated elements and attributes.
Generating a DAD file for IBM DB2 In the case of an existing XML model, the generated elements appear next to the existing elements. Extended model definitions The SQL/XML extended model definition is automatically attached to the generated XML model. You can attach the XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema. (See Note in step 11) 9 Select Model→Extended Model Definitions. The List of Extended Model Definitions appears.
Chapter 5 Exchanging data with databases supporting XML 11 In the XML in Database page, select IBM DB2 DAD. Note: In the General Purpose page, you can select the XML Document extended model definition to generate a simplified XML file that will help you understand the annotated schema. 12 Click OK in the Extended Model Definition Selection dialog box. IBM DB2 DAD appears in the List of Extended Model Definitions. 13 Click OK in the List of Extended Model Definitions.
Generating a DAD file for IBM DB2 15 In the Extended Attributes page, click the DB2XMLExtender tab and select a value for the StorageType (Xcollection or Xcolumn). In the case of an Xcollection, select a value for the MappingType (RDB or SQL).
Chapter 5 Exchanging data with databases supporting XML Extended attribute Description StorageName If StorageType is Xcolumn, then it is the name of the sidetable column StorageType Type of storage (Xcollection or Xcolumn) 16 Click OK. 17 Repeat steps 14 to 16 for each global element you want to determine the type of DAD file or other extended attributes. 18 Select Language→Generate Document Type Definition File. The Generation dialog box appears with IBM DB2 DAD selected in the Targets page.
Generating a DAD file for IBM DB2 19 In the Options page, generation options are set by default. You can change their value. Option Description Character ending an instruction Character ending instructions in the SQL file for stored procedures Generates procedures deployment Generation of a SQL script for stored procedures enabling XML data storage and facilitating XML data retrieval Path of DAD.
Chapter 5 Exchanging data with databases supporting XML The Result dialog box appears with the paths of the generated DAD, DTD and SQL files. 22 Select the path of a DAD file and click Edit. The selected DAD file appears in the Editor window.
Generating a DAD file for IBM DB2 ♦ DAD file defined with Xcolumn as StorageType: 23 Repeat step 22 to edit another DAD file. or Click Close in the Result dialog box.
Chapter 5 Exchanging data with databases supporting XML Generating SQL/XML queries SQL/XML is an XML extension of the Structured Query Language. With SQL/XML, you retrieve relational data using extended SQL syntax, and produce a result using XML.
Generating SQL/XML queries The List of Extended Model Definitions appears. 2 Click the Import an Extended Model Definition button. The Extended Model Definition Selection dialog box appears. 3 In the General Purpose page, select SQL/XML. 4 Click OK. SQL/XML appears in the List of Extended Model Definitions. 5 250 Click OK.
Chapter 5 Exchanging data with databases supporting XML The SQL/XML extended model definition appears in the Browser tree view, attached to the model. 6 < optional > Double-click a global element in the diagram to display its property sheet. 7 In the Preview page, click the SQL/XML.Query tab to display the SQL/XML query. The Preview page is in read-only mode, you cannot modify the script. XSM User's Guide 8 Click OK. 9 Select Tools→Extended Generation.
Generating SQL/XML queries The Generation dialog box appears with SQL/XML selected in the Targets page. 10 Click the Select a Path button beside the Directory box to select a path for the SQL/XML queries.
Chapter 5 Exchanging data with databases supporting XML 11 In the Selection page, select the global elements for which you want to generate a SQL/XML query. (Only one global element in the example) 12 Click OK. The Result dialog box appears with a path for each SQL/XML query. (Only one in the example) 13 Select the path of a SQL/XML query and click Edit. The SQL/XML query appears in the Editor window.
Generating SQL/XML queries 14 Repeat step 13 to edit another SQL/XML query. or Click Close in the Result dialog box. Once generated, SQL/XML queries are processed by SQL interpreters in databases supporting XML.
C H A P T E R 6 Generating from an XML model About this chapter Contents XSM User's Guide This chapter describes how to generate an XML model from an XML model.
Generation basics Generation basics You can generate an XML model from an XML model. There are two options to generate an XML model from an XML model: Generation option Description Generate new XML model It creates a copy of the source XML model, converting the source language (DTD, XSD or XDR) into the target language Update existing XML model It creates a default model with the objects translated from the XML model that is merged with an existing XML model.
Chapter 6 Generating from an XML model The model generation process allows you to define the target object of a shortcut in a generated model. For example, here is the proper sequence of events for external shortcuts generation: ♦ Model 1 is the target model of a shortcut in Model 2 ♦ Model 1 is generated to Model 1.1 ♦ Model 2 is prepared for generation to Model 2.
Generation basics You can also preserve the link between an external replication and its target model through generation. For more information on the generation of object replications, see section Generating replications, in chapter Managing Object Replications, in the General Features Guide.
Chapter 6 Generating from an XML model Generating an XML model from an XML model This section explains how to generate an XML model from an XML model. Why generate an XML model from an XML model? You can generate an XML model from an XML model when you need to keep two models synchronized during the design process. This kind of generation allows you to create a copy of a given model and define generation links between objects in the source XML model and their equivalent in the generated XML model.
Generating an XML model from an XML model For more information on model options when generating an XML model from an XML model, see section Defining model options in chapter XML Model Basics. Update existing XML model You can generate an XML model into an existing XML model. In the Update Existing Model groupbox, the Select Model dropdown listbox contains all the models already generated from the current model.
Chapter 6 Generating from an XML model Defining generation options The Detail page of the XML Model Generation Options dialog box displays the following options: Option Description Check model When selected, verifies the model before generating the XML model, and stops generation if an error is found Save generation dependencies When selected, PowerDesigner keeps track of the identity of the origin of each generated object.
Generating an XML model from an XML model You can only generate an XML model from the active XML model diagram. To generate a new XML model from an XML model: 1 Select Tools→Generate XML Model to display the XML Model Generation Options dialog box. 2 Select the Generate new XML Model radio button. 3 Select an XML language in the XML language dropdown listbox. 4 Select Share or Copy radio button.
Chapter 6 Generating from an XML model 11 Select the check boxes for the objects you want to generate, and clear the check boxes for the objects you do not want to generate. 12 Click OK. The Output window shows the progress of the generation process. The diagram of the new XML model appears in the work area.
Generating an XML model from an XML model 3 Select a model from the Select model dropdown listbox, if the current model has already been generated. or Click the Ellipsis button, beside the Select model dropdown listbox, and select a model model available in the workspace in the Select a model dialog box. Preserve modifications Select the Preserve modifications check box if you want to preserve objects in the XML model.
Chapter 6 9 Generating from an XML model Click OK. If you selected the Preserve modifications check box, the Merge Models window appears. If you cleared the Preserve modifications check box, the updated XML model diagram appears in the work area. Merging models The Merge Models dialog box shows the newly generated XML model in the left pane, and the existing XML model in the right pane.
Generating an XML model from an XML model 266 PowerDesigner
XML Model Glossary all A group particle indicating that child elements can appear in any order, each of them once or not annotation Additional information about a model and its objects proceeding from documentation and/or applications any Allows you to attach any type of object to a choice or a sequence group particle any attribute Allows you to insert any attribute of specified namespaces into an element, a complex type or an attribute group attribute Additional information about an element or a
XML Model Glossary extension Derivation of a complex type to extend the values of its base type facet A constraint on the set of values of a simple type field An XPath expression that specifies the value (or one of the values) used to define an identity constraint (unique, key or keyRef) global object A global object has a global scope. It has no parent object and can be reused locally in the model through referenced objects.
XML Model Glossary qualified name (QName) A name beginning with a prefix and a colon (:). The prefix is associated with a namespace URI. For example: xs:schema, xs being associated with http://www.w3.org/2001/XMLSchema RDB Relational database.
XML Model Glossary union Derivation of a simple type to restrict its values to a collection of built-in and simple data types unique An identity constraint used to specify that an element or attribute value (or set of values) must be unique or null within a specified scope URI Uniform Resource Identifier. A string of characters which identifies an Internet resource XDR XML-Data Reduced. An XML language defining the structure of an XML file.
Index A all 53 annotated schema for Microsoft SQL Server 2000 for Oracle 9i2 230 annotation 115 application information 115 check 165 create annotation 118 documentation 115 global 115 local 115 any 58 namespace 58 process contents 58 any attribute 61 namespace 61 process contents 61 application information 115 arrange symbols 34 attribute 46 add attribute to element 51 attribute type (XDR) 48 AttributeType (XDR) 48 check 156 data type 48 default 50 default (XDR) 49 detail properties 50 embedded type 48 fi
C check model 140 annotation 165 attribute 156 attribute group 157 automatic correction 140, 145 business rule (XSM) 149 complex type 152 correct error 145 data source 149 display details 145 element 153 entity 151 error list 145 extended link 162 extended object 162 extension 163 file 150 group 155 group particle 147 import 158 include 152 key 159 keyRef 160 levels of problem severity 140 manual correction 145 model 148 namespaces 148 notation 156 object selection 141 objects 147 re-check 145 redefine 158
database (continued) Oracle 9i2 230 SQL/XML queries 216, 249 XML in database 216 default 40, 50 derivation 102 extension 102 restriction 104 simple type list 112 simple type union 113 diagram 32 display preference any 61 complex type 96 element 52 group 82 simple type 90 documentation 115 DTD 3 E element 35 attributes properties 41 block 40 check 153 child element 52 constraints properties 42 content 37 create element 43 data type 37 default 40 detail properties 40 element type (XDR) 37 ElementType (XDR) 3
facet (continued) whitespace 105 field 64, 66, 67, 73 stereotype 73 XPath 73 file check 150 final 19, 40, 90, 94 fixed 40, 50, 105 form 40, 50 fraction digits 104 functional overview 2 group (continued) reference 76 stereotype 76 group particle 53 all 53 check 147 choice 53 create group particle properties 54 sequence 53 group symbols 34 G I generate 256 basics 256 check model 182 check model 261 check model parameter 203 DTD file from XML model 202 enable transformations 182, 190, 261 external shortcut
L length 104 level of problem severity error 140 warning 140 link 8, 45, 57, 81, 98 child object to complex type 98 child object to element 45 child object to group 81 child object to group particle 57 child object to parent object 8 local objects 176 M manipulate XML objects graphically 176 map object 166 attributes mapping 169, 170, 171, 172 complex type sources 170, 172 create mapping for XML object 172 data source 166 element sources 169, 171 XML Model to OOM 171 XML Model to PDM 169 mapping attribute
redefine 128 check 158 create redefine 130 schema location 128 reference 37, 48, 67, 76, 82 replication check 163 report 196 create model report 196 underline hierarchical structure 198 restriction 104 check 163 create restriction on complex type 111 create restriction on simple type 108 enumeration 104 fraction digits 104 length 104 maximum exclusive 104 maximum inclusive 104 maximum length 104 minimum exclusive 104 minimum inclusive 104 minimum length 104 pattern 104 total digits 104 whitespace 104 revers
V value attribute (DTD, XDR) element (XDR) 50 50 W warning 140 whitespace 104 workspace 28 X XDR 3 any 58 attribute type 48 AttributeType 48 element type 37 ElementType 37 XML 3 diagram 32 model 3 objects 5 XML language 10, 259 change XML language 11 choose XML language 28 XPath 73 abbreviated syntax 70 expressions 70 XSD 3 XSM User's Guide 277
278 PowerDesigner