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 use pattern metacharacters as a field delimiter may require additional precautions. (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)" regex='{$splitPattern}'> Thanks for this instructive example! -W On Wed, Feb 3, 2010 at 9:23 AM, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote: > > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] reading a .xsv file in xs, Andrew Welch | Thread | Re: [xsl] reading a .xsv file in xs, ac |
Re: [xsl] dateTime format string, A, Dave Pawson | Date | Re: [xsl] are all strings in a sequ, ac |
Month |