Andrew,
xml doesn't care about your data :), text() content of the title tag
contains two newlines. Correct XML document should't contain them.
If you need to process "bad" data, you have to use some trick. I can't
tell you, if the substr() and translate() function are sufficient or
not. Try to experiment, and feel free to ask more questions.
Pavel
Andrew C.R. Martin wrote:
> 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
--
Pavel Hlavnicka
Ginger Alliance Ltd.
Prague; Czech Republic