Accessibility

TechNote (Archived)

Understanding importing and exporting XML and templates

Understanding XML and templates
Dreamweaver provides options under the File > Import and File > Export menu that mention XML. The purpose of this TechNote is to explain how these XML options can be used.

Importing and exporting XML
At first, importing and exporting XML might seem to be two functions that would naturally follow one after the other, similar to cut and paste. In actual practice, these options offer two distinct functions. Usually only one is used at a time, although occasionally both may be used in conjunction with each other.

Export editable regions as XML:

Exported XML from a Dreamweaver template can be emulated by a third party application that will generate XML content that will later be inserted into the editable regions of a template.

Editable regions from one template can be exported for later insertion into pages created from a second template.

Note:Additional steps are required to accomplish this. Please see the below steps on Importing XML into a page created from a second template.

Import XML into a Dreamweaver template:

Used to create a new page from a template, inserting the selected XML content into the matching editable regions of the template.

Used to insert the exported editable regions from a page created from one Dreamweaver template into the editable regions of a page created from a second Dreamweaver template.

Note:Additional steps are required to accomplish this. Please see the below steps onImporting XML into a page created from a second template.

Developers may also choose to insert the editable regions from one Dreamweaver template into a page created from a second Dreamweaver template. This can be accomplished by using the "Export Editable Regions as XML" option to export the editable regions from the original template as XML. The developer can then insert the XML created from this original template into a second template using the "Import XML into Template" option, provided that the names of the editable regions in both templates match. Please refer to the steps on Importing XML into a page created from a second template for details on how to accomplish this.

Static content vs. dynamic content
It is important to understand that using the "Import XML into Template" option and the"Export Editable Regions as XML" option enables the creation of static Dreamweaver pages. These features must be not be misconstrued as a way to introduce dynamically generated database content into pages created from Dreamweaver templates. These options enable the creation of new pages from templates that have XML content inserted into the editable regions of the template. It is also important to understand that these options are not used for modifying existing pages or templates, but rather as a way to create new pages.

Understanding the "Export Editable Regions as XML" option
A developer may want to export the editable regions from a Dreamweaver template for the purpose of emulating structure of the Dreamweaver generated XML document. Some database applications have the capability to export database content as XML, thus allowing the data to be inserted into pages created from Dreamweaver templates. To accomplish this, the XML generated by the database application should exactly match the XML document that Dreamweaver generates. By using the "Export Editable Regions as XML" feature in Dreamweaver, developers have an XML model which they can then have their database application emulate.

Developers may also wish to insert the editable regions from one Dreamweaver template into a page created from a second Dreamweaver template. This can be accomplished by using the "Export Editable Regions as XML" option to export the editable regions from the original template file as XML. The XML created from this original template can be inserted into a second template using the"Import XML into Template" option, provided that the names of the editable regions in both templates match. Please refer to the steps below on Importing XML into a page created from a second template for details on how to accomplish this.

Understanding the "Import XML into Template" option
The"Import XML into Template" option is similar to creating a new page from a template. Rather than importing XML content into a template, this feature is best explained as selecting the "File > New from Template" menu item with the added functionality of "include XML content in the editable regions of the template". When the "Import XML into Template" option is selected from the File menu, Dreamweaver asks for the XML file that will be imported into the template. If the XML file was created with "Export XML from Template", Dreamweaver will not ask the user to select the template into which the user will be importing the XML. This is because there is already a reference in the selected XML page that describes the path to the template. If Dreamweaver cannot find the template, then it reports an error and does not ask the user to select a different template. Dreamweaver may not find the template if the XML file was created on a different machine that had a different local root folder defined. Dreamweaver will also not find the template if the entire path name is not specified. Dreamweaver asks the user to select a template only if a template is not specified.

Dreamweaver opens a new page from this referenced template and inserts the XML content into the matching editable regions of the XML document and the template. The XML document, the original template and the editable regions inside this template remain unchanged.

Note:Dreamweaverprovides no warnings if the editable regions do not match. Unmatched content in the XML file is simply ignored. Unmatched regions in the template will contain the default text from the template.

Importing XML into a page created from a second template
Dreamweaver opens a new document after selecting the Import XML into Template option, combining the selected XML content with the editable regions of the template referenced in the XML document. Sometimes, a developer may want to import the XML content into a template other than the one from which the XML file was created. This is possible if one follows the below steps to change the code that references the path to the original template to the path of a different template.

Note:Dreamweaver provides no warnings if the editable regions do not match. Unmatched content in the XML file is simply ignored. Unmatched regions in the template will contain the default text from the template.

Below are steps to import XML into a page created from a second template:

1

Open the exported XML file in Notepad or Simple Text.

2

Identify the line of code that describes the path to the template.

3

Either remove the path entirely or change the path to reference the template into which the XML content will be added. In this example, the XML will be added to a page created from the template named "my_template".

4 Save the XML file.
5

Selecting the option "Import XML into Template" will create a new document that inserts the XML content from "template1.xml" into the editable regions of the template "my_template.dwt". If the entire path was removed, Dreamweaver will ask the user to select a template from one of the defined sites.

Note:There must be matching editable regions in both templates for the above steps to work. In this example, both "template2.dwt" and "my_template.dwt" must have an editable region named "table1". Below is the reference to the editable region "table1" found in the XML document originally created from "template1.dwt".

Additional information
For more instructions on using templates in Dreamweaver, please refer toTemplates and Libraries pages of the Dreamweaver Support Center.



AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:tn_14365

Products Affected: