Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / LiveCycle Developer Center /

Transforming JDBC service output using the Query for Multiple Rows as XML operation

by Steve Walker

Steve Walker

Created

17 December 2007

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
LiveCycle XML

Requirements

Prerequisites

  • LiveCycle ES installed, configured, and operational
  • LiveCycle Workbench ES installed and configured to communicate with LiveCycle ES
  • Familiarity with building orchestrations in LiveCycle Workbench ES
  • MySQL 5.0, or above, in order to use the sample database and knowledge of techniques for restoring a MySQL backup

User level

Intermediate

Sample files

  • jdbc_xslt_sample.zip (3 KB)

Additional Requirements

LiveCycle ES

  • Try
  • Buy

LiveCycle Workbench ES

  • Try
  • Learn more

This sample file contains TransformQuery.1.0.xml, which is an exported process and customer.sql, which is a MySQL backup.

Adobe LiveCycle Workbench ES provides a service for accessing relational databases. The JDBC service, found within the Foundation service category, contains multiple query and execution operations for relational data accessible via JDBC.  For orchestrations that require access to multiple rows from a table, the JDBC service delivers the operation called Query for Multiple Rows as XML.

The Query for Multiple Rows as XML operation returns an XML instance where each node has an attribute "type" with a value representing the database schema data type. This article demonstrates how to remove the "type" attribute from the XML instance using the XSLTService Transform operation. 

The use case

Let's assume that an orchestration requires multiple rows of data from a MySQL table called "customer" (see Figure 1).

The "customer" table with multiple rows of data
Figure 1. The "customer" table with multiple rows of data

Based upon the database schema, by default, the "Query for Multiple Rows as XML" service operation returns the following XML instance:

<root> <element> <id type="INTEGER UNSIGNED">1</id> <firstName type="VARCHAR">Fred</firstName> <lastName type="VARCHAR">Flinstone</lastName> <address type="VARCHAR">301 CobbleStone Way</address> <city type="VARCHAR">Bedrock</city> <state type="VARCHAR">CA</state> <zipCode type="INTEGER UNSIGNED">95110</zipCode> </element> <element> … </root>

However, the use case may require the XML instance to be formatted differently.  For illustration purposes, the data extracted from the "customer" table will be written to the file system as XML and the XML instance will be formatted as follow:

<customers> <customer> <id>1</id> <firstName>Fred</firstName> <lastName>Flinstone</lastName> <address>301 CobbleStone Way</address> <city>Bedrock</city> <state>CA</state> <zipCode>95110</zipCode> </customer> </customers>

Draw the orchestration

The process map will contain the following service operations (see Figure 2).

The process map
Figure 2. The process map

Use the following steps to create the process map by adding and linking instances of the following service operations:

  1. Choose Foundation > JDBC > Query for Multiple Rows as XML
  2. Choose Foundation > XSLT Transformation > Transform
  3. Choose Foundation > File Utilities > Write String

Add process Variables

Now define two process variables (see Figure 3).

Define two process variables
Figure 3. Define two process variables

Configure the JDBC operation

Follow the steps to configure the JDBC operation:

  1. Add a datasource name (see Figure 4).

    The datasource name is a JNDI name defined in a datasource file.  You can add data sources to the datasource file deployed by LiveCycle ES (..\deploy\adobe-ds.xml), or preferably, create "application" datasource files.  Separating datasource files from "adobe-ds.xml" eliminates the introduction of errors into the "system" datasources and optimizes portability, particularly for migration through the application development lifecycle.

Add a datasource name
Figure 4. Add a datasource name
  1. Add the SQL statement "select * from customer; " to retrieve all columns and rows from the "customer" table.
  2. Click the ellipses to the right of the XML information property.
  3. Add the root element name "customers" and the repeating element name "customer" (see Figure 5).
  4. Click Process Metadata to load the index and column name values.
  5. Click Test. The window will load an XML instance based upon a subset of data in the "customer" table.
Add the root element name and repeating element name
Figure 5. Add the root element name and repeating element name
  1. Copy and paste the XML instance from the Test window to a text editor.

    The XML instance will be used in the Transform operation for testing the XSL transformation.  On Windows platforms, avoid using Notepad as a text editor for XML. Notepad adds a Byte-Order-Mark (BOM) which can cause XSL transformations to fail. 

  2. Click OK.
  3. For the Output property XML document, add the variable customersXml.

Configure the XSLT operation

Follow the steps below to configure the XSLT operation:

  1. For the XML Source property Source XML document, add the variable customersXml.
  2. From the XSLT Source property XSLT – (literal value), click the ellipses. 
  3. Add the following XSL in the XSLT window: 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/ | node()"> <xsl:copy> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>

The template <xsl:template match="/ | node()"> performs matches on two patterns. The pattern / matches the root node and node() matches any node other than an attribute node and the root node.  The copy is then performed on all child nodes excluding attribute nodes. 

  1. Click the Test XML tab and copy and paste the XML instance that you saved in Step 7 above.
  2. Click the Test Result tab and click Test (see Figure 6).
Test result
Figure 6. Test result
  1. Click OK.
  2. For the Transformation Result property Transformed XML, add the variable customersStr.

Configure the file utilities operation

Do the following steps to configure the file utilities operation:

  1. Add the fully qualified pathname for the destination XML file (see Figure 7).
  2. For the Input property Value, add the variable customersStr.
  3. Optionally, select *Over Write to replace the file on each write operation.
Add the fully qualified pathname for the destination XML file
Figure 7. Add the fully qualified pathname for the destination XML file

Deploy and test the orchestration

Follow the steps below to deploy and test the orchestration:

  1. Save and activate the process.
  2. Test the orchestration—Open a browser and enter the URL to call the process via the default SOAP endpoint.  For example, if the process name is TransformQuery, the following URL will synchronously invoke a process instance (see Figure 8):

http://localhost:8080/soap/services/TransformQuery?method=invoke

The WS-Security implementation in Axis requires user authentication on the SOAP request. Use administrator/password for user name/password.

Invoke a process instance
Figure 8. Invoke a process instance

The SOAP envelope contains the node invokeResponse indicating the process executed successfully.

The invocation procedure defined above is a simple method to test an orchestration that has no input parameters. More typically, an orchestration deployed in LiveCycle ES will be invoked by a client application using one of the out-of-the-box mechanisms including a Java API, web services, e-mail, and watched folders. Using the LiveCycle Administration Console, a service can be configured to be exposed by one or more of these mechanisms. For more on invoking LiveCycle ES, see the LiveCycle ES SDK Help.

Go to the pathname specified in the Write String service to validate the creation of the file and the XML content.

Where to go from here

Adobe LiveCycle ES can extend your enterprise with new applications that span data capture, process orchestration, and document generation. This article demonstrated the assembly of services into a process without a user interface. Imagine…

  • your customers or partners securely accessing a process through an interactive PDF form or Adobe Flex application and the PDF form or Flex application contained pre-populated data
  • a process that swaps between a Flex application and a PDF form to optimize the user experience
  • a PDF document that could be taken offline, securely shared, and submitted back to the process
  • the captured data could then be integrated into a transactional database, a customer relationship management (CRM) system, or an electronic content management (ECM) system

For more on LiveCycle ES, visit the Adobe LiveCycle ES documentation page.

LiveCycle Workbench ES Help provides instructions for importing process versions.

Read MySQL documentation for instructions on how to restore a table and information on the General tab.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Binding an XML Schema Document (XSD) to repeating subform elements using Adobe LiveCycle Designer
  • Displaying a list of participants for a review stage in e-mail for Managed Review & Approval Solution Accelerator 9.5
  • Using the Execute Script Service in LiveCycle Workbench ES2 to build XML data
  • Pre-populating dropdown lists in dynamic PDF forms from a back-end data source using LiveCycle ES2.5
  • Record-based processing using LiveCycle Output ES

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement