< Day Day Up > |
XML provides a rich system for defining complex documents and data structures. Dreamweaver uses several XML schemas to organize information about server behaviors, tags and tag libraries, components, document types, and reference information. When you create and work with extensions in Dreamweaver, there are many instances in which you create or modify existing XML files to manage the data that your extension uses. In many cases, you can copy an existing file from the appropriate subfolder within the Configuration folder to use as a template. Document type definition fileThe central component of extensible document types is the document type definition file. There might be several definition files, all of which are located in the Configuration/DocumentTypes folder. Each definition file contains information about at least one document type. For each document type, essential information such as server model, color coding style, descriptions, and so forth, is described. NOTE Do not confuse Dreamweaver document type definition files with the XML document type definition (DTD). Document type definition files in Dreamweaver contain a set of documenttype elements, each of which defines a predefined collection of tags and attributes that are associated with a document type. When Dreamweaver starts, it parses the document type definition files and creates an in-memory database of information regarding all defined document types. Dreamweaver provides an initial document type definition file. This file, named MMDocumentTypes.xml, contains the document type definitions provided by Macromedia:
If you need to create a new document type, you can either add your entry to the document definition file that Macromedia provides (MMDocumentTypes.xml) or add a custom definition file to the Configuration/DocumentTypes folder. NOTE The NewDocuments subfolder resides in the Configuration/DocumentTypes folder. This subfolder contains default pages (templates) for each document type. Structure of document type definition filesThe following example shows what a typical document type definition file might look like: <?xml version="1.0" encoding="utf-8"?> <documenttypes xmlns:MMString="http://www.macromedia.com/schemes/data/string/"> <documenttype servermodel="ASP-JS" internaltype="Dynamic" winfileextension="asp,htm, html" macfileextension=asp, html" previewfile="default_aspjs_preview.htm" file="default_aspjs.htm" priorversionservermodel="UD4-ASP-JS" > <title> <loadString /> </title> <description> <loadString /> </description> </documenttype> ... </documenttypes> NOTE Color coding for document types is specified in the XML files that reside in the Configuration/CodeColoring folder. In the previous example, the loadstring element identifies the localized strings that Dreamweaver should use for the title and description for ASP-JS type documents. For more information about localized strings, see "Localized strings" on page 44. The following table describes the tags and attributes that you can use within a document type definition file.
NOTE When the user saves a new document, Dreamweaver examines the list of extensions for the current platform that are associated with the document type (winfileextension and macfileextension). Dreamweaver selects the first string in the list and uses it as the default file extension. To change this default file extension, you must reorder the extensions in the comma-separated list so the new default is listed first. When Dreamweaver starts, it reads all document type definition files and builds a list of valid document types. Dreamweaver treats any entries within the definition files that have nonexistent server models as nonserver model document types. Dreamweaver ignores entries that have bad contents or IDs that are not unique. If, while scanning the Configuration/DocumentTypes folder, Dreamweaver finds no document type definition files or if any of the definition files appear to be corrupt, Dreamweaver closes with an error message. Dynamic templatesYou can create templates that are based on dynamic document types. These templates are called dynamic templates. The following two elements are essential to defining a dynamic template:
The following example defines a dynamic document type: <documenttype servermodel="PHP MySQL" internaltype="Dynamic" winfileextension="php,php3" macfileextension="php,php3" file="Default.php"> <title>PHP</title> <description><![CDATA[PHP document]]></description> </documenttype> Now, you can define the following dynamic template, which is based on this PHP_MySQL dynamic document type: <documenttype internaltype="DWTemplate" dynamic winfileextension="php.dwt" macfileextension="php.dwt" file="Default.php.dwt"> <title>PHP Template</title> <description><![CDATA[Dreamweaver PHP Template document]]></ description> </documenttype> When a Dreamweaver user creates a new blank template of type DWTemplate_PHP, Dreamweaver lets the user create PHP server behaviors in the file. Furthermore, when the user creates instances of the new template, the user can create PHP server behaviors in the instance. In the previous example, when the user saves the template, Dreamweaver automatically adds a .php.dwt extension to the file. When the user saves an instance of the template, Dreamweaver adds the .php extension to the file. Document extensions and file typesBy default, Dreamweaver shows all the file types it recognizes in the File > Open dialog box. After creating a new document type, extension developers need to update the appropriate Extensions.txt file. If the user is on a multiuser system (such as Windows XP, Windows 2000, or Mac OS X), the user has another Extensions.txt file in their Configuration folder. The user must update the Extensions.txt file because it is the instance that Dreamweaver looks for and parses. The location of the user's Configuration folder depends on the user's platform. Windows 2000 and Windows XP platforms use the following location: drive:\Documents and Settings\username\Application Data\Macromedia\Dreamweaver 8\Configuration NOTE In Windows XP, this folder may be inside a hidden folder. Mac OS X platforms use the following location: drive:Users/username/Library/Application Support/Macromedia:Dreamweaver 8/Configuration If Dreamweaver cannot find the Extensions.txt file in the user's Configuration folder, Dreamweaver looks for it in the Dreamweaver Configuration folder. NOTE On multiuser platforms, if you edit the copy of Extensions.txt that resides in the Dreamweaver Configuration folder and not the one in the user's Configuration folder, Dreamweaver is not aware of the changes because Dreamweaver parses the copy of the Extensions.txt file in the user's Configuration folder, not the file in the Dreamweaver Configuration folder. To create a new document extension, you can either add the new extension to an existing document type or create a new document type. To add a new extension to an existing document type:
To add a new document type:
To change the Dreamweaver default File > 0pen file type:
Localized stringsWithin a document type definition file, the <title> and <description> subtags specify the display title and description for the document type. You can use the MMString:loadstring directive in the subtags as a placeholder for providing localized strings for the two subtags. This process is similar to server-side scripting where you specify a particular string to use in your page by using a string identifier as a placeholder. For the placeholder, you can use a special tag or you can specify a tag attribute whose value is replaced. To provide localized strings, perform the following steps:
NOTE String identifiers, such as myJSPDocType/Description in the previous example, must be unique within the application. Dreamweaver, when it starts, parses all XML files within the Configuration/Strings folder and loads these unique strings. Rules for document type definition filesDreamweaver lets document types that are associated with a server model share file extensions. For example: ASP-JS and ASP-VB can claim .asp as their file extension. (For information on which server model gets preference, see "canRecognizeDocument()" on page 424.) Dreamweaver does not let document types that are not associated with a server model share file extensions. If a file extension is claimed by two document types where one type is associated with a server model and the other is not, the latter document type gets preference. Suppose you have a document type called SAM, which is not associated with a server model, that has a file extension of .sam, and you add this file extension to the ASP-JS document type. When a Dreamweaver user opens a file that has a .sam extension, Dreamweaver assigns the SAM document type to it, not ASP-JS. Opening a document in DreamweaverWhen a user opens a file, Dreamweaver follows a series of steps to identify the document type based on the file's extension. If Dreamweaver successfully finds a unique document type, Dreamweaver uses that type and loads the associated server model (if any) for the document that the user is opening. If the user has selected to use Dreamweaver UltraDev 4 server behaviors, Dreamweaver loads the appropriate UltraDev 4 server model. If the file extension maps to more than one document type, Dreamweaver performs the following actions:
If Dreamweaver cannot map the file extension to a document type, Dreamweaver opens the document as a text file. Customizing workspace layoutsDreamweaver lets you customize the workspace layout, including which panels are in the specified layout, as well as other attributes such as the positions and sizes of the panels, their collapsed or expanded states, the position and size of the application window, and the position and size of the Document window. The workspace layout is specified in XML files stored in the Configuration/Workspace layouts folder. The following sections describe the syntax of the XML tags. Optional attributes are marked in the attribute lists with curly braces ({}); all attributes not marked with curly braces are required. <panelset>Description Outermost tag, which signals the start of the panel set description. Attributes None. Contents This tag may contain one or more <application>, <document>, or <panelset> tags. Container None. Example <panelset> <!-- panelset tags here --> </panelset> <application>Description Specifies the application window's initial position and size. Attributes rect, maximize
Contents None. Container This tag must be contained in a panelset tag. Example <panelset> <application rect="0 0 1000 1200" maximize="false"> </application> </panelset> <document>Description Specifies the Document window's initial position and size. Attributes rect, maximize
Contents None. Container This tag must be contained in a panelset tag. Example <panelset> <document rect="100 257 1043 1200" maximize="false"> </document> </panelset> <panelframe>Description Describes an entire panel group. Attributes x, y, {width, height}, dock, collapse
Contents This tag must contain one or more panelcontainer tags. Container This tag must be contained in a panelset tag. Example <panelset> <panelframe rect="196 453 661 987" visible="true" dock="floating"> <!-- panelcontainer tags here --> </panelframe> </panelset> <panelcontainer>Description Describes an entire panel group. Attributes expanded, title,{ height,} activepanel, visible, maximize, maxRestorePanel, maxRestoreIndex, maxRect, tabsinheader
Contents This tag must contain one or more panel tags. Container This tag must be contained in a panelframe tag. Example <panelset> <panelframe rect="196 453 661 987" visible="true" dock="floating"> <panelcontainer title="Color" height="250" visible="true" expanded="true" activepanel="20"> <!-- panel tags here ---> </panelcontainer> </panelframe> </panelset> <panel>Description Specifies the panel that appears in the panel container. Attributes id, visibleTab
Contents None. Container This tag must be contained in a panelcontainer tag. Example <panelset> <panelframe rect="196 453 661 987" visible="true" dock="floating"> <panelcontainer title="Color" height="250" visible="true" expanded="true" activepanel="20"> <panel ></panel> </panelcontainer> </panelframe> </panelset> Customizing the Code view toolbarThe Code view toolbar displays 15 buttons initially. This is a subset of the buttons that are available. You can customize the Code view toolbar by changing the buttons that appear on the toolbar and the order in which they appear by editing the file Configuration/Toolbars/Toolbars.xml. You can also insert your own buttons into the toolbar through the Extension Manager. To change the order of button:
To remove a button:
To make any buttons that are not visible in the toolbar appear, you remove the comment that surrounds a button in the XML file. |
< Day Day Up > |