Transforming FixML using XSLT to a text file -strange output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CAM123
    New Member
    • Feb 2008
    • 1

    Transforming FixML using XSLT to a text file -strange output

    I have added:

    <br><xsl:valu e-of select="Line" /></br>

    to my XSLT stylesheet to get a line per repeating block. When I view the output as XML it looks perfect - one line per block. However when I output the file to a text file, all the data is wrapping and at the end of each block I am getting the text part of the header included but not all of it. The text that appears is:

    <br xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:user="urn :additional-functions" />

    I have tried different variations of the <br> command above, but the text above keeps coming out.

    So for example, I have three repeating blocks and each is ending with pipe, but the output comes out as follows
    200809021005554 |NEWM|BROKER|FU ND52|09022008|2 0080213|S|BRL|1 000000|AUD|1564 891|1.564891|
    <br xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:user="urn :additional-functions" />20080902100555 4|NEWM|BROKER|F UND54|09022008| 20080213|S|BRL| 2000000|AUD|312 9782|1.564891|
    <br xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:user="urn :additional-functions" />


    the full XSLT is as follows. Apolgies in advance if it is really messy, I'm not a programmer (and at this rate probably never will be!). Thank you in advance for your help.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" xmlns:msxsl="ur n:schemas-microsoft-com:xslt" xmlns:user="urn :additional-functions" xmlns:a="http://www.fixprotocol .org/FIXML-4-4" exclude-result-prefixes="a">
    <xsl:output method="text" omit-xml-declaration="ye s" indent="yes"/>
    <xsl:variable name="tradecoun t">0</xsl:variable>

    <xsl:template match="/">
    <xsl:apply-templates select="/a:FIXML/a:AllocInstrctn " />
    </xsl:template>

    <xsl:template match="/a:FIXML/a:AllocInstrctn ">


    <xsl:for-each select="a:Alloc ">


    <!--unique reference made up of trade date and trade id-->
    <xsl:value-of select="concat( substring(/a:FIXML/a:AllocInstrctn/@TrdDt,1,4),sub string(/a:FIXML/a:AllocInstrctn/@TrdDt,9,2),sub string(/a:FIXML/a:AllocInstrctn/@TrdDt,6,2))"/>
    <xsl:value-of select = "/a:FIXML/a:AllocInstrctn/@ID2"/><!--new or cancel-->|NEWM|<xsl:val ue-of select="/a:FIXML/a:AllocInstrctn/a:Pty[@Src='B' and @R=1]/@ID"/>|<xsl:value-of select = "@Acct"/>|<xsl:value-of select="concat( substring(/a:FIXML/a:AllocInstrctn/@TrdDt,9,2),sub string(/a:FIXML/a:AllocInstrctn/@TrdDt,6,2),sub string(/a:FIXML/a:AllocInstrctn/@TrdDt,1,4))"/>|<xsl:choose >
    <xsl:when test="@LinkTyp= 1 and a:Instrmt/@ID='FORWARD'">
    <xsl:value-of select="concat( substring(/a:FIXML/a:AllocInstrctn/@SettlDt2,1,4), substring(/a:FIXML/a:AllocInstrctn/@SettlDt2,6,2), substring(/a:FIXML/a:AllocInstrctn/@SettlDt2,9,2)) "/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="concat( substring(/a:FIXML/a:AllocInstrctn/@SettlDt,1,4),s ubstring(/a:FIXML/a:AllocInstrctn/@SettlDt,6,2),s ubstring(/a:FIXML/a:AllocInstrctn/@SettlDt,9,2))"/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="@Side=1">
    <xsl:text>B</xsl:text>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:text>S</xsl:text>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="@Ccy=subs tring(/a:FIXML/a:Instrmt/@Sym,1,3 and @Side=1)">
    <xsl:value-of select="substri ng(/a:FIXML/a:AllocInstrctn/a:Instrmt/@Sym,5,3)"/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="substri ng(/a:FIXML/a:AllocInstrctn/a:Instrmt/@Sym,1,3)"/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="@Ccy='JPY '">
    <xsl:value-of select="format-number(number(@ Qty),'####')"/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="format-number(number(@ Qty),'####.##') "/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="@Ccy=subs tring(/a:FIXML/a:AllocInstrctn/a:Instrmt/@Sym,1,3 and @Side=1)">
    <xsl:value-of select="substri ng(/a:FIXML/a:AllocInstrctn/a:Instrmt/@Sym,1,3)"/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="substri ng(/a:FIXML/a:AllocInstrctn/a:Instrmt/@Sym,5,3)"/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="substring (a:Instrmt/@Sym,5,3)='JPY' ">
    <xsl:value-of select="format-number(number(@ NetMny),'####') "/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="format-number(number(@ NetMny),'####.# #')"/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:choose>
    <xsl:when test="@LinkTyp= 1 and a:Instrmt/@ID='FORWARD'">
    <xsl:value-of select = "/a:FIXML/a:AllocInstrctn/@AvgPx2"/>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select = "/a:FIXML/a:AllocInstrctn/@AvgPx"/>
    </xsl:otherwise>
    </xsl:choose>|<xs l:value-of select="a:Stip[@Typ='TEXT']/@Val"/>
    <xsl:value-of select="a:Pty[@Src='D' and @R=11]/@ID"/>

    <xsl:text> </xsl:text>

    <br/><xsl:value-of select="Line" /></br>
    </xsl:for-each>


    </xsl:template>
    </xsl:stylesheet>
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Change the exclude-result-prefixes attribute to exclude these namespaces.
    exclude-result-prefixes="a msxsl user"

    Comment

    Working...