[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL Script for XMetal2.1

Subject: XSL Script for XMetal2.1
From: "Uslu, Cihan Y (MED)" <Cihan.Uslu@xxxxxxxxxx>
Date: Thu, 29 Aug 2002 11:08:06 -0500
alert xsl
Hi,
I was wondering if any of you have experience with writing XSL scripts
for XMetal2.1 , for preview in HTML function? I am trying to write a XSL
script for this purpose and I would like to know how I can pass
parameters to XSL script, so that I can view the HTML output for a
specific page, instead of seeing the whole document.

Thanks for your help.

Cihan

---------XSL Script---------

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:param name="moduleNum"/>
	<xsl:param name="sectionNum"/>
	<xsl:param name="screenNum"/>
-------------------------------------------------------------------


JavaScript Macro I use within XMetal
-------------------------------------------------------------------
// This macro gets called when the user has selected Page Preview view,
  // or Preview in Browser.  The BrowserURL property is the URL that
will 
  // be passed to the browser.  On entry, it contains the URL of a
temporary
  // copy of the XML file being edited.  We apply an XSLT stylesheet to
create
  // an HTML file and set BrowserURL to be the path to this file.
// This macro illustrates the use of the MSXML component to do an
// XSL transformation.  Note that the version of MSXML that ships
// with IE5 is not compliant with the final recommendation of the
// W3C XSLT working group.

function doOnBeforeDocumentPreview() {

  
  // Load the XML document into MSXML
  var result = "";
  var xmlurl = ActiveDocument.BrowserURL;
  try {
    var xmldoc = new ActiveXObject("MSXML2.DOMDocument");
  }
  catch(exception) {
    result = reportRuntimeError("Page Preview Error:", exception);
    Application.Alert(result + "\nYou need to get the latest version of
MSXML from the Microsoft site.");
    ActiveDocument.BrowserURL = "";
    return;
  }
  xmldoc.async = false;
  xmldoc.validateOnParse = false;
  xmldoc.load(xmlurl);
  
  // Load the XSL stylesheet
  try {
    var xsldoc = new ActiveXObject("MSXML2.DOMDocument");
  }
  catch(exception) {
    result = reportRuntimeError("Page Preview Error:", exception);
    Application.Alert(result + "\nFailed second use of MSXML.");
    ActiveDocument.BrowserURL = "";
    return;
  }
  var xslurl = Application.PathToUrl(Application.Path +
"\\Display\\course.xsl");
  xsldoc.async = false;
  xsldoc.load(xslurl);

  var htmlout = "";
  var errPos = "NOERROR";
  if (xmldoc.parseError.errorCode != 0) {
    result = reportParseError(xmldoc.parseError);
    errPos = "XML";
  }
  else
  {
    if (xsldoc.parseError.errorCode != 0) {
      result = reportParseError(xsldoc.parseError);
      errPos = "XSL";
    }
    else
    {
      try {
        htmlout = xmldoc.transformNode(xsldoc);
      }
      catch (exception) {
        result = reportRuntimeError("Page Preview Error:", exception);
        errPos = "TRANSFORMNODE";
      }
    }
  }
  if (result != "") {
    Application.Alert(errPos + " : " + result);
    ActiveDocument.BrowserURL = "";
    return;
  }
    
  // Get name of HTML file for output
  // If the doc is not saved, set the temp file path to "Document".
  var strTempFilePath; 
  if ( ActiveDocument.Path ) {
    strTempFilePath = ActiveDocument.Path;
  } else {
    strTempFilePath = Application.Path + "\\Document";
  }

  // Create the document property for PreviewTempFile.
  var ndlProperties = ActiveDocument.CustomDocumentProperties;
  var ndProperty    = ndlProperties.item( "PreviewTempFile" );

  // Reuse an existing temp file, or create a new one.
  var strTempName;
  if ( ndProperty ) {
    strTempName = ndProperty.value;
  } else {
    strTempName = Application.UniqueFileName( strTempFilePath, "XM",
"htm" );
    ndlProperties.Add ( "PreviewTempFile", strTempName );
  }
  
  // HTML output path is the temp file.
  var htmPath = strTempName;

  // Write the resulting HTML
  try {
    var fso = new ActiveXObject("Scripting.FileSystemObject");
  }
  catch(exception) {
    result = reportRuntimeError("Page Preview Error:", exception);
    Application.Alert(result + "\nFailed to invoke
Scripting.FileSystemObject\nYou need to get Windows Scripting Host from
the Microsoft site.");
    ActiveDocument.BrowserURL = "";
    fso = null;
    return;
  }
  var ArgOverwrite = true;
  var ArgUnicode = true;
  if (Application.UnicodeSupported == false) {
    ArgUnicode = false;
  }
  tf = fso.CreateTextFile(htmPath, ArgOverwrite, ArgUnicode);
  tf.Write(htmlout);
  tf.Close();

  // Change the URL to be sent to the browser to the HTML output file
  var htmURL = Application.PathToURL(htmPath);
  ActiveDocument.BrowserURL = htmURL;
  fso = null;
}
doOnBeforeDocumentPreview();

------------------------------------------------------------------------
-------------------------------------------- 


 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.