Subject: RE: Formatting XML output
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 13 Jan 2006 17:54:43 -0000
|
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@xxxxxxxxxxxx]
> Sent: 13 January 2006 17:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: 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@xxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Friday, January 13, 2006 10:43 AM
> Subject: RE: 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/
|