XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming
View Poll Results: Do you know how to use XSLT to convert XML to tabulated format ?
No, dunno. 3 60.00%
I know how, but I won't tell :-) 1 20.00%
The XSLT specs are not make for this situation 0 0%
Use xalan ! 0 0%
Use jato ! 1 20.00%
Voters: 5. You may not vote on this poll


Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old July 13th, 2001, 05:53 AM
Highlander Highlander is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 2 Highlander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xslt">

<xslutput method="xml"
encoding="UTF-8"
indent="yes"
xalan:indent-amount="111"
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>

</xsl:stylesheet>

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

<histvalues>

<symbol sym="SIE.ETR">

<day count="0"> <price>67.94</price>
<volume>7057625.0</volume>
<low>67.72</low>
<high>69.9</high>
<kassa>68.16</kassa>
<closedate>994269929</closedate>
<clearclosedate>2001-07-04</clearclosedate>

</day>

<day count="1">
<price>64.04</price>
<volume>6784440.0</volume>
<low>63.31</low>
<high>66.9</high>
<kassa>63.8</kassa>
<closedate>994356324</closedate>
<clearclosedate>2001-07-05</clearclosedate>

</day>


</symbol>

</histvalues>

Last edited by Highlander : July 13th, 2001 at 05:58 AM.

Reply With Quote
  #2  
Old July 17th, 2001, 11:16 AM
Hoggie Hoggie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Ireland
Posts: 10 Hoggie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey,

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 (http://www.jdom.org), 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
cya

Reply With Quote
  #3  
Old July 20th, 2001, 10:32 AM
Highlander Highlander is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 2 Highlander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XML to tabbed format (xalan) ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway