Dear all,
I'm not really sure if this is a Sablotron problem or a general XSLT problem,
being quite new to both. Any help would be appreciated!
I'm trying to generate SQL from XML using XSLT in text output mode
For example:
<reference ID="5">
<year>1990</year>
<authors>Rodrigues NR et al.</authors>
<title>
p53 mutations in colorectal cancer
</title>
<journal vol="6" first_page="7555" last_page="7559">
Proc Natl Acad Sci U S A
</journal>
<keywords>
RNA Neoplasm, Protein p53
</keywords>
</reference>
If I use a simple template to match the <reference> tags:
<xsl:template match="reference">
insert into references(id, authors, title, year)
values (<xsl:value-of select="./@ID"/>,
'<xsl:value-of select="authors"/>',
'<xsl:value-of select="title"/>',
<xsl:value-of select="year"/>);
</xsl:template>
then my output looks like:
insert into references(id, authors, title, year)
values (5, 'Rodrigues NR et al.',
'
p53 mutations in colorectal cancer
',
1990);
In other words in lines like the <authors> one where the tags are immediately
around the data, everything is fine, but in lines like the <title>, the
newlines and indentation are carried across to the text output.
Is there any way to suppress this behaviour, or some clever trick with substr()
and translate() to remove leading and trailing white-space and returns?
Or do I have to write a Perl script to reformat the XML first (or the SQL
afterwards)???
Best wishes,
Andrew
--
Dr. Andrew C.R. Martin EMail: [EMAIL PROTECTED]
Lecturer in Bioinformatics WWW: http://www.bioinf.org.uk
University of Reading Tel. (0118) 987 5123x7022 Fax: (0118) 931 0180
"Microsoft may have given you Windows, but Linux gives you the whole house"