Re: [xsl] reading a .xsv file in xslt

Subject: Re: [xsl] reading a .xsv file in xslt
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Wed, 3 Feb 2010 10:19:33 +0100
There's certainly many ways how one can vary this, with field names
being used as tags rather
than attribute values, etc.

Also, it's easy to extend this to a wider range of formats, i.e., DSV,
by adding another
parameter and a dynamically constructed split pattern although being able to
pattern metacharacters as a field delimiter may require additional
(My "test" data file uses semicolons as delimiters.)

<xsl:param name="fieldDel">,</xsl:param>
<xsl:variable name="p1">(("[^"]*")+|[^</xsl:variable>
<xsl:variable name="splitPattern" select="concat($p1, $fieldDel,
']*)', $fieldDel)" />

<xsl:function name="fn:getTokens" as="xs:string+">
    <xsl:param name="str" as="xs:string" />
    <xsl:analyze-string select="concat($str, $fieldDel)"

Thanks for this instructive example!


On Wed, Feb 3, 2010 at 9:23 AM, Andrew Welch <andrew.j.welch@xxxxxxxxx>
> > Also, but purely as a matter of taste and case, since all cell values are
> > strings, I would tend to use attributes, replacing
> >       <elem name="{.}">
> >       <xsl:value-of select="$lineItems[$pos]" />
> >       </elem>
> > with
> >        <xsl:attribute name="{.}" select="$lineItems[$pos]"/>

Current Thread