Subject: RE: [xsl] one line of xml to indented xml doc From: Astor Rivera <arivera@xxxxxxxx> Date: Sun, 24 Mar 2002 12:32:10 -0800 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] one line of xml to indent, Peter Davis | Thread | Re: [xsl] one line of xml to indent, Thomas B. Passin |
Many Thanks! Re. RE. [xsl] Can I gr, gary cor | Date | [xsl] Working with 2 namespaces, Andreas Schlegel |
Month |