home *** CD-ROM | disk | FTP | other *** search
/ Chip: 25 Years Anniversary / CHIP_25Jahre_Jubilaeum.iso / downloads / 401065 / WPO11 / Data1.cab / _BBF8EA182DF4411E9B03F80520924898 < prev    next >
Text File  |  2003-03-07  |  20KB  |  474 lines

  1. Working with elements
  2.  
  3. Elements are specific components of a document that are surrounded by markup. Once you create an XML document, you can insert and edit elements using a variety of methods.
  4.  
  5. In this section, you'll learn about
  6.  
  7.   inserting elements
  8.   
  9.   editing elements
  10.   
  11.   applying rules to elements
  12.   
  13.   editing element rules
  14.   
  15.   associating elements
  16.   
  17.   editing element attributes
  18.   
  19. Inserting elements
  20.  
  21. You can insert new elements manually or automatically. Automatically inserting elements is useful when you are creating a new XML document because the required elements are quickly inserted in the proper order.
  22.  
  23. You can also insert new elements that are not defined in the DTD. Upon document validation, you will be warned when elements are not defined. Undefined elements are not validated.
  24.  
  25. You can specify the root element of an XML document. Validation starts from the root element in an active XML document. If you do not specify a root element, the root element defined in the DTDeclaration is used. You can specify a root element for every XML document saved in a separate file.
  26.  
  27. You can also create an element rule that will display text as part of the element formatting. For example, you can create an element rule that will display the name of the document author whenever you insert the Author element into the XML document.
  28.  
  29. You also define a hierarchy, you set conditions that an element must meet in order for layout codes to be applied to the element. For example, if you specified the element <PS> as the parent of <PARA> in the Element rule dialog box, the layout codes would be applied only to <PARA> elements that occurred within <PS> elements.
  30.  
  31. To manually insert elements
  32.  
  33. 1    In the WordPerfect XML Editor, click Insert  Elements.
  34.  
  35. 2    Disable the Auto-insert check box.
  36.  
  37. 3    Enable one of the following options:
  38.  
  39.   Valid elements-displays only the valid elements of the associated DTD
  40.   
  41.   All elements-displays all the elements contained in the associated DTD
  42.   
  43. 4    Choose an element from the All elements list.
  44.  
  45. If you want to view the valid optional elements in an SGML document, enable the Inclusions check box.
  46.  
  47. 5    Click Insert.
  48.  
  49.  
  50.  
  51. You can also    
  52.  
  53. Display the Edit attributes dialog box whenever you insert a tag with attributes into the XML document    Click Options  Always prompt for attributes
  54.  
  55. Never display the Edit attributes dialog box    Click Options  Never prompt for attributes
  56.  
  57. Display the Edit attributes dialog box when you insert a tag containing required attributes into the XML document.    Click Options  Prompt when attributes required
  58.  
  59.  
  60.  
  61. Tip
  62.  
  63.   You can also choose an element in the All elements list by double-clicking the element.
  64.   
  65. To automatically insert elements
  66.  
  67. 1    In the WordPerfect XML Editor, click Insert  Elements.
  68.  
  69. 2    Enable the Auto-insert check box.
  70.  
  71. 3    Enable one of the following options:
  72.  
  73.   Valid elements-displays only the valid elements in the XML document
  74.   
  75.   All elements-displays all the elements contained in the associated template
  76.   
  77. 4    Choose an element from the All elements list.
  78.  
  79. 5    Click Insert.
  80.  
  81. WordPerfect inserts all required tags and their siblings into the document.
  82.  
  83. Tips
  84.  
  85.   You can also choose an element in the All elements list by double-clicking the element.
  86.   
  87.   When you use Auto-insert, the Enter key no longer inserts hard returns. You must close the Elements dialog box or disable the Auto-insert check box to use the Enter key to insert hard returns. You can also insert hard returns automatically by creating a draft template with a defined layout that simply inserts a new line after each end tag (or after both start and end tags, if you prefer). Use this draft template file with the Auto-insert check box enabled to automatically insert hard returns at strategic points throughout a document without pressing Enter.
  88.   
  89. To insert new elements not defined in the DTD
  90.  
  91. 1    In the WordPerfect XML Editor, open or create an XML document.
  92.  
  93. 2    Click Insert  Element.
  94.  
  95. 3    Type the name of the element in the Element box.
  96.  
  97. If you want to include the associated attributes of the element, you must also type the element attribute name and values. For example, type car color="red" where car is the element name, color is the attribute name and red is the attribute value.
  98.  
  99. Tips
  100.  
  101.   You can insert new elements by typing the name of the element and associated attributes in the Valid elements box on the property bar and pressing Enter.
  102.   
  103.   You can also open the Element dialog box by using the Ctrl + E shortcut keys.
  104.   
  105. To specify the root element
  106.  
  107. 1    In the WordPerfect XML Editor, open or create an XML document.
  108.  
  109. 2    Click XML  Root element.
  110.  
  111. 3    Choose an element from the Root element list.
  112.  
  113. 4    Click Select.
  114.  
  115. Tip
  116.  
  117.   You can return to the default root element for the selected document type by clicking XML  Root element  Original.
  118.   
  119. To insert text with element content
  120.  
  121. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  122.  
  123. 2    Choose an element in the Edit rule list.
  124.  
  125. 3    Click Edit  Edit rule.
  126.  
  127. 4    Click Display  Text.
  128.  
  129. 5    Type the text in the Text box.
  130.  
  131. The text will display when the selected element is inserted into the XML document.
  132.  
  133. Tips
  134.  
  135.   You can also choose an element by clicking the Elements button on the property bar.
  136.   
  137. To define the element hierarchy
  138.  
  139. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  140.  
  141. 2    Choose an element in the Edit rule list.
  142.  
  143. 3    Click Edit  Edit rule.
  144.  
  145. 4    Click Hierarchy.
  146.  
  147. 5    Enable one of the following options:
  148.  
  149.   Show parents only-displays only the valid parent elements of the selected element
  150.   
  151.   Show all elements-displays all the elements defined in the DTD
  152.   
  153. 6    Choose an element from the Element and parents selected list.
  154.  
  155. 7    Choose a parent element from the Element parents list.
  156.  
  157. 8    Click Add parent.
  158.  
  159. Notes
  160.  
  161.   If you choose the Show all elements option, the WordPerfect XML Project Designer will not validate the elements you insert as parent elements. For example, the WordPerfect XML Project Designer will allow you to insert <BODY> as a parent element to <MEMO> even if it is an invalid element order.
  162.   
  163.   If a default attribute value is defined in the DTD, WordPerfect highlights the default attribute value displayed in the Element attributes selected box. Otherwise, the first attribute value in the list is highlighted.
  164.   
  165. Tips
  166.  
  167.   You can choose an element in the Element parents list by double-clicking the element.
  168.   
  169.   You can edit the element hierarchy by choosing an element in the Element Rule list and clicking Edit  Edit hierarchy.
  170.   
  171. Editing elements
  172.  
  173. Once you create an XML document, you can edit it using a variety of methods. You can edit elements, copy element rules from one element to another, and assign user-friendly names known as aliases to the elements defined in the DTD you are using. The alias names you create are saved in a WordPerfect template.
  174.  
  175. You can also edit an element by performing an automatic search and replace for tags, codes, text, or attributes associated with an element. You can locate elements by searching for their tags. WordPerfect searches for the start or end tag of the element closest to the cursor.
  176.  
  177. To rename an element
  178.  
  179. 1    In the WordPerfect XML Editor, open or create an XML document.
  180.  
  181. 2    In the XML document, position the cursor after the start tag of an element.
  182.  
  183. 3    Click Insert  Element edit.
  184.  
  185. 4    In the Element box, type a new name for the element.
  186.  
  187. For example, Salutation title="Miss" surname="Smith"
  188.  
  189. Note
  190.  
  191.   In an SGML document, you can only rename an element if the new name is defined in the DTD.
  192.   
  193. To copy an element
  194.  
  195. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  196.  
  197. 2    Choose an element from the Element rule list.
  198.  
  199. 3    Click Edit  Copy rule.
  200.  
  201. Tip
  202.  
  203.   You can also copy an element by selecting an element in the Edit rule list and clicking the Copy Rule button on the property bar.
  204.   
  205. To create an alias name for an element
  206.  
  207. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  208.  
  209. 2    Choose an element from the Edit rule list.
  210.  
  211. 3    Click Tools  Alias.
  212.  
  213. 4    Choose an element from the Associations list.
  214.  
  215. 5    Type an alias name for the selected element in the Alias box
  216.  
  217. 6    Click in the Associations list.
  218.  
  219. The alias name is added to the list of associations.
  220.  
  221. Notes
  222.  
  223.   Alias names are defined once for each template, even if the template contains multiple layouts.
  224.   
  225.   The alias names you assign for elements will display in place of the element names in the application bar, reveal codes, error messages, and XML documents. When saving an XML document, the alias names are converted to the actual XML element name.
  226.   
  227. To find and replace text within elements
  228.  
  229. 1    In the WordPerfect XML Editor, open or create an XML document.
  230.  
  231. 2    Click Edit  Find and replace.
  232.  
  233. 3    Type the text in the Find box.
  234.  
  235. 4    Type the replacement text in the Replace with box.
  236.  
  237. 5    Click Match  Elements.
  238.  
  239. 6    Enable the Use match element conditions to limit the find check box.
  240.  
  241. 7    Enable one of the following buttons:
  242.  
  243.   Listed element order-searches for text within elements in the order specified in the Elements to search in boxes
  244.   
  245.   Any listed element-searches for text within all elements
  246.   
  247. 8    Choose an element from the Elements to search in box.
  248.  
  249. If you want to exclude an element from the search, choose an element from the Elements to ignore box.
  250.  
  251. Applying rules to elements
  252.  
  253. Applying rules to elements lets you edit elements and attributes in an XML document. You can rename an element and apply a rule to another element. Elements are specific components of a document that are identified and marked with XML tags.
  254.  
  255. Attributes qualify the formatting and content of an element. You can define attributes to specify what the content of an element should be, to specify justification definitions, and to specify formats such as font style. For example, an attribute could specify that the content of the element status be either public or confidential. You can also rename elements or copy an element rule from one element to another.
  256.  
  257. To apply a rule to another element
  258.  
  259. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  260.  
  261. 2    Choose an element from the Element rule list.
  262.  
  263. 3    Click Edit  Rename rule.
  264.  
  265. 4    Choose an element from the list.
  266.  
  267. Tip
  268.  
  269.   You can also rename an element by clicking the Rename rule button.
  270.   
  271. To revert an element rule
  272.  
  273. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  274.  
  275. 2    Choose an element in the Edit rule list.
  276.  
  277. 3    Click Edit  Edit rule.
  278.  
  279. 4    Click in the Rule entry for end tag (before revert) box.
  280.  
  281. 5    Click Insert  Revert.
  282.  
  283. 6    Choose the feature you want to revert from the Function list.
  284.  
  285. Note
  286.  
  287.   The Function list displays only the features that you can revert with the exception of on/off functions. On/off functions do not display in the Function list but can be reverted.
  288.   
  289. Tip
  290.  
  291.   You can also choose an element by clicking the Elements button on the property bar.
  292.   
  293. Editing element rules
  294.  
  295. Rules are applied to the selected element in the order that they appear in the rule entry boxes of the WordPerfect XML Project Designer. You can change the order of element rules, edit element rules, delete element rules that are no longer required, and restore up to ten element rules that you have deleted.
  296.  
  297. To edit element rules
  298.  
  299. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  300.  
  301. 2    Choose an element from the Element rule list.
  302.  
  303. 3    Click Edit  Edit rule.
  304.  
  305. 4    Choose the code you want to edit from one of the following boxes:
  306.  
  307.   Rule entry for start tag  Displays all existing formatting rules for the selected element that take effect at the start tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  308.   
  309.   Rule entry for end tag (before revert)  Displays all existing formatting rules for the selected element that take effect at the end tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  310.   
  311.   Rule entry for end tag (after revert)  Displays all formatting rules for the selected element that take effect at the end tag after a revert (return to a previous setting). Lets you create a hierarchy or choose a rule to edit, move, or delete.
  312.   
  313. Tip
  314.  
  315.   You can also edit an element rule by double-clicking on the rule and clicking the Edit rule button.
  316.   
  317. To move element rules
  318.  
  319. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  320.  
  321. 2    Choose an element from the Element rule list.
  322.  
  323. 3    Click Edit  Edit rule.
  324.  
  325. 4    Choose the rule you want to move from one of the following boxes:
  326.  
  327.   Rule entry for start tag  Displays all existing formatting rules for the selected element that take effect at the start tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  328.   
  329.   Rule entry for end tag (before revert)  Displays all existing formatting rules for the selected element that take effect at the end tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  330.   
  331.   Rule entry for end tag (after revert)  Displays all formatting rules for the selected element that take effect at the end tag after a revert (return to a previous setting). Lets you create a hierarchy or choose a rule to edit, move, or delete.
  332.   
  333. 5    Choose one of the following options:
  334.  
  335.   Move up-moves the code up one place in the list
  336.   
  337.   Move down-moves the code down one place in the list
  338.   
  339. To delete element rules
  340.  
  341. 1    Choose a rule from one of the following boxes:
  342.  
  343.   Rule entry for start tag  Displays all existing formatting rules for the selected element that take effect at the start tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  344.   
  345.   Rule entry for end tag (before revert)  Displays all existing formatting rules for the selected element that take effect at the end tag. Lets you create a hierarchy or choose a rule to edit, move, or delete.
  346.   
  347.   Rule entry for end tag (after revert)  Displays all formatting rules for the selected element that take effect at the end tag after a revert (return to a previous setting). Lets you create a hierarchy or choose a rule to edit, move, or delete.
  348.   
  349. 2    Click Delete entry.
  350.  
  351. Tip
  352.  
  353.   You can also delete an element rule by choosing an element from the Edit rule list and clicking Edit  Delete rule.
  354.   
  355. To restore an element rule
  356.  
  357.   In the WordPerfect XML Project Designer, click Edit  Undelete rule.
  358.   
  359. Tip
  360.  
  361.   You can also restore your last delete by clicking the Undelete rule button on the property bar.
  362.   
  363. Associating elements
  364.  
  365. When you associate a feature or macro with an element that meets the specified conditions, WordPerfect opens the associated feature or runs the macro when you insert the element. For example, if you select a <BKGROUND> element and then associate it with a Watermark, WordPerfect automatically opens the Watermark dialog box when you insert a <BKGROUND> tag in the document.
  366.  
  367. To associate a WordPerfect feature with an element
  368.  
  369. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  370.  
  371. 2    Choose an element with attributes from the Element rule list.
  372.  
  373. 3    Click Edit  Edit rule.
  374.  
  375. 4    Click Edit  Element associate.
  376.  
  377. 5    Choose an association type from the Association list.
  378.  
  379. 6    Choose the element from the Element list.
  380.  
  381. To associate a macro with an element
  382.  
  383. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  384.  
  385. 2    Choose an element with attributes from the Element rule list.
  386.  
  387. 3    Click the Browse button next to the Macro box and choose the drive and folder of the macro.
  388.  
  389. Editing element attributes
  390.  
  391. You can assign and display an attribute value. Attributes qualify the appearance or content of an element and are defined in the DTD. You cannot add or delete attributes using WordPerfect. You can, however, use attributes to define the context in which an element rule is used. For example, you want the class of document to appear on the title page of all documents that are confidential. You add an attribute constraint (or value) to an element called status that specifies that the content of status can be either "public" or "confidential". When the content is confidential, you display the document status on the title page.
  392.  
  393. You can edit elements and attributes in an XML document. You can rename an element, apply a rule to another element, and edit or delete an element attribute. Elements are specific components of a document that are identified and marked with SGML or XML tags.
  394.  
  395. You can define attributes to specify what the content of an element should be, justification definitions, and formats such as font style. For example, an attribute could specify that the content of the element status be either public or confidential. You can also rename elements or copy an element rule from one element to another.
  396.  
  397. You can display the XML Tree to locate the element you want to edit. The XML Tree window displays a structured view of all document elements and attributes
  398.  
  399. To display element attribute values
  400.  
  401. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  402.  
  403. 2    Double-click an element with attributes in the Edit rule list.
  404.  
  405. 3    Click Display  Attribute value.
  406.  
  407. 4    Choose an element attribute from the Attribute list.
  408.  
  409. Note
  410.  
  411.   If you want to display the attribute value of a parent for a selected element, you must first add the parent element in the Hierarchy and attributes dialog box. For example, if a DTD contains a <BOOK> element with an attribute value of "Volume X" and also contains a <CHAPTER> element, you can display the attribute value for <BOOK>, "Volume X", with the <CHAPTER> element. To do so, you would first use the Hierarchy and attributes feature to specify <BOOK> as a parent element of <CHAPTER>.
  412.   
  413. Tip
  414.  
  415.   You can also choose an element by clicking the Elements button on the property bar.
  416.   
  417. To add an element attribute constraint
  418.  
  419. 1    In the WordPerfect XML Project Designer, open or create an XML project.
  420.  
  421. 2    Choose an element with attributes in the Edit rule list.
  422.  
  423. 3    Click Edit  Edit rule.
  424.  
  425. 4    Click Hierarchy.
  426.  
  427. 5    Choose an attribute from the Element attributes list.
  428.  
  429. 6    Click Add attribute.
  430.  
  431. 7    Choose a value for List, Entity, or Entities type attributes from the Value list.
  432.  
  433. If the attribute is not a List, Entity, or Entities type, type a value in the Value list and click Select.
  434.  
  435. Tip
  436.  
  437.   You can also add an element by clicking an element in the Element rule list, and clicking Edit  Edit hierarchy.
  438.   
  439.   You can also choose an element by clicking the Elements button on the property bar.
  440.   
  441. To delete an element attribute constraint
  442.  
  443. 1    In the WordPerfect XML Editor, open or create an XML document.
  444.  
  445. 2    Click Insert  Edit attributes.
  446.  
  447. 3    Choose an attribute name from the Attributes list.
  448.  
  449. 4    Click Delete attribute.
  450.  
  451. Note
  452.  
  453.   The default attribute value defined in the DTD is used when no attribute value is specified for an element.
  454.   
  455. To edit an element attribute
  456.  
  457. 1    In the WordPerfect XML Editor, open or create an XML document.
  458.  
  459. 2    In the XML document, position the cursor after an element.
  460.  
  461. 3    Click Insert  Edit attributes.
  462.  
  463. 4    Choose an attribute name from the Attributes list.
  464.  
  465. 5    Click Edit value.
  466.  
  467. 6    Choose a value for List, Entity, or Entities type attributes from the Value list.
  468.  
  469. If the attribute is not a List, Entity, or Entities type, type a value in the Value list and click Select.
  470.  
  471.  
  472.  
  473.  
  474.