[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: one line of xml to indented xml doc

Subject: RE: one line of xml to indented xml doc
From: Astor Rivera <arivera@xxxxxxxx>
Date: Sun, 24 Mar 2002 12:32:10 -0800
r.e oneline
Thanks for the help, although I may not have explained what I really needed.
You did point out some redundancy I found later that evening.
What I was trying to transform is a single line of xml being output from a
C++ app,
I must then take it and make it a well formed document with a hierachical
structure
and the transform is being done using MSXSL.

It must remain generic as the output tags will always vary.

Here is what I have up to now,

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match=" * | @* ">
<xsl:copy>
        <xsl:apply-templates select=" * | @* " />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Although I am currently looking into using xsl:key to generate the
hierarchical structure.

Any more help is great.

Thanks,
Astor



-----Original Message-----
From: Peter Davis
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: 3/24/02 2:26 AM
Subject: Re:  one line of xml to indented xml doc

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

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.