[xsl] Delimited output from XML source

Subject: [xsl] Delimited output from XML source
From: Maulik Modi <MModi@xxxxxxxxxx>
Date: Fri, 8 Jun 2001 16:27:32 -0500

I know this Q has been asked before and I have found several references of
it in the archive, however it does not specifically address what I am trying
to do.

Here is my problem:

I want to write a XSL for any XML input ( i do not have control) and convert
it into a delimited output (tab, comma separated or any delimeter passed in
by the user). Here is my approach:

1. Since I do not have control over the XML input file, first I want to
flatten the input file (Attributes get their own tagname).
2. Search through the now flattened XML file and extract out any elements
with duplicate names.
3. The final XSL file which will take the delimeter as a param and convert
each node into a delimited text file.

Currently I am stuck at Step 1. Following is the flatten.xsl (from the
archive, slightly modified...)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

 <xsl:strip-space elements="*" />

 <xsl:template match="/">
     <xsl:apply-templates mode="flatten" />

 <xsl:template match="*" mode="flatten">
    <xsl:when test="*"><xsl:apply-templates mode="flatten" /></xsl:when>
        <xsl:copy-of select="." />

 <xsl:template match="text()|@*" mode="flatten">
    <xsl:element name="{name(..)}">
      <xsl:value-of select="normalize-space(.)" />
 <xsl:template match="*|@*|text()" />

However, it does not convert any of the text() or attribute nodes of the
elemnts that have children. Any suggestions?

Step 2: I am leaning towards using the Muenchian key approach, any
Step 3: is there anything available? I saw the formatted text output
extension for XT. However, I would like to use a XSL for this slution.

Any help is appreciated.



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

Current Thread