Beruflich Dokumente
Kultur Dokumente
PowerDynamo
Version 3.5
MC00341
Last revised: October 1999
Copyright © 1989-1999 by Sybase, Inc. All rights reserved.
This publication pertains to Sybase database management software and to any subsequent release until otherwise indicated in new
editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished
under a license agreement, and it may be used or copied only in accordance with the terms of that agreement.
To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.
Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All other
international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled
software release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic,
mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.
Sybase, the Sybase logo, ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive Server,
Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server Enterprise Replication,
Adaptive Server Everywhere, Adaptive Server IQ, Adaptive Warehouse, AnswerBase, Anywhere Studio, Application Manager,
AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-FORMS, APT-Translator, APT-Library, Backup Server,
ClearConnect, Client-Library, Client Services, Data Pipeline, Data Workbench, DataArchitect, Database Analyzer, DataExpress,
DataServer, DataWindow, DB-Library, dbQueue, Developers Workbench, Direct Connect Anywhere, DirectConnect, Distribution
Director, E-Anywhere, E-Whatever, Embedded SQL, EMS, Enterprise Application Server, Enterprise Application Studio, Enterprise
Client/Server, Enterprise Connect, Enterprise Data Studio, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work
Architecture, Enterprise Work Designer, Enterprise Work Modeler, EWA, Gateway Manager, ImpactNow, InfoMaker, Information
Anywhere, Information Everywhere, InformationConnect, InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase,
MainframeConnect, Maintenance Express, MAP, MDI Access Server, MDI Database Gateway, media.splash, MetaWorks, MySupport,
Net-Gateway, Net-Library, NetImpact, ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access Module, OmniSQL Toolkit,
Open Client, Open ClientConnect, Open Client/Server, Open Client/Server Interfaces, Open Gateway, Open Server, Open
ServerConnect, Open Solutions, Optima++, PB-Gen, PC APT Execute, PC DB-Net, PC Net Library, Power++, power.stop, PowerAMC,
PowerBuilder, PowerBuilder Foundation Class Library, PowerDesigner, PowerDimensions, PowerDynamo, PowerJ, PowerScript,
PowerSite, PowerSocket, Powersoft, PowerStage, PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare
Desktop, PowerWare Enterprise, ProcessAnalyst, Report Workbench, Report-Execute, Replication Agent, Replication Driver,
Replication Server, Replication Server Manager, Replication Toolkit, Resource Manager, RW-DisplayLib, RW-Library, S Designor, S-
Designor, SDF, Secure SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners, smart.parts, smart.script, SQL
Advantage, SQL Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU, SQL Everywhere, SQL
Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL SMART, SQL Toolset, SQL Server/CFT, SQL Server/DBM, SQL
Server SNMP SubAgent, SQL Station, SQLJ, STEP, SupportNow, Sybase Central, Sybase Client/Server Interfaces, Sybase Financial
Server, Sybase Gateways, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase User Workbench,
SybaseWare, Syber Financial, SyberAssist, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular Data Stream,
Transact-SQL, Translation Toolkit, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Viewer, Visual
Components, VisualSpeller, VisualWriter, VQL, WarehouseArchitect, Warehouse Control Center, Warehouse Studio, Warehouse
WORKS, Watcom, Watcom SQL, Watcom SQL Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup
SQL Server, XA-Library, XA-Server and XP Server are trademarks of Sybase, Inc. 9/99
Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.
All other company and product names used herein may be trademarks or registered trademarks of their respective companies.
Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-
7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies.
iii
iv
Contents
v
Contents
vi
Contents
viii
Contents
x
Chapter
xi
xii
About This Book
Subject This manual describes PowerDynamo, a suite of tools for building and
managing database-hosted Web sites and for enabling intranets for a
mobile workforce.
Audience This manual is for users who want to build Web sites with dynamic
content. For reference type information, see the PowerDynamo Reference.
Before you begin This manual assumes that you are moderately familiar with HTML,
ECMAScript (the standardized version of JavaScript) and the operations
of Web browsers and servers.
Introducing PowerDynamo
You can use PowerDynamo to store, manage, and access both static
HTML and dynamic database data. You can then make that information
available over the Internet for not only information delivery but also for
use by Web-hosted client/server applications.
You can combine PowerDynamo with Sybase SQL Remote replication
technology to replicate Web templates and dynamic content onto a laptop
computer for offline use.
SQL Remote allows data and HTML templates to be replicated in both
directions, so you can run client/server applications offline and SQL
Remote can update your changes to the central server.
New Features
This release of PowerDynamo has several major new features:
•Java You can access Java classes from within Dynamo scripts. For
information see “PowerDynamo and Java” on page 145.
xiii
About this book
•XML PowerDynamo now supports XML You can create queries that
generate output in either HTML or XML. For more information see
“Working with XML Documents” on page 165.
•Mail Several objects have been added to PowerDynamo that enable the
sending, receiving, and manipulation of mail from within a PowerDynamo
Web site. For more information see “PowerDynamo Mail Support” on
page 203.
•FTP Several objects have been added to PowerDynamo that provide FTP
functionality to PowerDynamo Web sites. These objects are documented
in “DynaScript Predefined Objects” in the PowerDynamo Reference.
•ECMAScript compatible PowerDynamo is now ECMAScript
compatible. The ECMAScript objects are documented in “DynaScript
Predefined Objects” in the PowerDynamo Reference.
•Invoking Jaguar CTS components PowerDynamo clients can access
Jaguar components through Java, ActiveX, SQL queries or PowerDynamo
tags. For information on PowerDynamo and Jaguar see “Calling Jaguar
Component Methods from PowerDynamo” on page 261.
•UNIX Dynamo is now available on AIX with NSAPI, CGI, and the
Personal Web Server. CGI and the Personal Web Server are now available
on Solaris (NSAPI is supported from previous Dynamo releases).
xiv
About this book
• DOMCharacterData object
• DOMComment object
• DOMDocument object
• DOMDocumentFragment object
• DOMDocumentType object
• DOMElement object
• DOMEntity object
• DOMEntityReference object
• DOMImplementation object
• DOMNamedNodeMap object
• DOMNode object
• DOMNodeList object
• DOMNotation object
• DOMProcessingInstruction object
• DOMText object
The following properties and methods are new to PowerDynamo
• java.CreateObject( )
• java.GetHomeInterface()
• java.GetUserTransaction()
• query.cursorType
• query.stripTrailingBlanks
• query.ResultsToXMLString( )
xv
About this book
PowerDynamo tags
The following tags have been added to PowerDynamo:
• COMPONENT
• ENDIF
• ELSE
• ELSEIF
• FORMAT_AS (attribute on FORMATTING tag)
• IF
• MAILPIECE
• STRIP_TRAILING_BLANKS (attribute on FORMATTING tag)
• USE_CDATA (attribute on FORMATTING tag)
xvi
About this book
Syntax conventions
The following conventions are used for syntax diagrams in this manual:
xvii
About this book
xviii
CH A PTE R 1 Databases and the Internet
About this chapter This chapter introduces basic Internet and World Wide Web concepts, and
describes the increasingly important role of databases on the Internet. It
also provides an overview of the pieces that make up PowerDynamo.
Contents
Topic Page
Basic Web concepts 2
Databases and the Web 5
A glance at PowerDynamo 9
1
Basic Web concepts
2
CHAPTER 1 Databases and the Internet
How information is To move from one page of a document to another page, or to another document
located: the URL on the same or another Web site, the user clicks a hyperlink (usually just called
a link) in the document shown in their Web client. Documents and locations
within documents are identified by an address, defined as a Uniform Resource
Locator, or URL. The following URL illustrates the general form:
http://www.sybase.com/productsl
or
http://www.sybase.com/inc/corpinfo/mkcreate.html
URLs contain information about which server the document is on, and may
also specify a particular document available to that server, and even a position
within the document. In addition, a URL may carry other information from a
Web client to a Web server, including the values entered into fields in an HTML
form.
For more information about URLs and addresses on the Web, see the material
on the World Wide Web Consortium pages, at the following address:
http://www.w3.org/pub/WWW/Addressing/
When a user clicks a link on a document on their Web client, the URL is sent
to the server of the indicated Web site. The Web server locates the document,
and sends the HTML to the Web client across the network.
External data in HTML HTML documents can include graphics or other types of data by referencing
documents an external file (for example, a GIF or JPEG file for a graphic). Not all these
external formats are supported by all Web clients. When the document contains
such data, the Web client can send a request to the Web server to provide the
relevant graphic. If the Web client does not support the format, it does not
request the information from the server.
Problems with file- In a file-based Web site, each resource is a separate file. For large Web sites,
based Web sites this leads to management problems. For example, maintaining current copies
of hundreds or thousands of different resources in separate files is difficult
enough; maintaining the links between these resources is even more
challenging.
Another problem is that many Web sites contain information that is dynamic–
pricing information, for example, or employee information on an
organization's Intranet. Maintaining such information in HTML files in
addition to the database where it resides is a huge task.
3
Basic Web concepts
For these and other reasons, linking databases to the Web is increasingly the
solution of choice for management of large Web sites and management of
dynamic content. Database storage of Web information can either replace or
complement file storage of Web resources.
4
CHAPTER 1 Databases and the Internet
5
Databases and the Web
Web server interfaces CGI (Common Gateway Interface) is a standard Web server interface. When a
Web server receives a URL corresponding to a CGI resource, it starts a CGI
program (such as a perl script, or the PowerDynamo Application Server)
which connects to the DBMS, queries the database, and returns the information
to the Web server to be handed on to the Web client.
CGI is a standard for interfacing any external application with a Web server,
not just a DBMS. CGI applications may also simply process files. The output
of the CGI program or script is returned to the Web server. This output can be
an HTML document, an image, a reference to another document, or any other
form of information understood by the Web server.
CGI is an industry-standard Web server interface. Some Web server vendors
also provide proprietary interfaces to their servers: NSAPI (Netscape
Application Programming Interface) and Microsoft ISAPI (Internet Server
Application Programming Interface) are two examples supported by
PowerDynamo.
6
CHAPTER 1 Databases and the Internet
The static components of the page are stored in an HTML document called a
template. The template consists of the static HTML text (which is passed on to
the Web client without change) together with the query or other instruction
defining the dynamic component of the page, and the layout instructions
governing the display of the data.
The query tags are interpreted by the application server and replaced by a result
set when the document is generated. The application connecting the database
to the Web server replaces the query with its data, formatted according to the
instructions, and sends the resulting page to the Web server for relay to the Web
client.
7
Databases and the Web
8
CHAPTER 1 Databases and the Internet
A glance at PowerDynamo
PowerDynamo includes Web-site management features and mobile Intranet
capabilities.
Building Web With PowerDynamo, you can embed instructions into any Web page, and
applications and process these instructions when providing HTML to a Web client for viewing
managing Web sites
or interaction. PowerDynamo supports the following kinds of embedded
instructions:
•Tags You can embed SQL statements and manipulate returned data within
a document.
•SQL statements You can place up-to-date database query results into a
Web page.
•Scripts You can include programmatic control (conditional execution,
looping, and so on) in your Web pages.
•Text replacement and host variable macros You can respond to HTML
forms and other variables supplied by a Web client.
The Web-site management utility, Sybase Central, manages all aspects of
dynamic Web content:
• Authoring
• Site management
• Application servers for deployment on a Web site managed by some other
Web server.
• A Personal Web Server for offline access to data and Web documents, and
for developing Web site content.
The interpreter
At the core of PowerDynamo is an interpreter which processes specially tagged
instructions embedded in the HTML pages or other documents, and serves the
resulting output together with static HTML to an application such as a Web
server.
The PowerDynamo interpreter is built into several components:
• The Web-site management tool, for managing a database-hosted Web site
• Application servers that link your database and your Web server
9
A glance at PowerDynamo
• The Personal Web Server, for working offline with dynamic Web content
Web-site management
PowerDynamo includes a Web site management tool for managing HTML
templates and connections. PowerDynamo focuses on combining HTML
documents with database data, and the Web-site management utility plugs in to
the Sybase Central database management utility, bringing management of both
technologies under the single roof of Sybase Central, using a consistent
interface.
PowerDynamo provides tools for the following management tasks:
• Wizard-based HTML template creation.
• Folder-based arrangement of HTML templates to map onto a file-based
Web site's directory structure.
• Syntax-highlighting editor. HTML tags, embedded SQL, and scripts are
all highlighted.
• Browsing and syntax highlighting of output HTML.
• Scheduled processing of scripts and templates. This process is particularly
useful for pages that would take a long time to generate.
Sybase Central requires either the Windows 95 or the Windows NT operating
system.
The Web-site management utility is a plug-in to the Sybase Central database
management tool, so that you manage your data and your Web site from the
same Sybase Central interface.
10
CHAPTER 1 Databases and the Internet
11
A glance at PowerDynamo
Text substitution and To enable real interaction between a Web client and the Web server, an action
host variables at the client (clicking on a button after filling out a form, for example) must
send information to the Web server, and this information must be used by the
application server in formulating its response. PowerDynamo supports this
function using: text substitution macros and host variables. Both are sent to the
Web server as part of the address when a link or button in the client is clicked.
You can include a macro in an HTML template. This macro is expanded by the
interpreter when the template is processed, being replaced by its value.
The value of a macro is defined in the URL when the page is accessed. The
following example shows how text substitution works.
1 A user at a Web client fills out an HTML form to subscribe to a service.
The form includes fields for their first and last name.
2 When the form is sent to the Web server, the user’s entry is sent along with
the request in the URL. The standard form for such an inclusion is:
http://www.organization.com/template-
name?firstname=Jane&lastname=Smith
3 In the HTML template, the symbol $firstname is replaced by Jane and the
symbol $lastname by Smith wherever they appear. For example, a returned
acknowledgment may include the text:
Dear Jane Smith,
Thank you for your registration. Your registration
number is 123-456.
For more information about text substitution, see “Passing variables from one
document to another” on page 52.
For more information about text substitution with DynaScript, see “value
property” in PowerDynamo Reference.
While text substitution macros are ideal for general-purpose substitution, there
are some circumstances where a similar but alternative method has
performance advantages. Host variables can be specified in a SQL statement
and the statement could be executed repeatedly without being reparsed,
providing significant performance improvements.
12
CHAPTER 1 Databases and the Internet
13
A glance at PowerDynamo
14
CH A PTE R 2 Getting Started with
PowerDynamo
About this chapter This chapter contains a set of tutorials that introduce you to the core
features of PowerDynamo.
Contents
Topic Page
Overview 16
Looking at the sample Web site 20
Creating a template 22
Creating a script 25
Viewing template output in a browser 27
15
Overview
Overview
The tutorials in this chapter guide you through:
• Inspecting the sample Web site included in PowerDynamo, using Sybase
Central.
• Creating a dynamic HTML page containing a SQL query and viewing the
results of the query.
• Creating a template containing a script.
• Accessing the templates you have created from a Web client (browser) on
your own machine. This tutorial introduces the PowerDynamo Personal
Web Server.
• Accessing the templates you have created from a Web client elsewhere on
a network.
Topics covered in This chapter does not include how to incorporate a PowerDynamo Web site
other chapters into an existing Web site managed by a Web server – see “Configuring Web
Servers and Web sites” on page 71.
Also, this chapter does not cover development of a mobile intranet, although
many of the concepts and tools you need are covered. For more information on
mobile intranets and SQL Remote replication technology, see “Setting Up a
Mobile Intranet” on page 241.
16
CHAPTER 2 Getting Started with PowerDynamo
17
Overview
18
CHAPTER 2 Getting Started with PowerDynamo
For users of Windows 95 or Windows NT 4.0, the Dynamo programs are added
to the Start Menu, under Programs | Sybase | PowerDynamo 3.5. For users of
Windows NT 3.51, the programs are added to the PowerDynamo 3.5 program
group.
PowerDynamo is accessible through Sybase Central. Sybase Central can be
started either from within the Sybase program group (Start | Programs | Sybase
| Sybase Central) or from within the PowerDynamo program group under the
heading of Manage PowerDynamo (Start | Programs | Sybase | PowerDynamo
3.5 | Manage PowerDynamo).
19
Looking at the sample Web site
20
CHAPTER 2 Getting Started with PowerDynamo
21
Creating a template
Creating a template
In this tutorial you create an HTML template that includes a SQL query. A Web
client accessing this template will receive the formatted results of the SQL
query.
22
CHAPTER 2 Getting Started with PowerDynamo
Templates are created with default extensions of .stm. We recommend that you
keep this extension for all your templates.
The query and formatting instructions are included in the HTML as specially
formatted HTML comments.
-->
23
Creating a template
24
CHAPTER 2 Getting Started with PowerDynamo
Creating a script
In this tutorial you create an HTML template that includes a script. Scripts
provide programmatic control over the content of the HTML page. For
example, they can be used to respond to forms filled out and submitted from a
Web client.
-->
7 Add lines to the script, so it reads as follows:
<!--SCRIPT test.ssc
/* A test script*/
document.Write ( "<HTML><BODY>" ) ;
document.Write ( "<H1>A first heading</H1>") ;
document.Write ( "</BODY></HTML>" ) ;
-->
These instructions write text into the document produced by the script.
For information about the Dynamo script language, see “The DynaScript
Language” in PowerDynamo Reference.
8 Click the database icon to save the script.
25
Creating a script
2 Select Execute from the pop-up menu. The output displays in the Sybase
Central syntax-highlighting editor.
26
CHAPTER 2 Getting Started with PowerDynamo
27
Viewing template output in a browser
• Double-click the Personal Web Server icon in the right pane of Sybase
Central.
• The Personal Web Server will be displayed as a small “tray icon” at
the opposite end of the taskbar from the Start menu when it is running.
The software installation configures the Personal Web Server to access the
PowerDynamo sample Web site, so that no further configuration is
needed.
2 Start your browser or other Web client.
3 Type the following URL into the address field of your browser or Web
client:
http://localhost/Site/products.stm
• The Site part of the URL directs the Personal Web Server to access data in
a PowerDynamo Web according to the information specified for the “Site”
mapping. For more information about mappings, see “Configuring Web
sites” on page 100.
• products.stm directs the Personal Web Server to access the products.stm
template from the Web site, process it, and return the output to the browser.
28
CHAPTER 2 Getting Started with PowerDynamo
29
Viewing template output in a browser
• The Site part of the URL directs the Personal Web Server to access data in
a PowerDynamo Web site according to the information specified for the
“Site” mapping.
For more information about mappings, see “Configuring Web sites” on
page 100.
products.stm directs the Personal web Server to access the products.stm
template from the Web site, process it, and return the output across the
network to the browser.
30
CH A PTE R 3 Working with Dynamo Web Sites
About this chapter This chapter describes some basic elements of managing PowerDynamo
Web sites.
For information on Web server configuration issues, see “Configuring
Web Servers and Web sites” on page 71.
Contents
Topic Page
Working with Web sites 32
The Utilities folder 41
Working with folders and documents in your Web site 42
Working with templates 46
Scheduling actions 57
Working with connections 60
Copying a Web-site database [Adaptive Server Anywhere] 69
Using the Performance Monitor 70
31
Working with Web sites
32
CHAPTER 3 Working with Dynamo Web Sites
Storing documents on Not all the documents in a site need be held in a database. Web sites can also
disk contain documents stored in folders on disk.
For information about creating dynamic file-based Web sites see “Creating a
dynamic file-based Web site” on page 36
For more information about storing documents on disk and linking these into a
database-hosted Web site, see “Linking folders to directories on disk” on page
43.
33
Working with Web sites
34
CHAPTER 3 Working with Dynamo Web Sites
• The connection information (database, user ID, and so on) that you fill in
when you first connect to the Web site serves two functions. It is the owner
of the tables containing the template and script data, and it is provided as
a connection called <default> which can be used for data referenced in
queries in templates.
35
Working with Web sites
Caution
All files in the target directory will be deleted when creating a dynamic file-
based Web site. If there are read-only files in this directory the Web site will
not be created.
36
CHAPTER 3 Working with Dynamo Web Sites
37
Working with Web sites
<HTML>
<TITLE>testthis.stm</TITLE>
<BODY>
<H1></H1>
<!--SCRIPT
myConn = site.GetConnection("Conn1");
if( myConn == null ) {
myConn = site.CreateConnection("Conn1", "My test
connection", "Adaptive Server Anywhere 5.0 Sample",
"dba", "sql");
}
-->
<!--SQL CONNECTION_OBJECT=myConn
SELECT contact.last_name, contact.first_name,
contact.title
FROM DBA.contact contact
-->
<TABLE BORDER>
<TR>
<TH>last_name</TH>
<TH>first_name</TH>
<TH>title</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
</BODY>
</HTML>
38
CHAPTER 3 Working with Dynamo Web Sites
39
Working with Web sites
Caution
Regenerating a Web site deletes the entire content of the Web site. This action
cannot be undone.
Caution
Deleting a Web site deletes the entire content of the Web site. This action
cannot be undone.
40
CHAPTER 3 Working with Dynamo Web Sites
41
Working with folders and documents in your Web site
Creating folders
To add a folder to a Web site:
1 Use Sybase Central to connect to a Web site.
2 Open the folder within which you want to create a new folder.
3 Double-click Add Folder in the right pane.
4 Enter a name for your folder, and click Next. Do not use spaces, as not all
Web servers and browsers handle spaces correctly.
5 If your Web site has more than one connection, select the connection for
the documents in this folder to use as a default. For more information
about connections, see “Working with connections” on page 60.
6 Enter an optional description of the folder, and click Finish.
42
CHAPTER 3 Working with Dynamo Web Sites
1 From Sybase Central, open the Web site folders until you see the folder or
document you want to move or copy.
2 To move the folder or document, drag the icon to the desired location. To
copy it, press the Ctrl key while you drag the icon.
Caution
Deleting a folder deletes all the contents of that folder and cannot be undone.
43
Working with folders and documents in your Web site
Linked Folders
You cannot create a linked folder inside a linked folder.
Linked folders are applicable only to database-based Web sites.
44
CHAPTER 3 Working with Dynamo Web Sites
45
Working with templates
Creating a template
This section describes how to add a template to your Web site. The example
describes a template displaying a table of information about current products
sold by the company.
❖ To create a template:
1 Use Sybase Central to connect to a Web site.
2 In the left pane, select the folder where you want to create the new
template. You may have to expand the Web site container to do this.
3 In the right pane, double-click Add Template.
4 On the first page of the wizard enter a name for the template, for example,
Products. Do not use spaces. Click Next.
5 Enter an optional description for the template and click Next.
6 If your Web site has more than one connection, select a default connection
for this template. For more information about connections, see “Working
with connections” on page 60.
7 On the Add SQL Query page, click Select and enter the query using the
query tab window. You can enter a query manually if you wish.
8 Select HTML or XML as the type of document to create.
9 Specify the type of formatting you would like. These options are different
depending on the choice you made in the previous step.
If you chose HTML as the document output, you must provide the type of
HTML format you wish to use for the output.
If you chose XML as the document output you are asked to provide tags
for the output or to select existing tags.
10 Click Finish to add the template to the Web site.
46
CHAPTER 3 Working with Dynamo Web Sites
You can view the contents of the template in several ways, as described in
“Viewing and editing templates” on page 48.
Selecting an HTML The Add Template wizard provides you with a list of formats to choose from.
output format for your
template •Tables Tables, with or without headings, are useful for queries returning
several columns of results.
The default table has a border to separate the data fields. After you have
completed the wizard, you can customize the attributes of the table using
a Web authoring tool or Sybase Central.
•Definition List A definition list displays queries with two columns, as a
list. Each list item has a term and a description. For example, you might
use a definition list for a glossary:
<DL>
<DT>Otley
<DD>A market town in Wharfedale
<DT>Wharfedale
<DD>A valley in Yorkshire, U.K.
</DL>
If you use the definition list format for a query with more than two
columns, any extra columns are concatenated into the description.
•Ordered and unordered lists These types of lists are useful primarily for
queries that return a single column. Markings for an ordered and
unordered list are dependent on the browser but in most cases an
unordered list is marked by bullets and an ordered list is marked by
numbers.
•Detail This is useful for queries with any number of columns. Each field
is shown on a separate line.
•Link This is most useful for three-column queries. An unordered list of
links is created such that column 1 is the link’s URL, column 2 is the text
that gets displayed for the link (the part that is usually underlined in the
browser), and column 3 (and onward) become the text that is displayed
after the link.
•Paragraph This is useful primarily for single column queries: each row of
the result set is placed in a separate paragraph.
47
Working with templates
48
CHAPTER 3 Working with Dynamo Web Sites
The instructions embedded in the template are not present in the output
HTML document. Instead, the results of those instructions are displayed
along with the HTML tags.
49
Working with templates
50
CHAPTER 3 Working with Dynamo Web Sites
All material inside the angle brackets is ignored by an HTML parser such as
that included inside a Web client. Thus, a Web client can view a template, and
it will ignore the material inside the comment tags. If you edit the template
using an HTML authoring tool it will ignore the embedded instructions. Of
course, the SQL statements are not seen by a Web client, as they are interpreted
and executed by the PowerDynamo Application Server.
SQL statements are embedded in an HTML document as follows:
<!--SQL
sql-statement
-->
The SQL statement itself can continue over several lines. It should start on a
separate line from the SQL comment tag.
Example The following HTML fragment contains a simple query.
<!--SQL
SELECT name, color, size, unit_price
FROM "dba".product
-->
Naming a SQL You can provide an identifying name for an embedded query. This is useful, for
statement example, if you have more than one SQL statement in a template.
To name a SQL statement, provide a name for a SQL statement as the NAME
attribute for the SQL comment tag. The following SQL statement has a name
of ProductQuery:
<!--SQL NAME=ProductQuery
SELECT name, color, size, unit_price
FROM "dba".product
-->
The SQL statement itself must start on a separate line from the NAME
attribute.
Formatting query If the embedded SQL statement is a query, then the Application Server inserts
results the results of the query into the output document. PowerDynamo allows you to
describe the formatting of a query using a formatting comment tag.
The HTML tags for formatting instructions are slightly different from the tags
used for SQL statements. To allow an HTML editor to modify and refine the
actual formatting, the formatting description is not inside a comment. Instead,
comment tags are used for placeholders for the data, which are replaced on
processing by the actual data.
51
Working with templates
Start and end All data placeholders must be between formatting start and end comment tags.
formatting comment The formatting start comment tag is of the form
tags
<!--FORMATTING-->
The formatting end comment tag is of the form
<!--/FORMATTING-->
As these are HTML comments, there is no restriction on the HTML that can be
included between the tags. The formatting comment tags have no effect on
HTML that occurs between them; they affect just the embedded instructions.
For more information on Dynamo Tags, see the chapter “Dynamo Tags” in
PowerDynamo Reference.
52
CHAPTER 3 Working with Dynamo Web Sites
<HEAD>
<TITLE>
Test of text substitution
</TITLE>
</HEAD>
<BODY>
<FORM ACTION="reply.stm" NAME="log" METHOD="GET">
<p>Please enter your name.
<ul>
<li>First name:
<INPUT TYPE="text" NAME="firstname" SIZE="15">
<li>Last name:
<INPUT TYPE="text" NAME="lastname" SIZE="15">
</ul>
<p><Center>
<INPUT TYPE="Submit" VALUE="Register">
</Center></p>
</FORM>
</BODY>
</HTML>
This HTML document contains a form, but contains no Dynamo-specific
instructions. The <FORM> tag tells the browser to retrieve reply.stm when
the user clicks Register.
3 Create a new template named reply.stm, without entering any query. Then
edit the document so that it has the following content:
<HTML>
<HEAD>
<TITLE>Test of text substitution</TITLE>
</HEAD>
<BODY>
<p>Dear $firstname $lastname,</p>
<p>Thank you for using our text substitution
facility.
<p>
Yours
<p>
TextSub Corporation.
</BODY>
</HTML>
The $firstname and $lastname entries are text substitution macros. They
are replaced by the values entered in the form when reply.stm is processed.
53
Working with templates
54
CHAPTER 3 Working with Dynamo Web Sites
55
Importing and exporting documents
56
CHAPTER 3 Working with Dynamo Web Sites
Scheduling actions
With PowerDynamo you can schedule a script or template to be executed
periodically.
Scheduling script and template execution provides an alternative way of
quickly providing to users the results of queries that take a long time to run. It
allows the results to be kept up to date, while allowing quick and efficient
access from Web clients.
The output of a scheduled script is stored in the Web site and available to users.
❖ To schedule a script:
1 Use Sybase Central to locate the script or template you want to schedule.
2 Right-click the script or template and select Schedule from the menu. This
will start the schedule wizard.
3 Select the appropriate time interval from the pull down menu in the
wizard.
4 The second screen of the wizard allows you to enter a time interval, at
which the document is to be generated. If you do not enter the time interval
exactly as specified in the following table default values will be used.
You must use a 24 hour clock to enter time intervals. Time interval values
are not case sensitive.
57
Scheduling actions
File replaced with its The file containing the script or template is modified to instead contain the
output output of the document. In this manner, you can change a script or template
from on-demand processing to scheduled processing without changing the
URL.
Original file saved to a The contents of the original script or template are saved in a file with the same
different location name but a changed extension. The extension for script source is sss, while the
extension for template source is sts. The source is saved in the same directory
as the original script.
The contents of the ssc or stm file are altered to indicate that the contents are
pre-generated from a scheduled script or template.
The schedule.ssc document in the system directory is altered to add a call to
site.Schedule(). This call adds the scheduled document to the list of
scheduled documents. The schedule.ssc document is imported by autoexec.ssc.
58
CHAPTER 3 Working with Dynamo Web Sites
59
Working with connections
60
CHAPTER 3 Working with Dynamo Web Sites
61
Working with connections
• <default>
• myConnection1
• myConnection2
and you set the minimum number of user connections to five, five of each of
the above connection definitions would be held in the connection pool. In other
words, once the connection pool was fully populated, there would never be less
than fifteen connections.
For information on setting connection defaults see “Changing Dynamo
configuration settings” on page 106.
Connection definitions
Each folder, template, and script object has a connection definition associated
with it, and all SQL statements within that object are executed using that
connection. The connection definition is assigned when the object is created.
You can override the default connection definition by getting another
connection (site.GetConnection) or by using the attributes on a SQL tag. For
example, if your data is stored in a different database than your Web site
content, you may wish to execute SQL statements using another connection.
There are four user connection definitions:
•<default> The connection specified when you create a database-based
Web site.
•<inherited> The first specified connection, other than <inherited>, as you
go up the hierarchy of the Sybase Central tree.
•<no connection> The connection specified when you create a file-based
Web site, or for scripts or templates without SQL statements.
•user-defined A user connection created by the user. Each instance of a
user-defined connection represents another connection definition.
62
CHAPTER 3 Working with Dynamo Web Sites
2 In the left pane, click the Connections folder. You may have to expand the
Web site container to do this.
3 In the right pane, double-click Add Connection.
4 Follow the instructions in the wizard to create a new connection.
If you have more than one connection, you are prompted for a connection name
whenever you create a new template, script, or folder.
63
Working with connections
Note Remember, temporary connections are deleted when the session ends.
64
CHAPTER 3 Working with Dynamo Web Sites
The following example asks a user to log in to a site. Once the login
information is provided a connection is created using the user’s ID and
password. The connection is associated with a session object which is then
used by Web site scripts. If the session times out, the user is directed back to
the login page.
Contents of logon.ssc:
<HTML>
<H1>Logon to temporary connection sample</H1>
<FORM METHOD=POST ACTION="tempConnection.ssc">
<INPUT TYPE="text" NAME="id" value="id" CHECKED>Enter
your user ID<BR>
<INPUT TYPE="text" NAME="password"
value="password">Enter your password<BR>
<P><INPUT TYPE="submit"></p>
<P><INPUT TYPE="RESET" VALUE="Clear Form"></P>
</FORM>
</HTML>
tempConnection.ssc
<HTML>
<BODY>
<!--SCRIPT tempConnection.ssc
/* Creates connection from login */
var password = document.value.password;
var id = document.value.id;
if( tempConn==null ) {
//error creating connection
document.writeln( "Temporary connection was not
created");
document.writeln( "Error Code: " +
site.GetErrorCode() );
document.writeln( "Error Message: " +
site.GetErrorInfo() );
document.writeln( "Error State: " +
site.GetState() );
65
Working with connections
} else {
session.persistentConn=tempConn;
document.WriteLn( session.persistentConn);
}
}
-->
<A HREF="useConnection.ssc" >Click here to access a new
script that used the existing temporary connection</A>
</BODY>
</HTML>
useConnection.ssc
<HTML>
<BODY>
<H1>Contacts for ACME Corp. </H1>
<!--SCRIPT useConnection.ssc
/* Uses temp connection associated with */
/* session object */
if ( !exists (session.persistentConn) ) {
document.redirect="logon.ssc";
} else {
conn = session.persistentConn;
query = conn.CreateQuery ("select last_name,
first_name, phone from contact" );
colCount = query.GetColumnCount();
while (query.MoveNext() ) {
for( i=1; i <= colCount; i++) {
document.WriteLn("<BR>" + query.GetValue(
i ) );
}
}
}
if( query == null ) {
document.WriteLn("The query did not work; query
object not created");
} else {
if( query.GetErrorCode() != 0 ) {
document.Write("The query did not work; ");
document.WriteLn( query.GetErrorInfo() );
}
}
-->
66
CHAPTER 3 Working with Dynamo Web Sites
</BODY>
</HTML>
67
Working with connections
68
CHAPTER 3 Working with Dynamo Web Sites
69
Using the Performance Monitor
70
CH A PTE R 4 Configuring Web Servers and
Web sites
About this chapter You can access a PowerDynamo Web site from a browser or other Web
client either by:
• Using the PowerDynamo Personal Web Server, or
• Using a third party Web server and a PowerDynamo Application
Server. The Application Server communicates with the Web server
using one of the ISAPI, NSAPI, CGI or WIN-CGI interfaces.
Contents
Topic Page
The Personal Web Server 72
Configuring a Dynamo Web site 76
Configuring an ISAPI server 79
Configuring an ISAPI 4.0 server 85
Configuring an NSAPI server 86
Configuring a CGI or WIN-CGI server 94
Configuring Web sites 100
How mapping information is stored 105
Changing Dynamo configuration settings 106
Setting Dynamo MIME types 109
71
The Personal Web Server
Testing Web sites When you are creating or changing a Web site that contains Dynamo content,
you may find it easiest to create all or part of the site on your own computer.
The site is stored in your own Dynamo database or in the file system.
Using the Personal Web Server, you can then point your Web browser to this
local site and test your changes, without disrupting your organization’s
production Web site.
For Dynamo sites that are stored in an Adaptive Server Anywhere database,
moving a site to a server platform is a simple matter of copying the appropriate
database and log file to the new location. For file-based Web sites, simply copy
the files.
Using the Web offline To use the Web, normally you must be online—that is, you must have a live
Internet connection for your Web browser. If you are offline, normally, there is
no Web server to supply your browser with Web content. This is not the case
with PowerDynamo.
If you have some Web content already stored on your computer, you can point
your browser to this content by using the Personal Web Server. You can then
navigate these local pages as you would normally navigate the Web if you were
online.
72
CHAPTER 4 Configuring Web Servers and Web sites
Your offline Web content can be a mixture of static and Dynamo documents
stored on your computer. It can be stored as conventional files copied from the
Internet, or stored as part of a Dynamo database replicated automatically from
an Adaptive Server Enterprise or Adaptive Server Anywhere central database
using SQL Remote. The Personal Web Server handles these details and
presents the results to your Web browser.
TCP/IP required
Web browsers require a TCP/IP protocol stack to communicate with a Web
server, even if it is on the same machine with no intervening network. You must
have TCP/IP installed to use the Personal Web Server.
73
The Personal Web Server
74
CHAPTER 4 Configuring Web Servers and Web sites
75
Configuring a Dynamo Web site
76
CHAPTER 4 Configuring Web Servers and Web sites
Supported Web PowerDynamo includes an Application Server for each of these interfaces:
servers
•CGI For integration with CGI-compatible Web servers.
•WIN-CGI For integration with Windows CGI-compatible Web servers.
•ISAPI For integration with Microsoft Internet Information Server or other
ISAPI Web server.
•NSAPI For integration with a Netscape Web server or other NSAPI Web
server.
Note Ensure that PowerDynamo has been installed on the Web server machine
before beginning configuration. For future administration use, it is
recommended that all PowerDynamo components remain installed on the Web
server machine. You must confirm that you are properly licensed to use
PowerDynamo and Adaptive Server Anywhere or Adaptive Server Enterprise
on your Web site before configuring your Web site.
77
Configuring a Dynamo Web site
Important
The above steps rely on tools available from PowerDynamo.
78
CHAPTER 4 Configuring Web Servers and Web sites
IIS 4.0
If you have the Internet Information Server NT 4.0 option pack, see
“Configuring an ISAPI 4.0 server” on page 85.
Steps 1 and 2 are part of the PowerDynamo installation procedure. These steps
are not necessary if the Web server was detected and configured during
installation. Steps 3 through 5 must still be completed.
For more information on configuring Web servers during installation see
“Configuring Web servers during installation” on page 77.
Windows 95
If you are running Windows 95, edit the path to include the directory
containing the new DLLs.
The DLL directory is added to the system path, not the user path. ISAPI servers
run as Windows NT services on the NT operating system.
79
Configuring an ISAPI server
• dyisa03.dll
• dyhtml03.dll
• dydom03.dll
• dyscr03.dll
• dydbg03.dll (optional)
• dyxdb03.dll
• dyxdfl03.dll
• dys03ent.dll
• dycom03.dll (optional)
• dycls03.dll
• dyzip03.dll
• dyperf03.dll (optional)
• mthr110.dll
• plbr110.dll
• clbr110.dll
The following required Power++ runtime libraries are automatically installed
into your Windows SYSTEM directory or your Windows NT system32
directory.
80
CHAPTER 4 Configuring Web Servers and Web sites
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, this step is not necessary. If you are using Windows 95, create a
data source; you do not need a system DSN.
81
Configuring an ISAPI server
82
CHAPTER 4 Configuring Web Servers and Web sites
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, see “Creating a connection profile for your Web site” on page 38.
83
Configuring an ISAPI server
For a more detailed description of how to configure the Dynamo sites using
Sybase Central and the Configuration folder, see “Configuring Web sites” on
page 100.
84
CHAPTER 4 Configuring Web Servers and Web sites
85
Configuring an NSAPI server
Note The DLL directory must be added to the system path, not the user path.
NSAPI servers are run as Windows NT services from an NT operating system.
86
CHAPTER 4 Configuring Web Servers and Web sites
87
Configuring an NSAPI server
• dydbg03.dll (optional)
• dydom03.dll
• dyxdb03.dll
• dyxdfl03.dll
• dys03ent.dll
• dycom03.dll (optional)
• dycls03.dll
• dyzip03.dll
• dyperf03.dll (optional)
The following Powersoft Power++ runtime libraries are installed into your
Windows SYSTEM directory or your Windows NT system32 directory:
• mthr110.dll
• plbr110.dll
• clbr110.dll
Init fn=_dynamo_init
88
CHAPTER 4 Configuring Web Servers and Web sites
# problems.
Init fn=load-modules
shlib=c:/Netscape/Server/Plugins/dynamo/dy2ns03.dll
funcs="_dynamo_ntrans,_dynamo_fn,_dynamo_pathcheck,
_dynamo_init"
Init fn=_dynamo_init
89
Configuring an NSAPI server
<Object name=default>
NameTrans fn=_dynamo_ntrans
NameTrans fn=document-root
root="c:/Netscape/Server/docs"
PathCheck fn=_dynamo_pathcheck
PathCheck fn=nt-uri-clean
PathCheck fn=find-pathinfo
ObjectType fn=type-by-extension
</Object>
<Object name=cgi>
Service fn=send-cgi
90
CHAPTER 4 Configuring Web Servers and Web sites
</Object>
<Object name=PowerDynamo>
Service fn=_dynamo_fn
</Object>
A document named test.stm in the Dynamo Web site folder would then have
the following URL:
http://server-name/Site/test.stm
The URL contains the server name, followed by the URL prefix defined in the
Application Server mapping: in this case /Site. This mode of addressing is
exactly the same as for the Personal Web Server.
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, this step is not necessary. If you are using Windows 95, create a
data source; you do not need a system DSN.
91
Configuring an NSAPI server
Click OK.
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, see “Creating a connection profile for your Web site” on page 38.
92
CHAPTER 4 Configuring Web Servers and Web sites
3 Enter a name for the connection profile, and select PowerDynamo from
the list of available types. Click OK.
4 Select an ODBC data source from the drop-down list. If appropriate, enter
a user ID and password, and any additional parameters and descriptions.
Click OK to create the connection profile.
93
Configuring a CGI or WIN-CGI server
Note The DLL directory must be added to the system path, not the user path.
94
CHAPTER 4 Configuring Web Servers and Web sites
• dycsrv03.exe
• dycgi03.exe
• dyhtml03.dll
• dyscr03.dll
• dydbg03.dll (optional)
• dydom03.dll
• dys03ent.dll
• dyu03ent.dll
• dyxdfl03.dll
• dyxdb03.dll
• dycom03.dll (optional)
• dycls03.dll
• dyzip03.dll
• dyperf03.dll (optional)
The following Powersoft Power++ runtime libraries are installed into your
Windows SYSTEM directory or your Windows NT system32 directory:
• mthr110.dll
• plbr110.dll
• clbr110.dll
Required files for The PowerDynamo Application Server for WIN-CGI Web servers includes the
WIN-CGI servers following files:
• dycsrv03.exe
• dycwin03.exe
• dyhtml03.dll
• dyscr03.dll
• dydbg03.dll (optional)
• dydom03.dll
• dys03ent.dll
• dyu03ent.dll
95
Configuring a CGI or WIN-CGI server
• dyxdfl03.dll
• dyxdb03.dll
• dycom03.dll (optional)
• dycls03.dll
• dyzip03.dll
• dyperf03.dll (optional)
The following Powersoft Power++ runtime libraries are installed into your
Windows SYSTEM directory or your Windows NT system32 directory:
• mthr110.dll
• plbr110.dll
• clbr110.dll
CGI Helper
In order for a Web site to interface with PowerDynamo through CGI you must
run the Dynamo CGI Helper along with the Web site server itself.
You can start the CGI Helper from the Dynamo Utilities folder.
96
CHAPTER 4 Configuring Web Servers and Web sites
http://server/cgi-win/dycwin03.exe/Site/Contents.stm
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, this step is not necessary. If you are using Windows 95, create a
data source; you do not need a system DSN.
97
Configuring a CGI or WIN-CGI server
Note
If you are connecting to a file-based Web site, or using an Open Client
connection, see “Creating a connection profile for your Web site” on page 38.
98
CHAPTER 4 Configuring Web Servers and Web sites
99
Configuring Web sites
100
CHAPTER 4 Configuring Web Servers and Web sites
101
Configuring Web sites
For more information, see “Using the ISAPI filter” on page 81.
Dynamo site type The type of document to which the URL prefix refers.
There are three Dynamo site types:
•Database site Documents are held in a database-hosted Web site. You
can process templates and scripts containing DynaScript.
•Dynamic file site Documents are held on disk. Templates and scripts
containing DynaScript can be processed.
•Static file site Documents are held on disk. Sends back static HTML. You
cannot process queries or templates containing DynaScript.
For more information, see “Defining mappings for database-hosted sites” on
page 102 and “Defining a mapping for file-based sites” on page 103.
Site location The location of the site corresponding to the URL prefix.
The site location for a database hosted Web site is the name of a Sybase Central
connection profile. Connection information is stored in the Registry.
The site location for a file-based Web site is a folder name on a drive available
to the Web site machine.
Document cache size The maximum amount of memory to reserve for
your document cache.
Java cache size The maximum amount of memory to reserve for your
Java cache.
Java classpath Class files that are stored in a database must have their
class path specified in Sybase Central for the class file to be found. Database
class paths may be set per mapping from the Configuration folder in Sybase
Central.
The mapping and Dynamo site name must be the same.
Class files that are stored in a file-based Web site can also use this field to set
the Java classpath.
102
CHAPTER 4 Configuring Web Servers and Web sites
103
Configuring Web sites
8 If you have Web sites that access Java class files from within a database
enter the classpath for the mapping. Dynamo cannot find the class files
unless the location is specified here.
9 Restart the server.
To edit a mapping, double-click on the mapping and make the necessary
changes. Click OK to save the changes.
To delete a mapping, right-click the mapping and select Delete.
104
CHAPTER 4 Configuring Web Servers and Web sites
105
Changing Dynamo configuration settings
106
CHAPTER 4 Configuring Web Servers and Web sites
107
Changing Dynamo configuration settings
108
CHAPTER 4 Configuring Web Servers and Web sites
109
Setting Dynamo MIME types
110
CH A PTE R 5 Dynamo Tags Tutorial
About this chapter This chapter introduces Dynamo tags, which are HTML-like tags used for
simple manipulation of PowerDynamo Web site documents.
The tutorials in this chapter introduce you to the most commonly used
Dynamo tags. Several other tags are also explored that allow you to
manipulate data within your Web site possible without using a scripting
language such as DynaScript or JavaScript.
Contents
Topic Page
Overview of Dynamo Tags 112
Tags tutorial 113
111
Overview of Dynamo Tags
112
CHAPTER 5 Dynamo Tags Tutorial
Tags tutorial
These tutorials teach you how to use the most commonly used Dynamo tags.
• SQL
• FORMATTING
• The error checking tags
• INCLUDE
• SQL_INSERT
-->
There are two ways to create a document with an embedded SQL query:
• Use the Add Template wizard in Sybase Central. This automatically
generates the SQL template for you.
• Use the Sybase Central code editor to enter the SQL query.
113
Tags tutorial
114
CHAPTER 5 Dynamo Tags Tutorial
<!--/formatting-->
The template you created with the Add Template wizard automatically inserted
FORMATTING tags. Your template should look something like this:
<HTML>
<TITLE>SQL_tag.stm</TITLE>
<BODY>
<H1>Customer Information</H1>
<!--SQL
SELECT customer.id, customer.lname, customer.fname,
customer.phone
FROM DBA.customer customer
-->
<TABLE BORDER>
<TR>
<TH>id</TH>
<TH>lname</TH>
<TH>fname</TH>
<TH>phone</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
</BODY>
</HTML>
115
Tags tutorial
116
CHAPTER 5 Dynamo Tags Tutorial
The LABEL tag Yet another way to alter the formatting of your output is by using the LABEL
tag. LABEL allows you to return the column name along with the column data.
For example, you could set up a query to return output in this format:
id: 101
lname: Devlin
fname: Michael
phone: 2015558966
id: 102
lname: Reiser
fname: Beth
phone: 2125558725
id: 103
lname: Niedringhaus
fname: Erin
phone: 2155556513
-->
<!--formatting-->
<!--/formatting-->
</BODY>
</HTML>
3 To assign a label to each unit of data that is returned by the query, enter this
line four times between the formatting tags:
<!--LABEL-->: <!--data--><BR>
117
Tags tutorial
4 Save the changes you just made. Your template should now look like this:
<HTML>
<TITLE>SQL_tag.stm</TITLE>
<BODY>
<H1>Customer Information</H1>
<!--SQL
SELECT customer.id, customer.lname, customer.fname,
customer.phone
FROM DBA.customer customer
-->
<!--formatting-->
<!--LABEL-->: <!--data--><BR>
<!--LABEL-->: <!--data--><BR>
<!--LABEL-->: <!--data--><BR>
<!--LABEL-->: <!--data--><BR>
<BR>
<!--/formatting-->
</BODY>
</HTML>
5 To view these changes, right-click on the template within Sybase Central,
and select Browse Output.
118
CHAPTER 5 Dynamo Tags Tutorial
<TABLE BORDER>
<TR>
<TH>Product Name</TH>
<TH>Quantity</TH>
<TH>Unit_price</TH>
<TH>Total</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
</BODY>
</HTML>
The output from this query list all inventory items, and the quantity, price,
and total value of each item.
2 Use the SQL_ON_NO_ERROR tag to ensure that the output is error-free.
Add the SQL_ON_NO_ERROR tags at the beginning and end of the
portion of the file you want error-checked. Your template should look like
this:
<HTML>
<TITLE>error_check.stm</TITLE>
<BODY>
<H1>Error Checking example</H1>
<!--SQL
select name, quantity, unit_price, (quantity *
unit_price) as total from product
-->
<!--SQL_ON_NO_ERROR-->
119
Tags tutorial
<TABLE BORDER>
<TR>
<TH>Product Name</TH>
<TH>Quantity</TH>
<TH>Unit_price</TH>
<TH>Total</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
<!--/SQL_ON_NO_ERROR-->
</BODY>
</HTML>
3 You can use the SQL_ON_ERROR tag to add a comment that displays
only if an error is encountered.
The default behavior of the SQL tag in the event of an error is to abort
processing. For this reason, you must add the NO_SQL_ERROR to the
SQL tag. This will allow the template to continue executing even if an
error is encountered. For example:
<HTML>
<TITLE>error_check.stm</TITLE>
<BODY>
<H1>Error Checking example</H1>
<!--SQL NO_SQL_ERROR
select name, quantity, unit_price, (quantity *
unit_price) as total from product
-->
<!--SQL_ON_NO_ERROR-->
<TABLE BORDER>
<TR>
<TH>Product Name</TH>
<TH>Quantity</TH>
<TH>Unit_price</TH>
<TH>Total</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
120
CHAPTER 5 Dynamo Tags Tutorial
</TR><!--/formatting-->
</TABLE>
<!--/SQL_ON_NO_ERROR-->
<!--SQL_ON_ERROR-->
<P>An error has occurred. Contact your system
administrator.</P>
<!--/SQL_ON_ERROR-->
</BODY>
</HTML>
4 View the output of your template. You should see the output of your query
in table format as expected.
5 Change the SQL query so that it has an error in it. Add a spelling mistake
to the table that is being queried, for example:
select name, quantity, unit_price, (quantity *
unit_price) as total from prodduct
Save your changes.
6 View the output of your template. Once the error in the query is
encountered, the formatting instructions surrounded by the
SQL_ON_NO_ERROR tags stop and the SQL_ON_ERROR tags take
effect. The text indicating that an error has been encountered is displayed.
See the SQL_ERROR_CODE, SQL_ERROR_INFO, and SQL_STATE tags in
“Dynamo Tags” in PowerDynamo Reference for information on how to display
errors returned by the database.
121
Tags tutorial
-->
<TABLE BORDER>
<TR>
<TH>company_name</TH>
<TH>lname</TH>
<TH>fname</TH>
<TH>phone</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
2 Create a second template that lists expectations for Sales reps. For
example:
<HTML>
<H1>Customer List</H1>
<H2>Expectations</H2>
<P>Each sales rep is expected to contact the
customers on their contact list a
minimum of once every two weeks. For a list of the
customers that you are
responsible for please talk to you supervisor.</P>
</HTML>
3 This example would benefit from displaying a list of customer contacts as
well as the expectations. To do this, you need only add one line to the
example, which includes the generated output from the customer list. After
the “Customer List” heading, add this line:
<!--INCLUDE name="customer.stm"-->
Your example should look like this:
122
CHAPTER 5 Dynamo Tags Tutorial
<HTML>
<BODY>
<H1>Customer List</H1>
<!--INCLUDE name="customer.stm"-->
<H2>Expectations</H2>
<P>Each sales rep is expected to contact the
customers on their contact list a
minimum of once every two weeks. For a list of the
customers that you are
responsible for please talk to you supervisor.</P>
</BODY>
</HTML>
4 Save the template and view the output.
123
Tags tutorial
number<BR>
<LI><INPUT TYPE="text" NAME="fax" >Fax number<BR>
</OL>
<P><INPUT TYPE="submit"></p>
<P><INPUT TYPE="RESET" VALUE="Clear Form"></P>
</FORM>
</BODY>
</HTML>
In a browser, this template would look like Figure 5-1:
Figure 5-1: NewCustomer.stm template
2 The NAME tags must match the appropriate column in the table that the
information is being inserted into. For example, the field that requests the
customer’s first name has a NAME tag of first_name. This matches the
first_name column in the contact table.
124
CHAPTER 5 Dynamo Tags Tutorial
125
Tags tutorial
126
CH A PTE R 6 Writing DynaScripts
About this chapter This chapter introduces DynaScript, which is the PowerDynamo server-
side language that provides programmable control over the content
returned to a Web client.
Contents
Topic Page
Overview of scripts 128
Script tutorials 130
127
Overview of scripts
Overview of scripts
You can embed scripts in HTML templates to control the information that the
template provides to the user. The PowerDynamo script language, DynaScript,
uses a syntax much like JavaScript. DynaScripts are interpreted by the
application server, and the results of that interpretation are passed on to the
Web server.
Script language DynaScript has the following characteristics:
summary
• Scripts are usually embedded in an HTML template. You can also
maintain a script as a separate file in the site, and include it in other scripts
or templates, allowing for code reuse throughout the site.
• Because DynaScript is processed at the application server, before the
content is passed back to the client, no client support for scripting is
required.
• Script statements and variables are case-sensitive.
• You do not need to declare variables.
• Scripts can use the following datatypes:
• numeric
• logical (Boolean) true or false
• string
• null
• function
• object (methods and properties)
• Variables do not have a fixed datatype. Datatype assignment occurs as
needed when expressions are evaluated.
• Control statements such as if, while, do-while and for have a syntax
similar to C and Java.
• You can create objects and define their properties and methods.
• DynaScript includes several built-in object types for working with
databases, SQL, and HTML documents.
Using a server-side Scripting languages for the Internet are interpreted at either the Web client or
language the Web server.
128
CHAPTER 6 Writing DynaScripts
129
Script tutorials
Script tutorials
This section presents some simple scripts that introduce you to DynaScript.
130
CHAPTER 6 Writing DynaScripts
131
Script tutorials
<SCRIPT LANGUAGE="JavaScript">
DynaScript uses this syntax:
<!--SCRIPT Comments can be included here -->
The parts of the script The body of the script consists of a single instruction:
document.Write( "Hello world" );
Here, document is a predefined object that refers to the HTML document
being executed.
The statement optionally ends with a semicolon.
Objects have methods associated with them. A method is a function that
carries out actions on an object. Write is a method of the document object.
An object method can take arguments and carries out actions, like a function or
subroutine in other programming languages. In this case, the argument to the
method is the character string "Hello world". The Write method inserts this
string into the HTML document that is sent to the client when the template is
requested.
132
CHAPTER 6 Writing DynaScripts
The + operator concatenates the two strings, and the resulting expression is
assigned to the variable quote. The last line sends the value of the variable as
a string to the HTML output.
Variable types and Unlike variables in many compiled programming languages, Dynascript
operators variables do not have fixed datatypes. The datatype of a variable is set
whenever the variable is assigned a value. You can change the datatype of a
variable by assigning it an expression of a different type.
While this is convenient for small scripts, it does require that you take care
when working with variables.
The same applies to operators. For example, the meaning of the + operator
depends on the expressions it is operating on. In the previous example + was
used to concatenate two strings, but if it is operating on integer expressions
rather than string expressions, it adds rather than concatenates the expressions.
Consider the following script:
<!--SCRIPT
sum = 123 ;
sum = sum + 456 ;
document.Write(sum) ;
-->
The output from this script is the following HTML string:
579
The value of sum is set to the integer 123 in the first line. In the second line the
+ operator acts on the two integers, and so adds them to produce the value 579.
In the final line, this integer is converted to a string for output.
• for
• while
• do-while
133
Script tutorials
A script using the The following example illustrates the use of the while statement:
while statement
<!--SCRIPT
var i = 0;
while ( i < 3 ) {
svar = "This is paragraph " ;
svar += (i + 1) + "<P>" ;
document.WriteLn(svar) ;
i++ ;
}
-->
This script prints the following HTML:
This is paragraph 1<P>
This is paragraph 2<P>
This is paragraph 3<P>
Notes Notice the way that the + operator acts in this script:
• In the expression (i + 1) it adds two integers.
• The other two + operators recognize a string, and combine the other
variable with the string by concatenation.
Using functions
You can define and use functions in scripts, which allows you to encapsulate a
set of instructions once in a document, and use it several times throughout the
document.
The following example shows how to provide consistent custom formatting
across headings in an HTML document:
<HTML>
<TITLE>Function testing</TITLE>
<BODY>
<!--SCRIPT
134
CHAPTER 6 Writing DynaScripts
-->
</BODY>
</HTML>
Notes Note the following in this example:
• The h1 function is defined before it is invoked.
• The h1 function does not return a value to the calling script, so it is called
using a simple statement. You can also return a value from a function using
the return statement, in which case you typically call the function as part
of an assignment statement.
• Simple variables such as strings and numbers are passed to functions by
value, while objects (including arrays) are passed by reference.
135
Script tutorials
this.quantity = quantity ;
this.price = price ;
}
Defining methods for So far, the product class has properties, but no methods to act on those
an object properties. To add a method to an object, you must:
1 Define a function that carries out the actions you want.
You can define the function inside the class definition, or as a global
definition (outside the class definition).
2 Assign the function to the class.
For example, you could define an order method for the product class, which
carries out the proper actions when a product is ordered:
function order ( orderQuantity ) {
// order returns true if the order is successful,
// false if stock is too low
if ( this.quantity >= orderQuantity ) {
this.quantity -= orderQuantity ;
return ( true ) ;
} else {
return ( false ) ;
}
}
Since we’ve declared order as a global function in our script, its definition
must precede the definition of the product class. We can then make the order
function a method of product by adding a line to the class definition:
class product( id, name, size, color,
quantity, price ) {
this.id = id ;
136
CHAPTER 6 Writing DynaScripts
this.name = name ;
this.size = size ;
this.color = color ;
this.quantity = quantity ;
this.price = price ;
this.order = order ;
}
Since we haven’t added any new properties, creating a new instance of the
product class is the same as it was before:
var currentProduct = new product(600, "Sweatshirt",
"Large", "Green", 39, 24.00 ) ;
You could then use the order method in a template as follows:
<!--SCRIPT
var orderQuantity = 20 ;
status = currentProduct.order( orderQuantity ) ;
if (status) {
document.WriteLn( "Your order for " +
orderQuantity + " " + currentProduct.name
+ "s succeeded.") ;
document.WriteLn( "Now in stock: " +
currentProduct.quantity + ".") ;
} else {
document.WriteLn( "Your order for " +
orderQuantity + " " + currentProduct.name
+ "s failed.") ;
document.WriteLn( "We only have " +
currentProduct.quantity + " in stock.") ;
}
-->
Using arrays
Arrays are useful for keeping track of a collection of objects. Typically, you
index a variable using integers, as in this example of three prices:
price = new Array(3);
price[0] = 19.95;
price[1] = 42.99;
price[2] = 0.02;
A common programming construct is a loop that performs some action on each
element of an array. The loop variable iterates over the index of the array, as in
the following example:
137
Script tutorials
138
CHAPTER 6 Writing DynaScripts
http://address?quantity=25
the following HTML is returned to the Web client:
<HTML>
<TITLE>Displaying variables</TITLE>
<BODY>
The value of argument quantity is 25.
</BODY>
</HTML>
Using arguments in You can also use arguments inside scripts. The argument is a property of the
scripts document, which is a predefined object. The actual value of an argument
named quantity can be accessed inside a script as:
document.value.quantity
The following script responds to user input for an order:
<!--SCRIPT
var currentProduct = new product(600, "Sweatshirt",
"Large", "Green", 39, 24.00 ) ;
var orderQuantity = document.value.quantity ;
var retval = currentProduct.order(orderQuantity) ;
if (retval) {
document.WriteLn( "Your order for " +
orderQuantity + " " + currentProduct.name +
"s succeeded.") ;
document.WriteLn( "Now in stock: " +
currentProduct.quantity + ".") ;
} else {
document.WriteLn( "Your order for " +
orderQuantity +
" " + currentProduct.name + "s failed.") ;
document.WriteLn( "We have only " +
currentProduct.quantity + " in stock.") ;
}
-->
For information on passing values of a multiple selection list see “value
property” in PowerDynamo Reference.
139
Script tutorials
140
CHAPTER 6 Writing DynaScripts
141
Script tutorials
142
CHAPTER 6 Writing DynaScripts
143
Script tutorials
144
CH A PTE R 7 PowerDynamo and Java
About this chapter This chapter provides an introduction to Java and an example of using
Java within a PowerDynamo script.
Contents
Topic Page
An introduction to Java 146
Dynamo and Java 155
Configuring Dynamo to use Java 156
Using Java in a PowerDynamo script 158
145
An introduction to Java
An introduction to Java
This section introduces key Java concepts. After reading this section you
should be able to examine Java code, such as a simple class definition or the
invocation of a method, and understand what is taking place.
146
CHAPTER 7 PowerDynamo and Java
147
An introduction to Java
Similarly it is the Invoice object that gets created, stores information, is stored,
retrieved, edited, updated, and so on.
Just as one invoice template is used to create many separate and distinct
invoices, many objects can be generated from one class.
Methods and fields A method is the part of the class that performs a calculation or interacts with
other objects. Methods can accept arguments, and return a value to the calling
function. If no return value is needed, a method can return void. Classes can
have any number of methods.
A field is the part of a class that ends up holding information. When an object
of type JavaClass is created, the fields in JavaClass are available to be passed
values unique to that object.
Examples To declare a field in a class, state its type and name, followed by a semicolon.
Such a variable is a field if it is declared in the body of the class and not within
a method. Declaring a variable within a method makes it a part of the method,
not the class.
public class Invoice {
Adding methods
You might want to include a method in the Invoice class. Declare a method by
stating its return type, its name, and what parameters it takes (in this case,
none). Like a class declaration, the method uses an opening and closing brace
to identify the body of the method where the code goes.
public class Invoice {
// Fields
public String lineItem1Description;
public double lineItem1Cost;
148
CHAPTER 7 PowerDynamo and Java
// A method
public double totalSum() {
double runningsum;
return runningsum;
}
}
Within the body of the totalSum method, a variable named runningsum is
declared. This is used first to hold the subtotal of the first and second line item
cost. This subtotal is then multiplied by the rate of taxation to determine the
total sum.
The local variable (as it is known within the method body) is then returned to
the calling function. When the totalSum method is invoked, it returns the
sum of the two line item cost fields plus the cost of tax on those two items.
149
An introduction to Java
// Fields
public String lineItem1Description;
public double lineItem1Cost;
// An instance method
public double totalSum() {
double runningsum;
double taxfactor = 1 + Invoice.rateOfTaxation();
150
CHAPTER 7 PowerDynamo and Java
return runningsum;
}
// A class method
public static double rateOfTaxation() {
double rate;
rate = .15;
return rate;
}
}
A Java glossary
The following items outline some details regarding Java classes that may aid
in the use of Java classes in PowerDynamo.
Public versus private The visibility of a field, method, or class to other Java objects and operations
is determined by what is known as an access modifier — essentially the
public, private, or protected keyword used in front of any declaration.
Fields and methods can be declared private or public, meaning, respectively,
their values are available to code within the object, or to code/classes/objects
both inside and outside the object.
Fields or methods declared as private cannot be manipulated or accessed by
methods outside the class. Public fields or methods can be directly accessed by
other classes and methods.
Packages and the Protected fields or methods are accessible only:
protected modifier
• Within their class
• Within subclasses that inherit from their class
• Within the package of which the class is a part
A package is a grouping of classes that share a common purpose or category.
Members of a package have special privileges to access data and methods in
other members of the package, hence the protected access modifier.
A package is the Java equivalent of a library. It is a collection of classes, that
can be made available using the import statement. The following Java
statement imports the utility library from the Java API:
151
An introduction to Java
import java.util.*
Packages are typically held in Java archive (Jar) files, which have the extension
.jar or .zip.
Constructors A constructor is a special method of a Java class that creates an instance of the
class and returns a reference to the newly-created Java object.
Classes can define their own constructors, including multiple, overriding
constructors. Which constructor is used is determined by the arguments used
to create the object. When the type, number, and order of arguments used to
create an instance of the class match one of the class’s constructors, that
constructor is used to create the object.
Destructors There is no such thing as a destructor method in Java (as there is in C++). Java
classes can define a finalize method for clean-up operations when an object
is discarded, but there is no guarantee that this method will get called.
An object that has no references to is automatically removed by a “garbage
collection” process.
Other C++ differences Everything related to a class is contained within the boundaries of the class
declaration, including all methods and fields.
Classes can inherit from only one class. Java uses interfaces instead of
multiple-inheritance. A class can implement multiple interfaces. Each interface
defines a set of methods and method profiles that must be implemented by the
class in order for the class to compile.
An interface is similar to an abstract class; it defines what methods and static
fields the class must declare. The implementation of the methods and fields
declared in an interface is located within the class that uses the interface. The
interface defines what the class must declare, and it is up to the class to
determine how it is implemented.
152
CHAPTER 7 PowerDynamo and Java
Both Java API classes and custom-created classes can throw exceptions. In
fact, users can create their own exceptions classes, which can be thrown by
their own custom-created classes.
If there is no exception handler in the method where the exception occurred,
the search for an exception handler continues up the call stack. If the top of the
call stack is reached and no exception handler has been found, the default
exception handler of the Java interpreter running the application is called and
the program terminates.
Error types in Java All errors in Java are derived from two types of error classes: Exception and
Error. Usually, exception errors are handled by error-handling code in your
method body. Error type errors are reserved for internal and resource
exhaustion errors inside the Java runtime system.
Exception class errors are thrown and caught. Exception handling code is
characterized by try, catch, and finally code blocks.
A try block executes code that may generate an error. A catch block will
execute if an error is generated (thrown) during the execution of a try block.
A finally block defines code executes regardless of whether an error was
generated and caught and is typically used for clean-up operations. It is used
for code that, under no circumstances, can be omitted.
Exception errors are divided into runtime exceptions and those that are not
runtime exceptions.
Errors generated by the runtime system are known as implicit exceptions,
because they do not have to be explicitly handled as part of every class or
method declaration.
For example, an array out of bounds exception can occur whenever an array is
used, but the error does not have to be part of the declaration of the class or
method that uses the array.
All other exceptions are explicit. If the method being invoked can throw an
error, it must be explicitly caught by the class using the exception throwing
method, or this class must explicitly throw the error itself by identifying the
exception it may generate in its class declaration.
A method must declare all the explicit errors it throws, or catch all the explicit
errors that may be potentially thrown.
Non-runtime exceptions are checked at compile time. Runtime exceptions are
usually caused by errors in programming. Java catches many such errors
during compilation, before the code is run.
153
An introduction to Java
Every Java method is given an alternative path of execution so that all Java
methods complete, even if they are unable to complete normally. If the type of
error that is thrown is not caught, it’s passed to the next code block or method
in the stack.
154
CHAPTER 7 PowerDynamo and Java
155
Configuring Dynamo to use Java
❖ Java VM
Dynamo provides Java support only if you have selected a Java VM in the
Sybase Central Configuration folder.
1 From the Configuration folder, open the Default General Settings folder.
2 In the right pane, double-click the Java VM setting.
3 Select the Java VM option from the drop-down list and click OK.
4 Restart PowerDynamo if you change the Java VM.
Note
If using the Sun VM you must have JDK 1.1.6 or higher installed. For
information, see http//java.sun.com/jdk/1.1. If using the Microsoft VM, you
must have msjava.dll (version 5) installed. For information, see
http//www.microsoft.com/java/download.htm.
156
CHAPTER 7 PowerDynamo and Java
3 Enter the classpath for this mapping in the field provided and click OK.
4 If you change your classpath, you must restart PowerDynamo.
157
Using Java in a PowerDynamo script
158
CHAPTER 7 PowerDynamo and Java
159
Using Java in a PowerDynamo script
The Java class that we are instantiating has properties and methods associated
with it. To use those properties within our Dynamo script, the Java class must
contain both get and set functions for this property. For example, testclass has
a property called str. When this property is used within a Dynamo script to
display the value of the str property ( document.WriteLn( cls1.str );
) in actuality, the getstr function from the Java class is called. The same holds
true for setting a property; the setstr function would be called. If you look at
the testclass code you will see that the str property has both get and set
functions.
Working with methods of an instantiated Java class is the same as working with
any DynaScript method.
For further information about the Java object and its methods see “The java
object” in PowerDynamo Reference.
The following is a Dynamo script that provided two strings for manipulation
by the testclass object:
<!--SCRIPT
160
CHAPTER 7 PowerDynamo and Java
document.writeln( site.GetErrorInfo() );
return;
}
// A method is invoked
document.writeln( "3 " + cls1.Upper() );
Arrays in Java
PowerDynamo does not support array indexing in Java. Use the Java class
java.lang.reflect.Array if you require array manipulation. For example:
<!--SCRIPT
// First create the class we want an array of
String_Class = java.CallStaticMethod(
"java/lang/Class", "forName", "java.lang.String" );
// Create the array with the class and a length
strarray = java.CallStaticMethod(
"java/lang/reflect/Array","newInstance", String_Class,
10 );
// Use the various set and get methods to access the
// created array
java.CallStaticMethod( "java/lang/reflect/Array",
"set", strarray, 1, "hello" );
y = java.CallStaticMethod(
"java/lang/reflect/Array", "get", strarray, 1 );
document.writeln(y.toString());
-->
161
Using Java in a PowerDynamo script
CallStaticMethod
This example uses the CallStaticMethod method of the Java object, which
enables users to access static methods without creating (java.CreateObject) an
instance of the object within the script.
162
CHAPTER 7 PowerDynamo and Java
163
Using Java in a PowerDynamo script
164
CH A PTE R 8 Working with XML Documents
About this chapter XML is becoming a standard framework for exchanging data over the
Web. This chapter describes how you can use Dynamo to manipulate
XML documents and data.
Contents
Topic Page
Dynamo and XML 166
An introduction to XML 167
Creating XML documents 170
Introduction to the Document Object Model 177
Document Object Model examples 182
Creating the DOMDocument object 187
Working with elements 189
Working with text 193
Working with entities 197
Working with other XML objects 199
Using the DOM interface to create and edit XML documents 200
165
Dynamo and XML
166
CHAPTER 8 Working with XML Documents
An introduction to XML
XML is a framework for creating markup languages. It has been designed
specifically for use on the Web.
Example Here is an example XML document:
<?xml version="1.0"?>
<Example>
<Computer>
<Name>Toshiba</Name>
<Processor>Pentium</Processor>
<Memory units="MB">96</Memory>
</Computer>
</Example>
Any complete XML document starts with an XML declaration (the first line in
the example above).
Other attributes can be added to this declaration, as described in any XML
book.
167
An introduction to XML
If a document uses a DTD, the DTD must immediately follow the declaration.
Well-formed The second way to specify XML syntax is to assume that a document is using
documents its language properly. XML provides a set of generic syntax rules that must be
satisfied, and as long as a document satisfies these rules, it is said to be well-
formed. All valid documents must be well-formed.
Processing well-formed documents is faster than processing valid documents
because the parser does not have to verify against the DTD. When valid
documents are transmitted, the DTD must also be transmitted if the receiver
does not already possess it. On the other hand, well-formed documents can be
sent without other information.
XML documents should conform to a DTD if they are going to be used by more
than one application. If they are not valid, there is no way to guarantee that
various applications will be able to understand each other.
In this chapter, most examples use well-formed documents with no DTD, for
simplicity.
XML syntax
There are a few more restrictions on XML than HTML, which make parsing
simpler. Unlike in HTML, you cannot omit tags. This guarantees that parsers
know where elements end. The following example is acceptable HTML, but
not XML:
<table>
<tr>
<td>Dog</td>
<td>Cat
<td>Mouse
</table>
To make this well-formed XML, you need to add all the missing end tags:
<table>
<tr>
<td>Dog</td>
<td>Cat</td>
<td>Mouse</td>
</tr>
</table>
168
CHAPTER 8 Working with XML Documents
Empty elements cannot be represented in XML the same way they are in
HTML. An empty element is one that is not used to markup data, so in HTML
there will not be an end tag. There are two ways to handle empty elements. The
first is to place a dummy tag immediately after the start tag. For example:
<img href="picture.jpg"></img>
The second method is to use a slash character at the end of the initial tag:
<img href="picture.jpg"/>
This tells a parser that the element consists only of one tag.
XML is case sensitive, which allows XML to be used with non-Latin
alphabets. You must ensure that letter case matches in start and end tags:
<MyTag> and </Mytag> belong to two different elements.
White space within tags in XML is unchanged by parsers.
All elements must be All XML elements must be properly nested. All child elements must be closed
nested before their parent elements close.
169
Creating XML documents
170
CHAPTER 8 Working with XML Documents
171
Creating XML documents
•Default tags The default result set tag is SYBRESULTSET. The default
row tag is SYBROW. If you do not supply any tags in the arguments to
ResultsToXMLString, the name of the column is used as the tag for
each tag. If you supply a single tag, it is used for all columns. If you supply
more than one tag, but not as many as there are columns, then the
remaining columns tags default to the column labels.
•Validation The XML output string is not validated. To validate the XML,
you must do so independently of Dynamo.
•Applying attributes The ResultsToXMLString method provides a
convenient way of supplying simple XML. To specify attributes for XML
tags in your output, see “Creating custom XML documents from query
result sets” on page 172.
172
CHAPTER 8 Working with XML Documents
173
Creating XML documents
174
CHAPTER 8 Working with XML Documents
myObj.b.b1 = 3;
myObj.b.b2 = 4;
x = toXMLString( myObj );
document.writeln(x);
-->
The output for the script is as follows:
<a>2</a><b><b1>3</b1><b2>4</b2></b>
• Use the ampersand character to escape text. The toXMLString function
changes the < and > characters to the XML entities < and >.
<!--SCRIPT
// Using ’&’ character escaping" )
myObj = null;
myObj.a = 2;
myObj.b = "&<encoding needed>&";
x = toXMLString( myObj );
document.writeln(x);
-->
The output for the script is as follows:
<a>2</a><b>&<encoding needed>&</b>
• Use CDATA escaping of text that contains special characters, by adding a
second argument to toXMLString.
<!--SCRIPT
document.writeln( "***** Using CDATA character
escaping" );
myObj = null;
myObj.a = 2;
myObj.b = "&<encoding needed>&";
x = toXMLString( myObj, true );
document.writeln(x);
-->
The output for the script is as follows:
<a>2</a><b><![CDATA[&<encoding needed>&]]></b>
• Write an XML string from an object with indexed members, with no tags
specified.
<!--SCRIPT
// Indexed members with no tags specified"
myObj = null;
myObj[0] = 2;
myObj[1] = 3;
175
Creating XML documents
176
CHAPTER 8 Working with XML Documents
177
Introduction to the Document Object Model
</Address>
</Customer>
The tree representation of this document is shown in Figure 8-1.
Figure 8-1: Tree representation of XML document
The node interface to In a DOM representation of this document, each element is a node. You can
DOM navigate the document using the relationships among these nodes:
•Each node has at most one parent The parent of City is Address. The
parent of LName is Customer, and the parent of Customer is a special node
named the document node. The document node does not have a parent
node. No node can have more than one parent, and only certain classes of
node (such as the document node) can have zero parents.
In the DOM representation, each node has a parentNode property that
takes you to the parent of the current node.
•Nodes have zero, one, or more child nodes For example, the children
of Customer are FName, LName, and Address.
In the DOM representation, each node has a childNodes property that
provides you with a list of all children of the current node. It also provides
a firstChild and lastChild node to take you to those specific child
nodes. These nodes are ordered, and each has a previousSibling
property and a nextSibling property that enable you to loop through the
current node.
178
CHAPTER 8 Working with XML Documents
•Not all nodes are elements Some nodes represent text, such as the text
nodes shaded gray in the above diagram. Other nodes represent attributes,
entity references, comments, and so on.
For example, the Region element has a single attribute. This attribute is a
node, with a name of Type and a value of Province. Attribute nodes have
some differences from element and text nodes.
For more information on attribute nodes, see “Working with attributes” on
page 191.
•Some nodes contain text and other nodes Character data, or text, in a
node, is also considered to be a separate node. Thus the child of the FName
node is a node that has a nodeType of Text and a nodeValue of
Gagliardo.
179
Introduction to the Document Object Model
Node types The properties of nodes depend on what piece of an XML document they
represent. The node types and their corresponding values are:
nodeType value XML Comments
1 Element Many nodes are XML elements.
2 Attribute Attributes of an XML element.
3 Text Text can occur in elements, or in the
values of attributes.
4 CDATASection Typically used for including blocks
of text that contain characters that
would otherwise be regarded as
markup (such as <, >).
5 EntityReference A reference to an XML entity.
6 Entity An XML entity.
7 ProcessingInstruction An XML processing instruction.
8 Comment An XML comment: all the
characters between <!-- and -->.
9 Document The document with which the node
is associated.
10 DocumentType The document type definition
(DTD) of the document.
11 DocumentFragment A piece of a document, primarily
used for editing purposes.
12 Notation An XML notation.
180
CHAPTER 8 Working with XML Documents
Performance tip
It is generally more efficient to use the explicit objects instead of the generic
node interface to XML documents.
181
Document Object Model examples
182
CHAPTER 8 Working with XML Documents
domElement.firstChild.nodeValue );//11
domElement = domElement.nextSibling;
//12
document.writeln( "<P>Address: ");
//13
for( i = 0; i < domElement.childNodes.length ; i ++
){ //14
document.writeln(
domElement.childNodes.item(i).firstChild.nodeValue
); //15
} //16
} //17
-->
The output is as follows:
<P>Name:
Jessie
Gagliardo
<P>Address:
2800 Park Avenue
Hull
PQ
How the script works The script works as follows:
•Line 2 An XML document is received by Dynamo, as a document value
named xmlData. It is parsed to provide a DOM document object.
You can create document objects from several sources, including files on
disk, documents stored in a Dynamo Web site, query results, or arguments
passed in from a URL.
For more information, see “Creating the DOMDocument object” on page
187.
•Line 6 The node corresponding to the top element of the DOM document
is accessed. Each XML document has a single top-level element that
includes all other content: in this case, it is the Customer element.
•Lines 8 and 9 The firstChild of the Customer element is FName. The
firstChild of FName is a text node. The nodeValue of the text node is
the string Jessie.
For information on navigating the document tree, see “Using nodes to
work with XML documents” on page 179.
•Lines 10 and 11 The nextSibling of FName is LName. Line 12 writes
out the string in the text node of LName (Gagliardo).
183
Document Object Model examples
184
CHAPTER 8 Working with XML Documents
185
Document Object Model examples
}
//27
Notes •Lines 1 to 3 The SQLVar function gets the value of the named element.
For information on the getElementsByTagName method, see “Using the
DOMElement object to work with elements” on page 190.
•Lines 8 to 9 These lines parse the document and locate the document
element.
For information on the toDOMDocument function, see “Creating the
DOMDocument object” on page 187.
•Lines 15 to 21 These lines call SQLVar to construct variables containing
the quantities that need to be inserted in the database.
•Line 22 The INSERT statement is constructed and executed.
•Lines 23 to 25 These lines check that the INSERT was carried out
successfully.
186
CHAPTER 8 Working with XML Documents
187
Creating the DOMDocument object
188
CHAPTER 8 Working with XML Documents
189
Working with elements
190
CHAPTER 8 Working with XML Documents
191
Working with attributes
192
CHAPTER 8 Working with XML Documents
193
Working with text
194
CHAPTER 8 Working with XML Documents
The text content of a CDATA section is the nodeValue of the object. For
example, the following fragment writes out the content of a node if it is a
CDATA section node:
if (child.nodeType == 4 ){ //CData Section
document.writeln( child.nodeValue ) ;
}
195
Working with entities
196
CHAPTER 8 Working with XML Documents
<BOOK>
&chap1;
&chap2;
</BOOK>
•External entities that cannot be parsed These allow you to incorporate
material that is not XML content, such as images, into an XML document.
You declare them as follows:
<!ENTITY Logo SYSTEM "emblem.gif" NDATA gif>
NDATA states that the entity is not XML data and should not be parsed.
To include an external entity of this kind in a document, you must
reference it in an attribute of an element:
<GRAPHIC entity="Logo">
197
Working with entities
198
CHAPTER 8 Working with XML Documents
199
Using the DOM interface to create and edit XML documents
200
CHAPTER 8 Working with XML Documents
• createProcessingInstruction
• createTextNode
The following fragment creates an FName element (elem), and a text node
(tnode) with content “Ann T. Dote” in a DOMDocument object named
domDoc:
elem = domDoc.createElement( "FName" );
tnode = domDoc.createTextNode( "Ann T. Dote" );
These nodes currently have no place in the document, and the FName element
has no content.
Adding objects to You can add objects to a node using one of these methods of the DOMNode
documents object:
• The appendChild method
• The insertBefore method
• The replaceChild method
This fragment expands on the previous one to add the elements into a
document. The FName element is a child of a node named cust, and the text
node is a child of the FName element:
elem = domDoc.createElement( "FName" );
text = domDoc.createTextNode("Ann T. Dote" );
el = cust.appendChild( elem );
el.appendChild( text );
For more information, see “insertBefore method” and “replaceChild method”
in PowerDynamo Reference.
201
Using the DOM interface to create and edit XML documents
Removing and For attributes and other unordered objects (not elements) you can also use
replacing attributes methods defined on the collection of attributes. This collection, which is
unordered, is represented by a DOMNamedNodeList object, and you can use
the removeNamedItem method and the setNamedItem method to carry out
the operations.
For more information, see “removeNamedItem method” and “setNamedItem
method” in PowerDynamo Reference.
202
CH A PTE R 9 PowerDynamo Mail Support
About this chapter This chapter looks at how to send, receive, monitor and edit mail from a
PowerDynamo Web site.
For reference information on the PowerDynamo mail objects see
“DynaScript Predefined Objects” in PowerDynamo Reference.
Contents
Topic Page
About PowerDynamo’s mail support 204
Sending mail 206
Receiving mail 208
Deleting mail 210
Forwarding and replying to mail 211
A simple mail application 213
203
About PowerDynamo’s mail support
204
CHAPTER 9 PowerDynamo Mail Support
205
Sending mail
Sending mail
To send mail with PowerDynamo use the outgoing mail piece object. The
outgoing mail piece object has many different methods and properties to help
manipulate the way you want your outgoing mail piece to perform.
Some of the options that may be useful when sending mail through
PowerDynamo are as follows:
• Attachments You can send attachments such as files and documents
along with a mail piece. The attachment object allows the recipients of the
mail piece to manipulate the attachment as required.
• Error checking Use the GetErrorCode and GetErrorInfo methods to
monitor the status of a mail piece that is being sent.
• Multiple addresses You can send a single mail piece to many
people.
• Sender property You can specify a sender property. The sender
property represents the person that sent the mail piece. The from property
represents the person from whom the mail piece originated. For example,
if an assistant was sending a mail piece for their supervisor, the assistant's
name would be represented by the sender property while the supervisor's
name would be represented by the from property.
206
CHAPTER 9 PowerDynamo Mail Support
mp = new MailPiece();
mp.from = "your@address.com";
mp.AddRecipient( "recipient@address.com" );
mp.subject = "My first mail piece";
mp.body = "This mail piece was sent from a Dynamo
script.";
mp.Send();
-->
This code creates a mail piece called mp. Properties and methods are used
to define the sender, recipient, subject, and actual content of the mail piece.
The Send method actually sends the mail piece.
5 Replace your@address.com with your own address.
6 Replace recipient@address.com with the address of the recipient.
7 Save the script.
8 Execute the script.
9 To verify that the mail piece was sent, replace the line:
mp.Send();
with:
if( !mp.Send() ) {
document.writeln( mp.GetErrorCode() );
document.writeln( mp.GetErrorInfo() );
}
For additional information, see “The mail piece object (outgoing)” in
PowerDynamo Reference.
207
Receiving mail
Receiving mail
You can receive mail through Dynamo using a POP3 server, the DynaScript
mail list, and incoming mail piece objects.
208
CHAPTER 9 PowerDynamo Mail Support
inPiece.Retrieve();
document.WriteLn( "body: " + inPiece.body );
document.WriteLn( "sender: " +
inPiece.sender );
}
}
mlist.Disconnect();
-->
This script checks each mail piece to see if the subject line is “Bug
Report.” If it is, the contents of the mail piece and the sender display.
5 Save the script.
6 Execute the script.
209
Deleting mail
Deleting mail
You can use either the Delete method of the Retrieve method to delete mail
objects.
The Delete method allows you to delete a specific mail piece from the server,
while the Retrieve method marks a mail piece for deletion as soon as it has been
retrieved from the server. In either case the deletion occurs when you
disconnect from the POP3 server.
This example retrieves all mail pieces from the mail server and marks them for
deletion.
<!--SCRIPT
mlist = new MailList ("mailsrc.sybase.com", "dynamo7",
"dynamo", "dynamo7@mailsrc.sybase.com");
num = mlist.count
document.WriteLn("There are " + num + " messages in the
mail box");
for (i in mlist) {
inPiece=mlist[i];
inPiece.Retrieve(true);
document.WriteLn( "body: " + inPiece.body );
document.WriteLn( "sender: " + inPiece.sender );
}
mlist.Disconnect();
-->
210
CHAPTER 9 PowerDynamo Mail Support
Forwarding mail
You can either include your own message along with the forwarded mail piece
or you may forward a mail piece as it is with no additional text.
Select the mail piece you want to forward. For example:
mlist = new MailList ("mail.sybase.com", "elmo",
"dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
Specify that you want to forward the mail and the address to where you want
to forward it. For example:
forwardmp= mlistitem.Forward("sam@sybase.com")
The body of the original mail piece is now held in forwardmp.body. To add
your own text to the mail piece you would do something like:
forwardmp.body = ( "Please review this mail piece " +
forwardmp.body );
The full script looks similar to the following:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo",
"dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
forwardmp= mlistitem.Forward("sam@sybase.com")
document.writeln( forwardmp.GetErrorCode() );
document.writeln( forwardmp.GetErrorInfo() );
document.writeln(forwardmp.body);
forwardmp.body = ( "Please review this mail piece " +
forwardmp.body );
forwardmp.Send();
-->
211
Forwarding and replying to mail
Replying to mail
Select the mail piece you want to reply to. For example:
mlist = new MailList ("mail.sybase.com", "elmo",
"dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[0];
mlistitem.Retrieve();
Indicate that you want to use the Reply method and the address to which to
respond. For example, to respond to all recipients including the sender and
include the original mail piece in the body of the outgoing mail piece, enter:
replymp=mlistitem.Reply( "all", true );
To add your own text to the mail piece you enter something like:
forwardmp.body = ( "I have read the attached document
and all the changes look correct. " + replymp.body );
The mail piece is then sent in the normal fashion. The full script would look
similar to:
<!--SCRIPT
mlist = new MailList ("mail.sybase.com", "elmo",
"dynamo", "elmo@mail.sybase.com");
mlistitem = mlist[8];
mlistitem.Retrieve();
replymp=mlistitem.Reply( "all", true );
forwardmp.body = ( "I have read the attached document
and all the changes look correct. " + replymp.body );
replymp.Send();
-->
212
CHAPTER 9 PowerDynamo Mail Support
213
A simple mail application
</form>
</BODY>
</HTML>
214
CHAPTER 9 PowerDynamo Mail Support
mailListMain.stm <HTML>
<TITLE>mailListMain.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 display of mail in the mailbox</H1>
<form action=’mailList.stm’ method=post>
<table>
<tr><th align=left>Mail Server:</th>
<td><input type=text name=mailServer
size=30 value=mailsrv.sybase.com></td></tr>
<tr><th align=left>User Name:</th>
<td><input type=text name=username size=30
value=george></td></tr>
<tr><th align=left>Password:</th>
<td><input type=password name=passwd
size=30 value=dynamo></td></tr>
</table>
<input type=submit name=action value=Logon>
</form>
</BODY>
</HTML>
Notes • This page requests the name of the mail server that is to be used as well as
the user name and password for the mail pieces that are to be viewed.
• Only the mail that has been sent to the user name provided will display.
mailList.stm <HTML>
<TITLE>mailList.stm</TITLE>
<BODY>
<H1>Dynamo 3.5 Mail</H1>
<!--script
var parm = document.value;
var mlist = new MailList (parm.mailServer,
parm.username, parm.passwd,
parm.username+’@’+parm.mailServer, false);
if (mlist.GetErrorCode()>899) {
document.writeln(mlist.GetErrorCode());
document.writeln(mlist.GetErrorInfo());
} else {
var num = mlist.count
document.WriteLn("There are " + num + " messages
in the mail box<br>");
document.writeln("\n&
<table border>\n&
215
A simple mail application
<tr><th>From</th><th>Subject</th><th>Body</th></tr>");
for (i in mlist) {
mlist[i].Retrieve();
document.writeln("\n&
<tr><td>"+mlist[i].from+"</td>\n&
<td>"+mlist[i].subject+"</td>\n&
<td>"+mlist[i].body+"</td></tr>");
}
document.writeln("\n&
</table>");
}
mlist.Disconnect();
-->
<BR>
<a href=mailMain.stm>Return to the main menu</a>
</BODY>
</HTML>
Notes • This page displays all the mail messages that have been sent to the user
(specified in mailListMain.stm).
For information on the incoming mail piece and its methods see “The mail
piece object (incoming)” in PowerDynamo Reference.
Once you have created these files, you can start your mail application by
opening mainMail.stm in a browser.
216
CH A PTE R 1 0 Achieving Optimum Performance
with PowerDynamo
About this chapter This chapter describes how to design a PowerDynamo Web site to ensure
maximum productivity and performance.
Contents
Topic Page
Performance requirements 218
Increasing the performance of your Web site 222
Optimizing your document cache 223
Scheduling your scripts 228
Writing cacheable documents 230
Expensive methods and properties 234
Load balancing 235
Converting an inefficient Web site to an efficient Web site 237
Summary 240
217
Performance requirements
Performance requirements
PowerDynamo includes features that have been specially designed to make the
creation and optimization of high volume Web sites practically effortless.
Dynamo Web sites that are designed without thought to performance or site
specifications generally experience a slow down due to one or all of the
following reasons:
• Slow or excessive processing of scripts
• Exorbitant calls to the database
• Expensive use of connections
Processing of scripts
Web sites that are required to support large volumes of traffic must contain
documents that have been created with the criterion of the Web site in mind.
As a general rule, a Web document should take no longer to execute than the
time between requests to the Web site. For example, if a Web site has an
average of one request every three seconds, each Web document should be
written so that no document takes longer than three seconds to execute from
start to finish.
218
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
For more information on minimizing the processing time of your scripts, see
“Writing cacheable documents” on page 230 and “Scheduling your scripts” on
page 228.
For more information about running PowerDynamo on a multiple processor
system, see “Load balancing” on page 235.
219
Performance requirements
220
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
221
Increasing the performance of your Web site
222
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
223
Optimizing your document cache
Once a request for a document has been made, three basic paths are possible.
They are listed here in order of the most to the least efficient:
•Doc source and output held in cache The output is retrieved from the
cache and returned.
•Doc source held in cache The document is executed and the appropriate
information is stored in the cache and the output is returned.
•Doc source not held in cache A connection must be made to the Web site
to retrieve the document source. The document in executed and the
appropriate information is stored in the cache and the output is returned.
The most efficient path is requests for documents that have been written in such
a way as to support cached output.
For more information about writing documents with cacheable output, see
“Writing cacheable documents” on page 230.
224
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
225
Optimizing your document cache
The size of the cache The size of the document cache may affect how documents with specified
cachedOutputTimeOut values are cached.
If a document has a cachedOutputTimeOut value of 10 minutes, it will remain
in the cache for the full 10 minutes only if there is room for it along with the
subsequent documents that are called during those 10 minutes. When the cache
is full and a new document is requested, the document that was least recently
used is flushed to make room for the new document regardless of how long the
cachedOutputTimeOut value is set to.
226
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
Cache is flushed
The entire document cache is flushed if you modify or create documents
outside a Web server environment; for example, in Sybase Central.
227
Scheduling your scripts
❖ To schedule a document:
1 In Sybase Central, locate the script or template to schedule.
2 Right-click on the script or template and select Schedule from the pop-up
menu to start the Schedule wizard.
3 Select the time interval from the drop-down list in the wizard.
4 Enter a time, within the specified time interval, at which the document is
to be generated.
For more information about scheduling documents, see “Scheduling actions”
on page 57.
228
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
229
Writing cacheable documents
230
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
SIZE="5">
<OL>
<INPUT TYPE="radio" NAME="choice" value="less10">Less
than $10<BR>
<INPUT TYPE="radio" NAME="choice" value="less20">Less
than $20, more than $10<BR>
<INPUT TYPE="radio" NAME="choice" value="less30">Less
than $30, more than $20<BR>
</OL>
<P><INPUT TYPE="submit" VALUE="Submit List"></P>
<P><INPUT TYPE="RESET" VALUE="Clear Form"></P>
</FORM>
</BODY>
</HTML>
multiIntro.stm calls the following script, which in turn calls one of three scripts
depending on the parameter being passed:
mulchoice.stm <HTML>
<TITLE>Selected Products</TITLE>
<BODY>
<!--SCRIPT
231
Writing cacheable documents
<TH>color</TH>
<TH>unit_price</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
<!—DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
choice2.stm <H1>The following items are $10.00 to $20.00 in
price</H1>
<!--SQL
SELECT product.name, product.color, product.unit_price
FROM DBA.product product
WHERE product.unit_price <= 20.00 and
product.unit_price >= 10.00
-->
<TABLE BORDER>
<TR>
<TH>name</TH>
<TH>color</TH>
<TH>unit_price</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
<!—DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
choice3.stm <H1>The following items are $20.00 to $30.00 in
price</H1>
<!--SQL
SELECT product.name, product.color, product.unit_price
FROM DBA.product product
WHERE product.unit_price <= 30.00 and
product.unit_price >= 20.00
-->
<TABLE BORDER>
<TR>
<TH>name</TH>
<TH>color</TH>
232
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
<TH>unit_price</TH>
</TR>
<!--formatting--><TR>
<TD><!--data--></TD>
<TD><!--data--></TD>
<TD><!--data--></TD>
</TR><!--/formatting-->
</TABLE>
<!—DOCUMENT CACHED_OUTPUT_TIMEOUT = 10 -->
233
Expensive methods and properties
234
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
Load balancing
Load balancing – that is, running PowerDynamo on systems with multiple
processors or across multiple server machines – can be extremely effective for
improving PowerDynamo performance.
235
Load balancing
236
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
237
Converting an inefficient Web site to an efficient Web site
• Data that changes less than once an hour or documents that take a long
time to execute – Schedule these documents to run on a regular basis. This
makes the output readily available for subsequent requests.
• Data that changes once an hour or more often – Assign appropriate
cachedOutputTimeOut values to these documents.
Refer to “Setting a cachedOutputTimeOut value” on page 225 for more
information.
• Data that is constantly changing and must be accurate to the minute and
documents that take parameters – do not set cachedOutputTimeOut values
for these documents or schedule them with the scheduling wizard. Ensure
that the cache size is set high enough to hold their source so those requests
can be processed as quickly as possible.
A cache size should be set that is appropriate for the Web site that will be
utilizing it. It is important that the size of the cache is large enough to hold
all the active documents for at least a brief duration of time. If a cache size
is too small, the stored document output and source may be flushed to
make room for more recent documents before they have a chance to be re-
used before being unloaded.
238
CHAPTER 10 Achieving Optimum Performance with PowerDynamo
Next, we will look at the maximum and minimum number of User connections
for our Hockey Web site.
User connections At peak times our Web site uses a maximum of 20 User connections. Since this
is manageable without slowing down the overall performance of the Web site,
we can set the maximum number of User connections to 20.
During the slow times, there is a minimum of four User connections per
definition being used at any one time. By setting the minimum number of User
connections to four, we ensure that four connections will always remain in each
connection pool ready for use.
Dynamo connections The minimum and maximum connections for User connections applies per
definition. The minimum and maximum number of connections for Dynamo
connections is a total since each Web site has only one Dynamo connection.
For example, suppose there are two User connections defined in the
connections folder of Sybase Central; “sales_db” and “marketing_db”, setting
a minimum number of user connections to four would mean that eight
connections would be held in the connection pool, once created.
Our Hockey Web site requires a slightly smaller number of Dynamo
connections than User connections. The maximum number of Dynamo
connections will be set to fifteen and the minimum number of Dynamo
connections will be set to five.
Use of permanent and Finally, let's look at whether our Web site is using temporary or permanent
temporary connections within its scripts. We need to ensure that temporary User
connections
connections are used only in the appropriate instances. Scripts that use
temporary User connections that are reused in day to day Web use should be
changed to permanent User connections to minimize the processing required to
create a new connection each time.
For more information on connections see “Working with connections” on page
60.
239
Summary
Summary
Ways to increase performance:
Set an appropriate cache size
Set a cachedOutputTimeOut value in the appropriate documents
Create the most efficient type of connections in your documents
Set connection minimum and maximum defaults that are correct for your
Web site
Set an appropriate connection time out value
Schedule all possible documents for minimal processing time
Ensure that your scripts are specific and efficient
Limit the time of processing per document to use the CPU time the most
efficiently
240
CH A PTE R 11 Setting Up a Mobile Intranet
About this chapter This chapter describes how to set up a mobile intranet using
PowerDynamo and SQL Remote replication technology.
PowerDynamo allows you to browse both static and dynamic Web pages,
and enter data using HTML forms. SQL Remote provides message-based
replication technology. Together, these two applications enable you to set
up a mobile intranet that can be used on laptop computers without
requiring constant network connections.
Contents
Topic Page
SQL Remote replication technology 242
Requirements for a mobile intranet 243
Replicating a Web site 244
A Replication Tutorial 246
241
SQL Remote replication technology
242
CHAPTER 11 Setting Up a Mobile Intranet
Note You can use the same server for both data and Web site storage.
243
Replicating a Web site
244
CHAPTER 11 Setting Up a Mobile Intranet
245
A Replication Tutorial
A Replication Tutorial
This section includes a tutorial in which you set up a simple SQL Remote
replication system between an Adaptive Server Enterprise consolidated
database and a remote Adaptive Server Anywhere database to replicate a
Dynamo Web site along with accompanying data.
In the tutorial you act as the system administrator of a consolidated Enterprise
database, and set up a simple replication system. The replication system
consists of a sales database with two tables, and a Web site.
The consolidated database holds all of the database and Web site, while the
remote database has the entire Web site, all of one table, and some of the rows
in the other table.
The goals of the replication design are to provide each sales representative
with:
• The complete SalesRep table
• Those customers assigned to them
• A Web site for querying and updating their data
The tutorial describes how to meet this goal using SQL Remote and the Sybase
Central management utility.
The tutorial takes you through:
• Creating a consolidated database on your Adaptive Server Enterprise.
• Connecting to the consolidated database through Dynamo to create your
Web site.
• Creating a file-sharing replication system with a single Adaptive Server
Anywhere remote database.
• Replicating the Web site between the two databases.
The database
The tutorial uses a database that contains two tables and a Dynamo Web site
that performs queries on the tables. One table holds information about sales
representatives, and the other about customers.
Database schema The database schema for the tutorial is illustrated in Figure 11-1.
246
CHAPTER 11 Setting Up a Mobile Intranet
Each sales representative is represented by one row in the SalesRep table, and
each customer is represented by one row in the customer table.
Each customer is assigned to a single Sales representative, and this assignment
is built in to the database as a foreign key from the Customer table to the
SalesRep table. The relationship between the Customer table and the SalesRep
table is many-to-one.
The tables in the The tables are described in more detail as follows:
database
Table Description
SalesRep The SalesRep table has the following columns:
• rep_key An identifier for each sales representative. This is
the primary key.
• name The name of each sales representative.
The SQL statement creating this table is as follows:
CREATE TABLE SalesRep (
rep_key CHAR(5) NOT NULL,
name CHAR(40) NOT NULL,
PRIMARY KEY (rep_key)
)
Customer One row for each customer that does business with the company.
The Customer table includes the following columns:
• cust_key An identifier for each customer. This is the
primary key.
• name The name of each customer.
• rep_key An identifier for the sales representative in a sales
relationship. This is a foreign key to the SalesRep table.
The SQL statement creating this table is as follows:
CREATE TABLE Customer (
cust_key CHAR(12) NOT NULL,
name CHAR(40) NOT NULL,
rep_key CHAR(5) NOT NULL,
FOREIGN KEY ( rep_key )
REFERENCES SalesRep ( rep_key ),
PRIMARY KEY (cust_key)
)
247
A Replication Tutorial
248
CHAPTER 11 Setting Up a Mobile Intranet
From the Web site’s system folder, open the connect.ssc file. Modify the
<default> connection so there is no information specific to the
consolidated database. Your <default> connection should look like this:
site.LoadConnection( "<default>", "", "", "", "", "",
"" );
Save the file.
Install SQL Remote Install SQL Remote into the HQ database:
1 Open the hq database container in the left pane of Sybase Central.
2 Open the SQL Remote folder, double-click Setup SQL Remote, and
follow the instructions. For the tutorial, install the stable queue in the hq
database.
If your TEMPDB database is too small, you may have to add space to it.
For a full description of how to install SQL Remote, see the Data Replication
with SQL Remote manual.
Create directories for Make a directory for the files created in this tutorial. For example:
messages
mkdir c:\tutorial
Under this directory, create a directory for each of the two users of the
replication system:
mkdir c:\tutorial\hq
mkdir c:\tutorial\field
Add tables The next step is to add two user-defined tables to the consolidated database:
1 Connect to the hq database from Sybase Central.
2 Click the User Tables folder of the hq database.
3 Double-click Add Table, and use the Table Editor to create a table named
SalesRep with the following columns:
You do not need to use the Advanced Properties window. By default, the
columns do not allow NULL.
4 Double-click Add Table again, and use the Table Editor to create a table
named Customer with the following columns:
249
A Replication Tutorial
250
CHAPTER 11 Setting Up a Mobile Intranet
251
A Replication Tutorial
252
CHAPTER 11 Setting Up a Mobile Intranet
• WebSynchronize
• WebTemplate
• WebData
• WebVersion
4 Select SalesRep from the list of tables. You can leave the Conflict
Resolution fields as they are. Click Apply to mark the table for SQL
Remote replication.
5 Select Customer from the list of tables. Again, you can leave the Conflict
Resolution fields as they are. Click OK to mark the table for SQL Remote
replication.
To add a publication:
1 Click the Publications folder in the SQL Remote folder.
2 Double-click Add Publication.
3 On the first page of the wizard, name the publication SalesRepData.
4 On the next page, click Add Table and select SalesRep from the list.
Leave All Columns selected, and press OK to add the table. Do the same
for all the Dynamo Web tables:
• WebConnection
• WebDocumentType
• WebSynchronize
• WebTemplate
• WebData
• WebVersion
253
A Replication Tutorial
Click Add Table again, and select Customer from the list. Again, leave
All Columns selected. Click the Subscribe Restriction tab, and choose to
Subscribe by the column rep_key. Click OK to add the table to the
publication.
5 Complete the wizard to create the publication.
Add a subscription Each user ID that is to receive updates to a publication must have a
subscription to that publication. You need to add a subscription to the
SalesRepData publication for the remote database user field_user:
1 Double-click the Publications folder, which is in the SQL Remote folder,
so that the SalesRepData publication is displayed in the left pane.
2 Click the Remote Users folder so that remote users are displayed in the
right pane.
3 Drag field_user from the right pane onto the SalesRepData publication
in the left pane. In the Create Subscription window, enter rep1 in the With
Value box. This value represents the rep_key value for field_user in the
SalesRep table.
You have now set up the consolidated database.
No data will be exchanged until you start the database extraction utility.
254
CHAPTER 11 Setting Up a Mobile Intranet
You need to extract a database from the consolidated database for remote user
field_user:
1 Click the Remote Users folder, which is in the SQL Remote folder.
2 Right-click field_user, and select Extract Database from the pop-up
menu.
3 In the Extraction wizard, enter the user ID and password that you used to
create the tables and users in the database.
4 On the next page, select Start Subscriptions Automatically. Also, check
Create New Remote Database. Adaptive Server Anywhere must be
installed for Create New Remote Database to be available.
5 Create the database as file c:\tutorial\field.db and specify a transaction log
in the same directory.
6 Extract all parts of the schema (the default). Leave the other options at
their default settings, and create the remote database.
You should connect to the field database as DBA and confirm that all the
database objects are created:
1 From Sybase Central, choose Tools | Connect | Sybase Adaptive Server
Anywhere.
2 Enter DBA as the user and SQL as the password. Use upper case, as the
database was created as case sensitive. Select field.db, and Connect.
3 Open the database container, and confirm that the tables and user names
are present.
In a real-life SQL Remote setup, you would load the remote database field onto
the computer using it, together with an Adaptive Server Anywhere engine and
any required client applications. For the tutorial, we leave the database where
it is and use isql to input and replicate data.
The system is now ready for replication.
Replicating data
In this section of the tutorial, we’ll replicate data from the consolidated
database to the remote database, and from the remote to the consolidated
database.
255
A Replication Tutorial
256
CHAPTER 11 Setting Up a Mobile Intranet
2 Click Shutdown on the Message Agent window to stop the Message Agent
when the messages have been sent.
257
A Replication Tutorial
Create a template in your remote Web site that queries the data
In this section, we create a template that performs a query from the Adaptive
Server Anywhere remote database. This template queries data that has been
replicated from the consolidated database to the Adaptive Server Anywhere
remote database.
1 From Sybase Central, create a ODBC Data Source name to connect to
field.db.
2 Create a connection profile for field.db.
3 Connect to field.db.
4 In the left pane of Sybase Central, open the Site folder.
5 In the right pane, double-click Add Template.
6 On the first page of the wizard, enter a name for the template, for example,
RepProducts. Do not use spaces. Click Next.
7 Enter an optional description for the template and click Next again.
8 Use the default connection.
9 On the Add SQL Query page, click Select and enter a query to display the
cust_key, name, and rep_key columns.
10 Select one of the supplied formats from the list.
11 Click Finish.
You can view the output by right-clicking on the template and selecting
Browse Output.
258
CHAPTER 11 Setting Up a Mobile Intranet
259
A Replication Tutorial
260
CH A PTE R 1 2 Calling Jaguar Component
Methods from PowerDynamo
About this chapter Jaguar CTS makes it possible for multiple clients, whether Java,
PowerBuilder, Visual Basic or PowerDynamo, to execute methods from a
Jaguar component. Jaguar eliminates the need to write application logic
toward specific platforms or a specific client. Jaguar allows methods to be
created once, installed on a Jaguar server, and accessed from multiple
clients from a variety of platforms.
This chapter looks at how you can use PowerDynamo and Jaguar together
to serve up applications that require dynamic Web pages as well and
access components (Java/JavaBeans, CORBA C++, ActiveX, and C) that
run in Jaguar.
Contents
Topic Page
How do Jaguar and PowerDynamo work together? 262
What does Jaguar bring to PowerDynamo applications? 264
Setting up PowerDynamo as a client 266
Calling Jaguar components from a PowerDynamo script 271
Working with ADO record sets as PowerDynamo query objects 284
Working with Tabular Results 286
261
How do Jaguar and PowerDynamo work together?
262
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
263
What does Jaguar bring to PowerDynamo applications?
264
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
265
Setting up PowerDynamo as a client
266
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
267
Setting up PowerDynamo as a client
268
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
4 On the General tab, enter an ODBC data source name (for example,
Jaguar_dsn), and a Server name (for example, Jaguar).
5 Click OK to create the data source.
269
Setting up PowerDynamo as a client
270
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
271
Calling Jaguar components from a PowerDynamo script
272
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
273
Calling Jaguar components from a PowerDynamo script
274
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
275
Calling Jaguar components from a PowerDynamo script
received = query.next();
i = 0;
while( received ) {
metadata = query.getMetaData();
document.writeln( "*****" );
columns = metadata.getColumnCount();
for( j = 1; j <= columns; j++ ) {
value = query.getString( j );
document.writeln( value );
}
received = query.next();
i++;
}
-->
</HTML>
For more information, see “CreateComponent method” in PowerDynamo
Reference.
This example creates an instance of the SVU/SVUEnrollment component
called comp from a machine called testMachine. Once the object is created, its
method getMajors is called and the Record Set is displayed:
<!--SCRIPT
comp = java.CreateComponent( "SVU/SVUEnrollment",
"iiop://testMachine:9000", "guest", "" );
RecordSet = comp.getMajors();
query = java.CallStaticMethod(
"com.sybase.CORBA.jdbc11.SQL", "getResultSet",
RecordSet );
received = query.next();
i = 0;
while( received ) {
metadata = query.getMetaData();
document.writeln( "*****" );
columns = metadata.getColumnCount();
for( j = 1; j <= columns; j++ ) {
value = query.getString( j );
document.writeln( value );
}
received = query.next();
i++;
}
-->
For information on tabular results see, “Working with Tabular Results” on page
286.
276
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
GetHomeInterface method
Description Allows access to the EJBHome interface for a Jaguar component.
Syntax java.GetHomeInterface(component_name [, provider_url, user_id,
password] )
The parameters are:
•component_name The name of the component to instantiate.
Component names are composed as follows:
[<server-context>]<package>/<comp>
• server-context – The root naming context for the server where the
component is installed. server-context is optional and necessary only
if a root naming context has been set for the server. The root naming
context can also be given as the initial context in the provider_url.
• package – The Jaguar package to which the component belongs, as
displayed in Jaguar Manager.
• component – The component name, as displayed in Jaguar Manager.
You can view and edit this setting using the Naming Service tab of the
Server Properties window from Jaguar Manager. The default for a new
server is “/”. If you specified an initial name context in
GetHomeInterface()'s provider_url parameter, then the server context is
assumed to be relative to this initial name context. For example, if the
provider_url parameter is set to iiop://localhost:9000/USA/Sybase, and
your server's root context is USA/Sybase/Engineering, then you can
resolve component names as Engineering/package/component.
•provider_url The provider_url is optional and defaults to
“iiop://localhost:9000”. If used, it identifies the URL of the JNDI name
server. This parameter should be of the form iiop://<hostname>[:<iiop-
port>][/<initial-context>] where:
• hostname Is the host machine name for the Jaguar server that serves
as the name server for your application.
• iiop-port Is the IIOP port number for the server.
• initial-context Is the optional initial naming context, which can be
used to set a default prefix for name resolution. For example, if you
specify USA/Sybase/, then the component_name parameter is
assumed to be relative to this location in the name hierarchy. When
specifying the initial context, the trailing slash is optional; it is added
automatically if you do not specify an initial context that ends with a
slash.
277
Calling Jaguar components from a PowerDynamo script
•user_id The user name for the Jaguar session. If authorization is enabled for
your Jaguar server, this parameter is used to authorize access to Jaguar
components.
The user_id parameter is optional and defaults to “guest”.
•password The password for the Jaguar session. If authorization is enabled
for your Jaguar server, the password is used to authorize access to Jaguar
components.
The password parameter is optional and default is no password.
GetUserTransaction method
Description Allows access to the EJB UserTransaction object.
Syntax java.GetUserTransaction( [ <provider_url>, <user_id>, <password>] )
The parameters are:
278
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
Comments The components that participate in the transaction managed with the
UserTransaction object must be in the same server as the UserTransaction
object, which cannot be assumed if a Jaguar cluster is used to ensure that this
requirement is met:
1 Use the same name server to create the UserTransaction object that was
used when creating the component instances. That is, supply the same
provider_url to GetUserTransaction() and GetHomeInterface(),
CreateComponent(). The initial-context values of the URLs can differ.
279
Calling Jaguar components from a PowerDynamo script
2 Get the UserTransaction object and begin the transaction before creating
any component instances.
3 In addition, follow the same restrictions as other Java clients when using
the UserTransaction object. Refer to the Jaguar CTS Programmer’s Guide
and Jaguar CTS Reference Manual for details.
The UserTransaction interface defines exceptions that are thrown when errors
occur. For example, TransactionRolledbackException is thrown when
commit() is called after setRollbackOnly() has already been called for a
transaction.
As many of the methods in the UserTransaction interface for example, return
void, begin(), commit(), rollback(), these exceptions are the only way
to detect errors.
In DynaScript, exceptions are passed to the user through the
site.GetErrorInfo() method. That is, the exception is converted to an
error string. For example:
ut.begin()
...
ut.commit()
errMsg = site.GetErrorInfo();
if ((errMsg != null) && (errMsg != ""))
{
/* the transaction was not committed */
}
The UserTransaction.getStatus() method returns an integer value
indicating the status of the current transaction. Dynamo users can include the
script ~/system/utils/usertran.ssc to get the definitions of variables that map to
the integer values returned by getStatus().
import "~/system/utils/usertran.ssc"
...
ut = java.GetUserTransaction(...);
ut.begin()
status = ut.getStatus();
if (status != UserTran.STATUS_ACTIVE)
{
/* the transaction was not started */
}
...
280
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
281
Calling Jaguar components from a PowerDynamo script
objectName.Name="packageName_1/componentName_1"]
objectName.Initialize();
output=objectName.methodName(parameter);
-->
The Host, UserName, and Password are all optional properties, depending on
the scenario in which you are creating your instance of an ActiveX object.
•Host By default, host is set to localhost:9000. If the Jaguar server is
running on a different machine or the port number is a value other than
9000, you must set this property accordingly.
•UserName and Password The user name and password are optional
properties unless you are working with components that have had
component level security specified using Roles.
•Name The name property is optional if the package name is the same as
the module name and the component name is the same as the interface
name.
For more information on working with ActiveX and Jaguar, see the Jaguar
Programmer’s Guide.
Example This example creates an instance of an ActiveX object called comp. Once the
object is created, its method getMajors is called and the Record Set is
displayed:
<!--SCRIPT
comp = CreateObject( "SVU.SVUEnrollment" );
comp.Initialize();
RecordSet = comp.getMajors();
RecordSet.MoveFirst();
while( !RecordSet.EOF ) {
document.writeln( "*****" );
fields = RecordSet.Fields;
columns = fields.Count;
for( j = 0; j < columns; j++ ) {
field = fields.Item(j);
document.writeln( field.Value );
}
RecordSet.MoveNext();
}
-->
This example creates an instance of an ActiveX object called comp that resides
on a machine called testMachine. Once the Object is created, its method
getMajors is called and the Record Set is displayed:
282
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
<!--SCRIPT
comp = CreateObject( "SVU.SVUEnrollment" );
comp.Host = "testMachine:9000";
comp.Initialize();
RecordSet = comp.getMajors();
RecordSet.MoveFirst();
while( !RecordSet.EOF ) {
document.writeln( "*****" );
fields = RecordSet.Fields;
columns = fields.Count;
for( j = 0; j < columns; j++ ) {
field = fields.Item( j );
document.writeln( field.Value );
}
RecordSet.MoveNext();
}
-->
For more information about the CreateObject method, see “Built-in functions”
in PowerDynamo Reference.
For information on ADO record sets see “Working with ADO record sets as
PowerDynamo query objects” on page 284.
283
Working with ADO record sets as PowerDynamo query objects
284
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
document.writeln( value );
}
}
285
Working with Tabular Results
286
CHAPTER 12 Calling Jaguar Component Methods from PowerDynamo
}
}
287
Working with Tabular Results
288
A P PE N DI X A Setting Up the Adaptive
Server Anywhere Database
Server as a Service
About this appendix This appendix explains how to set up PowerDynamo to run with the
Adaptive Server Anywhere database server.
Contents
Topic Page
Why use the Adaptive Server Anywhere server? 290
Setting up the Adaptive Server Anywhere database server for 292
PowerDynamo
289
Why use the Adaptive Server Anywhere server?
For more information on running Adaptive Server Anywhere, see the Adaptive
Server Anywhere documentation.
290
APPENDIX A Setting Up the Adaptive Server Anywhere Database Server as a Service
291
Setting up the Adaptive Server Anywhere database server for PowerDynamo
292
APPENDIX A Setting Up the Adaptive Server Anywhere Database Server as a Service
3 In the Create New Data Source window, select the appropriate ODBC
driver and click OK.
4 In the SQL Anywhere ODBC configuration window, enter the data source
name, the server name, and the database name. Click OK.
Start-up options for If you are using SQL Anywhere 5.5.04 or earlier, you should set some start-up
SQL Anywhere 5.5.04 commands in the ODBC configuration window.
or earlier
If you are using Adaptive Server Anywhere 6.0 or later, you do not need to set
these start-up commands.
Click Options from the SQL Anywhere ODBC configuration window.
Figure A-1 illustrates how your start-up options should be set if you are using
SQL Anywhere 5.5.04 or lower.
Figure A-1: Startup Options window
If you are connecting to a remote database server, specify this start command:
c:\sqlany50\win32\dbclient.exe
If you are connecting to a database server on the same machine as the Web
server and DBCLIENT has been specified, the Agent should be Not Specified.
This does not start the DBCLIENT application, but allows access to the
database server.
Selecting Client as the Agent would cause the DBCLIENT application to start
unnecessarily, causing the local connection to be made through the network
which would cause a decline in performance. Select Client as the Agent only
if the database server is running on a different machine than the Web server.
293
Setting up the Adaptive Server Anywhere database server for PowerDynamo
Connect to PowerDynamo
Once you have completed your connection profile, you can connect to
PowerDynamo.
1 In Sybase Central, select Tools -> Connection Profiles.
294
APPENDIX A Setting Up the Adaptive Server Anywhere Database Server as a Service
2 Select the connection profile you want to connect with and click Connect.
295
Setting up the Adaptive Server Anywhere database server for PowerDynamo
296
A P PE N DI X B Language Support
About this appendix This appendix explains the language support that Dynamo provides for
double-byte and multi-byte character sets.
Contents
Topic Page
Language support 298
Usage of multi-byte characters 301
297
Language support
Language support
In many languages, each letter and number can be represented by a single-byte
character set. Each character is represented by an 8 bit byte. At most, 256
characters can be represented.
For many languages such as Japanese or Taiwanese 256 characters is not
sufficient. In cases such as these, a double-byte character set is necessary to
represent the large number of characters that make up the language. In a few
languages even double-byte character sets are not sufficient, in which case a
multi-byte character set is used.
Collation Sequence Each character set has its own collation sequence (sorting order) for characters
in a character set. The collation sequence is important when doing queries and
compares such as:
<!--SQL
SELECT emp_lname, emp_fname
from EMPLOYEE
where emp_lname > ’S’
-->
The collation sequence enables the database to determine if J is greater than or
less than S in this example.
298
APPENDIX B Language Support
The Japanese language DLL (dys03jpt.dll) sets the collation sequence to sjis
(Japanese Shift-JIS Encoding).
The English language DLL (dys03ent.dll) sets the collation sequence to
cp437, ASCII, United States.
To change the collation sequence used by PowerDynamo, create a new
database and specify the appropriate collation sequence for the required
language. Store the PowerDynamo Web site in the newly created database. The
Web site will have the same collation sequence as that specified for the new
database.
For more information about collation sequences, see the Sybase Adaptive
Server Anywhere User’s Guide.
299
Language support
300
APPENDIX B Language Support
301
Usage of multi-byte characters
302
Index
A B
abstract classes 143 browsers
access modifiers viewing Dynamo documents 27, 29
Java 151 viewing local Dynamo documents 27
accessing existing data 8
ActiveX
in Jaguar 265
using in Jaguar 266 C
ActiveX proxy automation server 266 cache
Adaptive Server Anywhere database server 289 document 223
ADO record sets 284 setting the size of 224
ADOQuery class 284 size 102, 226
agents cache size 102
and mappings 101 cacheable documents
database 102 writing 230
file 103 cachedOutputTimeOut
answering mail 211 setting a value 225
App folder 21 caching the generated output of a document 225
Application Servers CallStaticMethod method (java object) 277, 278
about 80, 94 case sensitive 106
application servers Dynamo tags 112
about 77, 79, 83, 87, 93, 94, 99, 128, 129 XML 169
configuring 83, 93, 99 catch block
application to launch when debugging 106 Java 153
arguments CDATA sections
scripts 139 about 194
URLs 138 CGI
arrays about 6, 96
Java 161 configuration 94, 96
tutorial 137 helper 96
attributes helper application 41
using 191 maximum number of connections 106
XML 191 support for 77
authoring tools System DSN 97
using with PowerDynamo 49 system path 94
character data
XML 193
class methods
about 149
1
Index
2
Index
3
Index
4
Index
F
E fields
ECMAScript Java 148
about 128 private 151
editing protected 151
XML documents 200, 201 public 151
editing script source 131 file-based Web sites 36
elements connections 37
DOM 189 files
DOMAttribute object 191, 192 and folders 43
DOMElement object 189, 190 creating a connection profile 39
DOMNode object and 189, 191 exporting 55, 56
getElementsByTagName function 190 importing 55
nodeType value 190 storing Web pages as 43
XML 189 filter
embedding instructions ISAPI 81
about 9 finally block
supported types 9 Java 153
entities flushing the cache 226
declaring 196 folders
external 196, 197 about 42
internal 196, 197 adding 42
referencing 196 App 21
types of 196 Configuration 41
XML 196 Connections 21, 42
error checking connections 60
Java 152 copying 42
using dynamo tags 118 creating 42
XML 181 deleting 43
escaping text Doc 21
XML 195 Helper Application for CGI 41
evaluating performance 70 linked 43, 44
examples linking with directories 43
DOM 182 main contents 42
exceptions moving 42
Java 152 ODBC administrator 41
executing scripts 131 Personal Web Server 41
expensive methods and properties 234 renaming 43
5
Index
6
Index
7
Index
8
Index
9
Index
10
Index
11
Index
12
Index
viewing source 48 U
wizard 11
UNIX
working with 46
port number 108
templates and scripts
URL
performance 222
about 3, 74, 138
temporary connections 60
accessing the sample Web site 28
testing
and the Personal Web Server 74
connections 62
case sensitive 106
text
mapping 100
replacement 12
prefixes 100
substitution 12
URL prefix
XML 193
and database mappings 102
XML elements 194
and file mappings 103
text replacement
and mappings 101
about 52
User connections 60
timeout
creating 62
connection 106
limiting 67
cookies 106
ltno connectiongt 68
toDOMDocument function
Utilities folder 41
using 187
application to launch when debugging 106
toXMLString function
connection timeout 106
using 174
cookie timeout 106
trace
Dynamo defaults 106
setting default 107
port number 108
tree
DOM documents 177
try block
Java 153 V
tutorials
arrays 137 valid documents
control statements 133 XML 167
Dynamo tags 113 variables
functions 134 data types 133
getting started with PowerDynamo 16 declaration 132
object inheritance 140 passing 52
passing variables 138 passing by value and reference 135
replication 246 replacing 138
scripts 130 tutorial 132
simple objects 135 void
variables and expressions 132 Java methods 148
writing HTML 130
type
objects 147
typing of variables 133
W
W3C standards
Document Object Model 177
wcmdpa24.dll 80, 94
13
Index
14
Index
Z
zip files
Java 151
15
16