[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[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 |
Hi, 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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*" /> <xsl:template match="/"> <root> <xsl:apply-templates mode="flatten" /> </root> </xsl:template> <xsl:template match="*" mode="flatten"> <xsl:choose> <xsl:when test="*"><xsl:apply-templates mode="flatten" /></xsl:when> <xsl:otherwise> <xsl:copy-of select="." /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="text()|@*" mode="flatten"> <xsl:element name="{name(..)}"> <xsl:value-of select="normalize-space(.)" /> </xsl:element> </xsl:template> <xsl:template match="*|@*|text()" /> </xsl:stylesheet> 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 suggestions? 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. Regards, Maulik mmodi@xxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] msxml3.0 SP1 can't compar, Hahn, Kimberly | Thread | [xsl] ASP/XML/XSL Combo, Robert Dahnke |
Re: [xsl] Node vs TreeFragment, Mike Brown | Date | Re: [xsl] Producing Excel spreadshe, Peter Flynn |
Month |