xsl-list
[Top] [All Lists]

RE: Formatting XML output

2006-01-13 10:54:43
I believe that when you use transformNode(), the result tree is in the form
of a DOM, so the XSLT stylesheet is not serializing the output, and
therefore xsl:output has no effect. You need to use a method that invokes
the XSLT serializer rather than the DOM serializer.

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

-----Original Message-----
From: Rick Quatro [mailto:frameexpert(_at_)truevine(_dot_)net] 
Sent: 13 January 2006 17:28
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Formatting XML output

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(_at_)saxonica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>