Results: Do you know how to use XSLT to convert XML to tabulated format ? 

5 You may not vote on this poll

  • No, dunno.
  • I know how, but I won't tell :-)
  • The XSLT specs are not make for this situation
  • Use xalan !
  • Use jato !
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Rep Power

    Question XML to tabbed format (xalan) ?

    I am trying to convert an XML file holding a stock trading history to tabulated format without writing a lot of code.
    The XML file is nested and uses tabulators to give a nice look.

    However, using XSLT with xalan, indent="no", I always end up with tabulators in the output. I believe they are copied from the input by apply-templates.

    Is there a way to avoid this, and to get a file which holds the values separated by tabulators ?

    My two other options right now are using jato (which seems to much, since I only need the data conversion, not the data objects) or writing my own skinny XML parser.

    I look forward to your input.
    Here a little flame to spark replies: Surely it must be possible to produce other formats from XML without much trouble ?

    Both xml and xsl attached.
    (Attached manually since I somehow lost the attachment.)

    ----- histvalues.xsl -----
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"

    <xslutput method="xml"
    version = "1.0"
    omit-xml-declaration = "yes"
    standalone = "no"
    doctype-public = "text/public"
    doctype-system = "text/system"
    cdata-section-elements = ""
    media-type = "text/plain"

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

    <xsl:template match="histvalues">[<xsl:apply-templates/>]</xsl:template>

    <xsl:template match="symbol">symbol=<xsl:value-of select="@sym"/>[<xsl:apply-templates/>]</xsl:template>

    <xsl:template match="day">day=<xsl:value-of select="@count"/> <xsl:apply-templates/></xsl:template>

    <xsl:template match="price"> p<xsl:apply-templates/>P</xsl:template>

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

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

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

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

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

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


    ----- histvalues.xml -----
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <?xml-stylesheet href="histvalues.xsl" type="text/xsl" ?>


    <symbol sym="SIE.ETR">

    <day count="0"> <price>67.94</price>


    <day count="1">



    Last edited by Highlander; July 13th, 2001 at 05:58 AM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Rep Power

    Do you want to produce another XML file or just the info from the XML file with the vlaues in tab format. Sorry but your request seemed a bit fuzzy?

    have you come across JDOM (, its a java package that allows to do do really handy things to xml files. You can create new xml files, but for your needs you can also read existing xml files.

    once you have it read into your java program, you can do whatever it is you want to it!(Still a bit fuzzy on that one )

    Its opensource and easy to use. Thats of course if you know java? Still java is handy as well...

    Hope that helps
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Rep Power

    Thumbs up Xml to non xml tabbed format

    No, I want to produce non-xml tabbed format.

    Right now, I find jato nice to use; I started from the code in the file/directory/tree example. I build my object hierarchy using jato, then produced output using a visitor/descend pattern.

    The fact that dom-based parsers like jato have to build the parse tree before they allow you to process the input seems a bit annoying, that is, forbidding, to a (near-)real-time application processing lots of data. That is the only gripe have with jato.

    Maybe the very basic parser/tokenizer that you get if you use sax or sax2 is really all you need, but it seems a little crude and uninspiring to me. It could need a jato-like wrapper.

IMN logo majestic logo threadwatch logo seochat tools logo