|
Home > Online Product Documentation > Table of Contents > Defining Elements That Carry Attributes and Contain Data in XML Schemas Defining Elements That Carry Attributes and Contain Data in XML Schemas
You might want to define an element that carries attributes and contains data, but does not contain subelements. In the
This element has a
Diagram ViewTo define a complex type that contains only attributes:
1. Right-click the
schema node
2. In the shortcut menu, select
Add >
Element.
Alternatives: This operation is also available from the
XMLSchema >
Diagram >
Add > Element menu and from the
Add button
The new element is added to the XML Schema. It is displayed in the diagram and in the text pane (if you have it open). The properties for the new element are displayed in the Properties window.
3. Create a complexType of the element - right-click the element and select
Add > ComplexType.
4. Make sure the new complexType is selected.
5. Click the
QuickEdit button
The Type Derivation dialog box appears.
6. Expand the W3C XML Schema and select the simpleType on which you want to base the data allowed by the complexType.
7. Click OK.
The XML Schema is updated with the element's new definition.
Figure 270 shows an extension of the
The simpleContent node (
8. To add an attribute, right-click the element and select
Add > Attribute.
Tree ViewTo define an element that contains raw data and carries attributes:
1. Click the
Schema node.
2. In the left tool bar, click
New Element Definition
3. Type the name of the element and press Enter twice. If you press Enter once, Stylus Studio displays a pop-up menu that lists the possible types for the new element. You need to define a new type, so you cannot select from this list. If the pop-up menu does appear, press Enter or click outside the menu. You should now have a named element with no type specified.
4. In the left tool bar, click
New complexType
5. In the left tool bar, click
New Content
6. In the drop-down list that appears, double-click
simpleContent. This is the
Content Type property. When the content type is
simpleContent, the complexType you are defining can contain data and attributes. It cannot contain subelements.
7. If you want the contained data to be one of the simpleTypes already defined with no restrictions, click
New Extension
Stylus Studio displays a scrollable, drop-down list of the simpleTypes built in to XML Schema and previously defined in the current schema.
8. If you clicked
New Extension, double-click the type of the data you want this element to contain. Go to
step 9.
If you clicked New Restriction, follow these steps:
a. Double-click the simpleType whose values you want to restrict.
b. In the left tool bar, click
New Facet
c. Double-click the type of facet you want to specify.
d. In the
Properties window, double-click the
Value field.
e. Enter a value for the new facet.
f. To add another facet, click the
restriction node for the simpleType, and repeat
step b.
9. In the left tool bar, click the
complexType node that you created in
step 4.
10. In the left tool bar, click
New Attribute Definition
11. Type a name for the new attribute and press Enter. Stylus Studio displays a scrollable, drop-down list of the possible types for the new attribute.
12. Double-click the attribute type. If you want to, specify a value for the attribute's
Default or
Fixed Value property in the
Properties window.
|
Publishing & Printing
It is really hard to get things to look pretty, especially XML. That's why these publishing & printing companies use Stylus Studio to make a Mona Lisa out of data integration. Check out these top companies that are "stunning" with Stylus Studio!
DTD Parser
Learn about the powerful DTD parser technologies that are supported in Stylus Studio's DTD tools, including DOM and SAX based DTD parsing components.
XML Unicode Encoding
Stylus Studio supports over 300 different file encodings, including UTF-8, UTF-16, EUC-JP, SHIFT-JIS, and more, alowing you to work with any XML document. Robust text editors support standard editing features, and Sense:X intelligent auto-completion.
Sybase
Sybase Adaptive Server Enterprise (ASE) is a powerful high-performance database for recording and retrieving business records. Learn how to develop XML applications for Sybase using Stylus Studio.