Home Forums General XMetaL Discussion Code Request: Process content with XSLT Reply To: Code Request: Process content with XSLT

Crispness

Reply to: Code Request: Process content with XSLT

Thanks Gunnar but not really what I was looking for. I already have some code to do something very similar
[code]function doXformXML(strXMLIn,xslPath)
{
var strXMLOut = null;
if(!isWellformedDoc()){
Application.Alert(“Current document is an invalid document!”);
return;
}

var fso = null;
var xmldoc = null;
var xsldoc = null;
try {

var fso = createFileSystemObject();
if (fso == null)
throw null;

//xsl-hmtl file doesn't exist, do nothing.
// if (!fso.FileExists(xslPath))
// throw null;

 
// Load the XML document into MSXML
var xmldoc = getDOMDocument();
if (xmldoc == null)
throw null;

xmldoc.async = false;
xmldoc.validateOnParse = false;
xmldoc.loadXML(strXMLIn);
if (xmldoc.parseError.errorCode != 0)
throw “XML: ” + formatParseError(xmldoc.parseError);

// Load the XSL stylesheet
xsldoc = getDOMDocument();
if (xsldoc == null)
throw null;
xsldoc.async = false;
xsldoc.load(xslPath);
if (xsldoc.parseError.errorCode != 0)
throw “XSL: ” +  formatParseError(xsldoc.parseError);

var htmlout = “”;
try {
htmlout = xmldoc.transformNode(xsldoc);
} catch (exception) {
throw “TRANSFORMNODE: ” + formatRuntimeError(“Save As HTML Error:”, exception);
}
   
} catch (e) {
if (e)
Application.Alert(e);
return false;
} finally {
fso = null;
xmldoc = null;
xsldoc = null;
}
return htmlout;
}
[/code]

What it doesn't do is to take a fragment and replace it with the results of the transform.

Thats the part I need help with.

Reply

Products
Downloads
Support