cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

XML to XML

ptc-953422
1-Newbie

XML to XML

Hi, S.E.,


See Help topic "Composing a document using XSL" (help 15034).

Note the prerequisites: Print Composer option, Web/Wireless Composer, or
E3.

Here's the general recipe I've used:

[1] Open your source XML file in Arbortext Editor.
[2] Select the following menu-item path: "File | Compose | Using XSLT
..." This launches the "Compose Using XSL" dialog.
[3] Change the file extension in the file in the "Save As:" textbox,
which defaults to ".htm," to ."xml".
[4] Select your XSLT stylesheet in the "Stylesheet:" textbox that
generates your target XML output.
[5] [Optionally, apply profiling with the "Set Profiles:" button.]
[6] Click OK, and watch the task-bar message that indicates publishing
progress and when publishing is complete.

Note that AE 5.1 uses the Saxon 6.5.2 XSLT transformation engine. I just
downloaded and installed AE 5.2, and it now
uses the Saxon 6.5.3 XSLT transformation engine, FWIW. I think the
issue has some before in Adepters about
changing the engine to another one, e.g., MSXML, but I don't remember
what the result of that discussion was.
As always, STA! (Search the Archive)


--Jack

jkulas@lsijax.com
Logistic Services International, Inc.
Jacksonville, FL
1 REPLY 1

The ACL code sitting behind the Compose Using XSL code does not check
for licenses. I asked Arbortext support if the license check was missing
or if the documentation was wrong:

"You are correct. Compose -> XSL does not require a Web Compose, Print
Compose, or E3 license. Please note that Compose -> XSL does not convert
graphics to a web-friendly format, but you can also use Compose -> HTML
without additional licenses. Compose -> HTML will convert the graphics.
Compose -> HTML Help is also available without additional licenses.

I will file a documentation correction CR.

Other notes: Print Composed with an XSL-FO stylesheet will still require
a Print Compose license. Compose -> PDF also requires a Print Compose
license, since the first half of that process calls Print Compose to
create a postscript file.

If you don't need any of these processes, then I would guess you don't
need Print Compose licenses."

This was as of 10/15/2003 in Epic 4.4. Case # 25607; CR # 57584.

In both 4.4K and 5.1H, you want compose::compose_using_xsl() defined
within packages\tools\comp_usingxsl.acl. A third parameter was added
between these versions. [eval menu_cmd("File.Compose.Using XSL") ->
ComposeUsingXSL -> compose_xsl() -> compose_using_xsl()]

What follows is an implementation allowing one to pre-populate the
output filename and xslt filename fields, optionally performing the
transformation in "batch" (dialog not shown). I share this as it took a
bit to figure out. I filed several enhancement requests based on the
hoops I jumped through. In any case, I hope someone will enjoy.

This is only tested against 4.4K. Given there are differences in 4.4K
and 5.1H's implementations, this very well may only work in 4.4K.

It starts off with some constants and window utilities...may want to
jump straight to composeUsingXsl(). The "X" and "Y" refer to specific
DTDs we transformed between.




# Constants required by xslcommon package.
package constants;


global Y_INPUT_DIRNAME = "Y_XML";
global SCRIPTS_DIR = main::ENV[ "APTCUSTOM" ] . main::PCS . "scripts";
global XSLT_X_TO_Y_FILE = SCRIPTS_DIR . main::PCS . "XtoY.xsl";





# Window utils required by xslcommon package.
package uWindow;


#
# Determine if the given window id is valid.
#
function isWinValid( win )
{
return ( window_state(win) >= 0 && win > 0 )
}


#
# Set status message on given window, if given window id is valid.
#
function setMessage( msg = " ", win = current_window() )
{
if ( isWinValid( win ) )
{
window_set( win, "message", msg );
}
}






#
# Purpose: Use core Epic to perform XSLT transformation of X to
# Y, while also providing defaults based on our workflow and
# environment.
#
# Code modifies array used by core.
#
# Epic Version: 4.4K
#


# Source the distributed packages first so make sure the
# compose::xsl_recent_params[] array gets initialized.
source comp_usingxsl;


package xslcommon;


require compose;
autoload epicutil::SerializeKeyed() epicutil;
autoload epicutil::UnserializeKeyed() epicutil;


#
# Only allow source if not done already
#
if ( defined( INITIALIZED ) && INITIALIZED ) { return };


#
# Standard package globals
#
global _STRICT_;
global PACKAGE_ID = package_name();


#
# Custom types, allowing for custom processing. Presently, there is only
one
# such type implemented. If you wish to implement another type, add a
global
# and account for it in both preXslDialog() and postXslDialog().
#
global CUSTOM_TYPE_DEFAULT = 0;
global CUSTOM_TYPE_X_TO_Y = 1;


# Values used in Epic proper's compose::xsl_recent_params[] array.
global DELIM_PRIMARY = chr( 1 );
global KEY_OUTPUT_FILE = "outputFile";
global KEY_STYLESHEET = "stylesheet";


#
# Perform any work before Epic's "Compose Using XSL" dialog is
displayed, based
# on current "custom type".
#
function preXslDialog( customType, paramArr[], doc = current_doc() )
{
local batch = 0;

# Manipulate core array shelf, for current doc, specifying workflow
output
# file name and our XSLT file.
if ( customType == CUSTOM_TYPE_X_TO_Y )
{
local win = doc_window( doc );
if ( uWindow::isWinValid( win ) )
{
uWindow::setMessage( "Preparing for transformation...", win );
}

batch = 1; # Change batch default to true.

# Ensure there's a shelf for this doc.
if ( !defined( compose::xsl_recent_params[ doc ] ) )
{
compose::xsl_recent_params[ doc ] = ";
}

# Extract data.
epicutil::UnserializeKeyed( compose::xsl_recent_params[ doc ], \
paramArr, DELIM_PRIMARY );

# Edit array data.
# -->Below is our business logic of where we wanted the output.
local basename = basename( doc_path( doc ) ); # keep file
extension.
local dir = dirname( doc_path( doc ) );
chop( dir ); # lop off path separator
# parent dir plus Y subdir name
dir = dirname( dir ) . constants::Y_INPUT_DIRNAME;
if ( file_directory( dir ) )
{
paramArr[ KEY_OUTPUT_FILE ] = dir . main::PCS . basename;
}
else
{
batch = 0;
}
if ( access( constants::XSLT_X_TO_Y_FILE, "r" ) )
{
paramArr[ KEY_STYLESHEET ] = constants::XSLT_X_TO_Y_FILE;
}
else
{
batch = 0;
}

# Encode data.
compose::xsl_recent_params[ doc ] = epicutil::SerializeKeyed(
paramArr, \
DELIM_PRIMARY );
}

return batch;
}


#
# Perform any work after Epic's "Compose Using XSL" dialog is displayed,
based
# on current "custom type".
#
function postXslDialog( customType, doc = current_doc() )
{
}


#
# Encapsulate call to Epic's "Compose Using XSL..." dialog, providing
# customization layer.
#
function composeUsingXsl( customType = ", doc = current_doc() )
{
# Give doc focus.
local savedDoc = current_doc();
if ( doc != savedDoc )
{
current_doc( doc );
}

# Perform pre XSL dialog work, if any.
local paramArr[];
local batch = preXslDialog( customType, paramArr, doc );

# Invoke core Epic's "Compose Using XSL" dialog.
if ( batch )
{
compose::compose_using_xsl( doc, paramArr )
}
else
{
ComposeUsingXSL;
}

# Perform post XSL dialog work, if any.
postXslDialog( customType, doc );

# Restore doc focus, if necessary
if ( doc != savedDoc )
{
current_doc( savedDoc );
}
}


#
# Initialize this package.
#
function initPackage()
{
global INITIALIZED = 1;
}


initPackage();





-Brent
Announcements