Page 1 of 1

transforming to text file

Posted: Thu Nov 06, 2003 10:04 pm
by agashirazi
Hey,

Can someone please tell me, what functions do I use to transform an XML to a text file? I created an XSL shylesheet file, but it throws an error saying that the for-each statement is not placed right. But when I use the same structure with the HTML tags, it works fine.

Here is my code:

********************************************

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:for-each select="NSF_QUERY/QUERYITEM">
<xsl:value-of select="TITLE"/>
<xsl:value-of select="ABSTRACT/ABSTRACT_UNPARSED"/>
</xsl:for-each>
</xsl:stylesheet>


********************************************


Thanks a lot guys for my previous responses, really appreciat it.

Aga Shirazi

Posted: Thu Nov 06, 2003 11:13 pm
by george
Hi Aga,

You should place your code inside a template. Try something like:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="NSF_QUERY/QUERYITEM">
<xsl:value-of select="TITLE"/>
<xsl:value-of select="ABSTRACT/ABSTRACT_UNPARSED"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
You may consider also looking over an XSL tutorial like the one below:
http://www.zvon.org/xxl/XSLTutorial/

Best Regards,
George