Re: [xsl] Formatting XML output

Subject: Re: [xsl] Formatting XML output
From: "Rick Quatro" <frameexpert@xxxxxxxxxxxx>
Date: Fri, 13 Jan 2006 12:28:04 -0500
Thanks for the help, but it still doesn't work. I am using a scripting language for FrameMaker called FrameScript, which allows me to access MSXML objects. Here is my basic script.

// Create the MSXML objects.
Set oXmlDoc = InitializeXObject{'Msxml2.DOMDocument.4.0'};
Set oStylesheet = InitializeXObject{'Msxml2.DOMDocument.4.0'};
If (oXmlDoc = 0) or (oStylesheet = 0)
 LeaveSub;
EndIf

// Create the stylesheet.
Set sStylesheet = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>';
Set sStylesheet = sStylesheet + '<xsl:output method="xml" indent="yes"/>';
Set sStylesheet = sStylesheet + '<xsl:template match="/">';
Set sStylesheet = sStylesheet + '<xsl:copy-of select="."/>';
Set sStylesheet = sStylesheet + '</xsl:template>';
Set sStylesheet = sStylesheet + '</xsl:stylesheet>';
// Load the stylesheet.
oStylesheet.loadXML{sStylesheet};


// Build up the XML document.
Set oRoot = oXmlDoc.createElement{'toc'};
oRoot.setAttribute{'title','Standard Operating Procedures Manual'};
oXmlDoc.appendChild{oRoot};
Set oFolder = oXmlDoc.createElement{'folder'};
oFolder.setAttribute{'title','0135 Technical Support'};
oFolder.setAttribute{'expanded','false'};
oRoot.appendChild{oFolder};
Set oFile = oXmlDoc.createElement{'file'};
oFile.setAttribute{'title','Response to Customer Support Telephone Calls'};
oFile.setAttribute{'refid','File01.txt'};
oFolder.appendChild{oFile};
Set oFile = oXmlDoc.createElement{'file'};
oFile.setAttribute{'title','Customer Support Call List'};
oFile.setAttribute{'refid','File02.txt'};
oFolder.appendChild{oFile};

// Transform the XML document.
Set sOutput = oXmlDoc.transformNode{oStylesheet};

// Save the XML to a file.
eStr.SaveToTextFile{sOutput,ClientDir+DIRSEP+'Output.txt'};

// Delete the objects.
Delete Object(oXmlDoc);
Delete Object(oStylesheet);

When this runs, Output.txt contains the XML declaration on a single line, but the rest of the XML is on the second line with no new-lines or indents.

<?xml version="1.0"?>
<toc title="Standard Operating Procedures Manual"><folder title="0135 Technical Support" expanded="false"><file title="Response to Customer Support Telephone Calls" refid="File01.txt" /><file title="Customer Support Call List" refid="File02.txt" /></folder></toc>


This may be an MSXML (or FrameScript) issue, but I thought I would try here first. Thanks.

Rick Quatro
Carmen Publishing
585-659-8267
www.frameexpert.com


----- Original Message ----- From: "Michael Kay" <mike@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, January 13, 2006 10:43 AM
Subject: RE: [xsl] Formatting XML output



<xsl:stylesheet...

<xsl:output indent="yes"/>

<xsl:template match="/">
 <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

Michael Kay
http://www.saxonica.com/

Current Thread