Donate Share

ServingXML

Subscribe

How to obtain the last field of record(line)

You are viewing a single message from this topic. View all messages.

  1. 2009-11-10 06:07:50 UTC

    You can't read fields right to left, but you can read the entire line as a single field, and use the XSLT fn:ends-with function to test the end of the line. So, add the prefix declaration

    xmlns:fn="http://www.w3.org/2005/xpath-functions"

    in the sx:resources element, and use something like

      <sx:flatRecordTypeChoice>
        <sx:delimitedField name="line"/>
        <sx:when test="fn:ends-with(line,'Cap')">
          <sx:flatRecordType name='Cap'>
            <sx:fieldDelimiter value="|"/>
            <sx:delimitedField name="tradeId"/>
            <sx:delimitedField name="placeholder1"/>
            <sx:delimitedField name="currency"/>
            <sx:delimitedField name="buySell"/>
            <sx:delimitedField name="maturityDate"/>
            <sx:delimitedField name="strike"/>
            <sx:delimitedField name="recordType"/>
          </sx:flatRecordType>
        </sx:when>
        <sx:when test="fn:ends-with(line,'SWAP')">
          <sx:flatRecordType name='SwapFloatingLeg'>
            <sx:fieldDelimiter value="|"/>
            <sx:delimitedField name="tradeId"/>
            <sx:delimitedField name="style"/>
            <sx:delimitedField name="side"/>
            <sx:delimitedField name="currency"/>
            <sx:delimitedField name="index"/>
            <sx:delimitedField name="maturityDate"/>
            <sx:delimitedField name="notional"/>
            <sx:delimitedField name="recordType"/>
          </sx:flatRecordType>
        </sx:when>
      </sx:flatRecordTypeChoice>
    

    Note that the default field delimiter is the record delimiter, so the delimiter for the field "line" is the record delimiter, as no other is specified at that level.

    -- Daniel

< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.