Re: [xsl] one line of xml to indented xml doc

Subject: Re: [xsl] one line of xml to indented xml doc
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Sun, 24 Mar 2002 02:26:35 -0800
On Friday 22 March 2002 15:52, Astor Rivera wrote:
> This is what I have and would like to know how to indent the document.
> The xml is coming from an application, and it's url encoded.

So you have a source document that is not indented, and you want to indent 
it?  Well, if that's the case, then you have the right idea with <xsl:output 
indent="yes"/>.  The problem is that processors aren't required to support 
that; I know that Xalan doesn't do a very good job of it.  Saxon does, 
however.  Your milage will probably vary, though.

BTW, your template has some very redundant parts:

> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
>         <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
>         <xsl:template match=" * | node() | text() | @* ">

"text()" and "*" are both redundant since they are matched by "node()".  So 
really, the only thing you need here is <xsl:template match="node() | @*"/>.

>                         <xsl:copy>
>                                 <xsl:apply-templates  select=" * | node() |
> @*"/>                            </xsl:copy>

Same thing with your apply-templates.  "*" is taken care of by "node()", so 
all you need is <xsl:apply-templates select="@* | node()"/>.

>         </xsl:template>
> </xsl:stylesheet>

Your question was a little confusing, so if this is not the answer you wanted 
you really should clarify what you mean by "indent".  I would also suggest 
re-indenting your stylesheet, because it's pretty ugly with the <xsl:copy> 
half way across the page :).  Or maybe that's where your having problems with 
indenting?  If so, please clarify.

-- 
Peter Davis
Excess on occasion is exhilarating.  It prevents moderation from
acquiring the deadening effect of a habit.
		-- W. Somerset Maugham

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


Current Thread