Click to See Complete Forum and Search --> : output xml results into plain text file


Brad
11-07-2001, 01:51 PM
Hello.

I would like to output some info from an xml into a text file.

The xml looks like:

<EPILOTRESULTS>
<RESULTS>
<row urllink="http://ww.domain.com"
description=" WE LEND NATIONWIDE"
title="DOT.COM ONLINE HOME LOANS"
</RESULTS>
</EPILOTRESULTS>

The text i would like to be outputed needs to look like this:

-------------------------------------
function sa(url,site_text,desc,cluster)
{
this.url = url
this.site_text = site_text
this.desc = desc
this.cluster = cluster
}
article = new Array(
new sa("http://www.domain1.com","Alibris","Descr goes here ","text"),
new sa("http://www.domain2.com","Book Closeouts","Imagine a hand-drawne one.
","text"),
new sa("http://www.domain3.com","Elephant Books","The Artlounge","text"),
new sa("http://www.domain4.com","Exposing Art","Exposing Art.","text")
);


-----------------------------------------

i need to insert the "urllink" from the xml into the text output where it
says "domain1.com" and other results too like title where it says "Alibris",
etc.

Can someone please advise how the xslt stylesheet would need to look like
to do this.

Steve
11-08-2001, 01:04 PM
Try using the <xsl:text> tag in your xsl stylesheet.

Brad
11-08-2001, 01:06 PM
ok, i made some progess myself. i am able to output the following:

-------------------------
function sa(url,site_text,desc,cluster)
{
this.url = url
this.site_text = site_text
this.desc = desc
this.cluster = cluster
}
article = new Array(
new sa(" "," "," ","text"),
);

---------------

BUT the values from the xml dont get inserter into the " "," "," " spaces

:(



here's my stylesheet. am i doing anything wrong?


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes"/>

<xsl:template match="RESULTS/row">

<xsl:text> function sa(url,site_text,desc,cluster) </xsl:text>
<br/>
<xsl:text> { </xsl:text>
<br/>
<xsl:text> this.url = url </xsl:text><br/>
<xsl:text> this.site_text = site_text </xsl:text><br/>
<xsl:text> this.desc = desc </xsl:text><br/>
<xsl:text> this.cluster = cluster </xsl:text><br/>

<xsl:text> } </xsl:text>
<br/>
<xsl:text>article = new Array( </xsl:text><br/>

<xsl:text>new sa(" </xsl:text>
<xsl:value-of select="@urllink"/>
<xsl:text>"," </xsl:text>
<xsl:value-of select="@title"/>
<xsl:text>"," </xsl:text>
<xsl:value-of select="@description"/>
<xsl:text>","text"),</xsl:text><br/>
<xsl:text>);</xsl:text>
</xsl:template>

<xsl:template match="COPYRIGHT">
<tr>
<td valign="top" colspan="5">
<font color="white" size="0">
<xsl:value-of select="."/>
<xsl:text></xsl:text>
</font>
</td></tr>
</xsl:template>

</xsl:stylesheet>