beautypg.com

Translatemarkup() – Adobe Extending Dreamweaver CS4 User Manual

Page 351

background image

345

EXTENDING DREAMWEAVER CS4

Data translators

Description
Dreamweaver performs two translation passes. The first pass goes through all the translators and calls the

translateMarkup()

functions. After those functions are called, the second pass calls the

translateDOM()

functions.

The

dom

passed in is the

dom

to translate. The only edits that are allowed during the second pass are those dealing with

translated attributes.

Arguments
dom, sourceStr

The dom argument.

The sourceStr argument is the same string passed into

translateMarkup

. It's provided for reference, but all

translation should be done on the dom argument, not the sourceStr argument.

Returns
Dreamweaver expects nothing.

Example

translateDOM( dom, sourceStr ); //returns nothing

The following instance of the

translateDOM()

function hides the tag with ID

div1

in the document.

function translateDOM(dom, sourceStr){

var div1 = dom.getAttributeById("div1");
if (div1){
div1.style.display = "none";
}

}

translateMarkup()

Description
This function performs the translation.

Arguments
docName, siteRoot, docContent

The docName argument is a string that contains the file:// URL for the document to be translated.

The siteRoot argument is a string that contains the file:// URL for the root of the site that contains the document to
be translated. If the document is outside a site, this string might be empty.

The docContent argument is a string that contains the contents of the document.

Returns
A string that contains the translated document or an empty string if nothing is translated.

Example
The following instance of the

translateMarkup()

function calls the C function

translateASP()

, which is contained

in a dynamic link library (DLL) (Windows) or a code library (Macintosh) called ASPTrans:

This manual is related to the following products: