[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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]"/>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|