Updating the Tree Representation of a Sample Document

This section provides instructions for updating the DOM tree representation of the your-quotes.xml document.

You should have already performed the steps in Updating the Schema of a Sample Document. Each of the following topics contains instructions for editing the sample XML document. You should perform the steps in each topic before you move on to the next topic. After the first topic, some steps depend on actions you performed in a previous topic.

This section includes the following topics:

Adding an Element to a Sample Document Tree

To add an element to the tree representation of your-quotes.xml:
1. If it is not already open, open your-quotes.xml.

See Opening a Sample XML Document if you need help with this step.

2. At the bottom of the XML Editor window, click the Tree tab.

Stylus Studio closes the Properties window.

4. Click New Element in the left tool bar to add a quote element to the document.

Stylus Studio displays a drop-down menu that lists the elements you can add at that position in the tree.

5. Click quote and press Enter.

Stylus Studio displays a field next to the new quote element. The DTD allows a quote element to contain data.

6. Click outside the field to close it without entering data.

Changing an Element's Data in a Sample Document Tree

This topic is part of a sequence. If your-quotes.xml is not open, see Opening a Sample XML Document. The sequence starts with Adding an Element to a Sample Document Tree.

In the Tree tab of your-quotes.xml, to change the data that an element contains:
1. Expand the third quote element.
2. Click the symbol element.
3. In the XML Editor top tool bar, click Change Value .

Stylus Studio activates the field to the right of the symbol element and selects the current value.

4. In the active field, type XSOL and press Enter.
5. To the right of the exchange element, right-click Nasdaq NMS.

Stylus Studio displays a shortcut menu.

6. Click Change Value. Stylus Studio activates the value field for the exchange element.
7. In the active field, type NYSE and press Enter.

Adding Attributes and Other Node Types to a Sample Document Tree

This topic is part of a sequence. If your-quotes.xml is not open, see Opening a Sample XML Document. The sequence starts with Adding an Element to a Sample Document Tree.

To add attributes and other types of nodes to your-quotes.xml:
1. Click the last quote element in the tree.
2. Click New Attribute .

Stylus Studio displays an attribute name field immediately below the selected quote element.

Stylus Studio displays a default value for the attribute, Text, in an entry field to the right of the new attribute.

4. In the attribute value field, type Star Brokers and press Enter.

Stylus Studio displays an entry field for a new attribute name, allowing you to easily add a number of attributes, one after the other.

5. Click outside the attribute name field to close it.
6. In the XML editor top tool bar, click Validate Document .

Stylus Studio displays a message in the Output window that indicates that the document is not valid. The DTD does not specify the agent attribute for the quote element. Stylus Studio allows you to modify your document in invalid ways, which you might want to do during application design. The validation feature informs you that your document is invalid when you try to validate the document.

7. Click the agent attribute.
8. In the XML Editor top tool bar, click Delete Node .
9. Click Validate Document again.

Stylus Studio displays a message in the Output window that indicates that the document is now valid.

Adding an Entity Reference to a Sample Document Tree

This topic is part of a sequence. If your-quotes.xml is not open, see Opening a Sample XML Document. The sequence starts with Adding an Element to a Sample Document Tree.

To add an entity reference to your-quotes.xml:
1. If it is not already selected, click the quote element you defined in the previous topic.
2. In the left tool bar, click New Element to add subelements to the new quote element.

Stylus Studio displays a drop-down menu that lists a number of elements that you can insert at this point. Scroll the list to view them all.

3. Click company, which is first in the list, and press Enter.

Stylus Studio displays a field next to the element name. You can enter data here, such as the name of the company. But rather than entering data, suppose you want to refer to an entity. To refer to an entity:

4. Click outside the field or press the Esc key.
5. Click New Entity Reference , which is the last button in the left tool bar.

Stylus Studio displays a drop-down menu that lists the defined entities.

If the New Entity Reference button is not active, click Toggle Display of Entity References in the XML editor top tool bar. This button allows you to control whether you can refer to entities.

6. Double-click TCBCC.

Stylus Studio inserts the text The Country's Best Computer Company as the value for the company element.

7. Click the Text tab at the bottom of the XML editor window.

Stylus Studio displays the &TBCC; entity reference in the new company element.

8. Click the Tree tab.
 
Free Stylus Studio XML Training:
W3C Member