Class CsvRepresentationGenerator

java.lang.Object
com.saxonica.functions.qt4.csv.CsvRepresentationGenerator
Direct Known Subclasses:
CsvRecordGenerator, CsvXmlGenerator

public abstract class CsvRepresentationGenerator extends Object
  • Field Details

    • options

      protected final Map<String,GroundedValue> options
    • extractHeaderRow

      protected boolean extractHeaderRow
    • trimRows

      protected final boolean trimRows
    • explicitColumnNames

      protected GroundedValue explicitColumnNames
    • rowAdjuster

      protected ItemMapper.Lambda rowAdjuster
  • Constructor Details

  • Method Details

    • makeRowTrimmer

      protected ItemMapper.Lambda makeRowTrimmer(int width)
      Make a mapping function that adjusts an array item representing one CSV row by truncating excess fields or adding empty fields as required
      Parameters:
      width - the required number of fields in each row
      Returns:
      a mapping function that can be used to adjust the rows as required
    • fromRowSequence

      public abstract Item fromRowSequence(SequenceIterator rows) throws XPathException
      Generate the item to be delivered as the function result, given the sequence of rows returned by the CSV parser
      Parameters:
      rows - the rows returned by the CSV parser, as a sequence of XDM arrays of XDM strings
      Returns:
      the data as appropriate to each subclass
      Throws:
      XPathException - if anything goes wrong
    • generateColumnNames

      protected List<StringValue> generateColumnNames(ArrayItem firstRow)
      Extract the list of column names from an array item holding the contents of the first row, selecting and reordering the names if required
      Parameters:
      firstRow - the first row of the data, containing column names
      Returns:
      a list of column names in the order that the columns appear in the output