2008/7/9 netBrackets <[EMAIL PROTECTED]>:
>  Is there any way to tell the CSVGenerator to use one or more contiguous 
> spaces as a seperator?  You can tell it to use a single space:
>
>      <map:match pattern="importSSV/*">
>         <map:generate type="csv" src="inputs/{1}">
>            <map:parameter name="separator" value=" "/>
>         </map:generate>
>         <map:serialize type="xml"/>
>      </map:match>
>
> But then when there are contiguous spaces separating values, it increments 
> the field number for each space that it finds, e.g. if there are 28 spaces 
> between the first field and the second field you get:
>
> <csv:record number="1">
> <csv:field number="1">G005</csv:field>
> <csv:field number="29">OR</csv:field>
> <csv:field number="30">G020</csv:field>
> <csv:field number="31">G021</csv:field>
> </csv:record>
>
>  I'd like it to increment the field number only by 1 for each set of 
> contigous spaces, so it would output the below instead:
>
> csv:record number="1">
> <csv:field number="1">G005</csv:field>
> <csv:field number="2">OR</csv:field>
> <csv:field number="3">G020</csv:field>
> <csv:field number="4">G021</csv:field>
> </csv:record>
>
>
> Thanks,
> Jeff

I don't know if there's anything in the CSVGenerator that can do this,
but how about following the generator with an XSL transformer that
renumbers the fields?  So long as you're not expecting any gaps in the
fields after the contiguous spaces are taken into account, something
like

<xsl:template match="csv:field">
<xsl:copy>
<xsl:attribute name="number"><xsl:value-of select="position()"/></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

should do the trick.


Andy.
-- 
http://answers.polldaddy.com/poll/771503/  Cross-site scripting poll

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to