[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: reading a .xsv file in xslt

Subject: Re: reading a .xsv file in xslt
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Wed, 3 Feb 2010 10:19:33 +0100
Re:  reading a .xsv file in xslt
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.