XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
W MokSubject: Transform to text using xslt
Author: W Mok
Date: 21 Jul 2006 06:45 PM
Hi All,

I need to convert a XML to text. However, I run the Java with xsl and return me a blank outfile w/o any error.
The following is the XML

<FIXML r="20030618" s="20040109" v="4.4" xr="FIA" xv="1" xmlns="http://www.fixprotocol.org/FIXML-4-4">
<Batch>
<SecDef BizDt="2006-04-24" RptID="23729" Ccy="USD"><Instrmt StrkValu="100" Mult="100" StrkMult="1" NTPosLmt="0" PosLmt="25000000" MinPxIncr="0.01" Sym="SNV" Desc="STAN" CFI="OXASPS" StrkCcy="USD" AsgnMeth="R" SettlOnOpenFlag="N"><Evnt EventTyp="5" Dt="1997-04-01"/><Pty ID="XCBO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPHO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPSE" R="22"><Sub ID="2004-07-08" Typ="27"/></Pty><Pty ID="OCC" R="21"/></Instrmt><Undly Sym="SNV" ID="87161C105" Src="1" Qty="100" SettlStat="1" AllocPct="100" CFI="EXXXXX" SettlTyp="4" SetMeth="CCC"></Undly></SecDef>
</Batch>
</FIXML>

My XSL is

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="http://www.fixprotocol.org/FIXML-4-4">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>

<xsl:template match="/a:FIXML/a:Batch/SecDef">
<xsl:apply-templates select="Instrmt"/>
<xsl:apply-templates select="Undly"/>
</xsl:template>
<xsl:template match="Instrmt">
<xsl:value-of select="@NTPosLmt"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@PosLmt"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@Sym"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@Desc"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@CFI"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@StrkCcy"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@SettlOnOpenFlag"/>
<xsl:text>|</xsl:text>

<xsl:apply-templates select="Pty"/>

<xsl:template match="Pty">
<xsl:for-each select="Pty">
<xsl:value-of select="@ID"/>
<xsl:text>|</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:template>
<xsl:template match="Undly">
<xsl:for-each select="Undly">
<xsl:value-of select="@Sym"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@Qty"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="@AllocPct"/>
<xsl:text>|</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Please advise
Thanks
Wai

Postnext
Ivan PedruzziSubject: Transform to text using xslt
Author: Ivan Pedruzzi
Date: 21 Jul 2006 09:12 PM

Wai,

Have a look to the attached solution

Ivan Pedruzzi
Stylus Studio Team


Documentfixxml.xsl

Postnext
W MokSubject: Transform to text using xslt
Author: W Mok
Date: 24 Jul 2006 09:44 AM
Ivan;

Thanks a lot. It work but when I have mulitple XML records. The string will keep on concat without a line break for each records. For example,

<FIXML r="20030618" s="20040109" v="4.4" xr="FIA" xv="1" xmlns="http://www.fixprotocol.org/FIXML-4-4">
<Batch>
<SecDef BizDt="2006-04-24" RptID="23729" Ccy="USD"><Instrmt StrkValu="100" Mult="100" StrkMult="1" NTPosLmt="0" PosLmt="25000000" MinPxIncr="0.01" Sym="SNV" Desc="STAN" CFI="OXASPS" StrkCcy="USD" AsgnMeth="R" SettlOnOpenFlag="N"><Evnt EventTyp="5" Dt="1997-04-01"/><Pty ID="XCBO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPHO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPSE" R="22"><Sub ID="2004-07-08" Typ="27"/></Pty><Pty ID="OCC" R="21"/></Instrmt><Undly Sym="SNV" ID="87161C105" Src="1" Qty="100" SettlStat="1" AllocPct="100" CFI="EXXXXX" SettlTyp="4" SetMeth="CCC"></Undly></SecDef>
<SecDef BizDt="2006-04-24" RptID="23729" Ccy="USD"><Instrmt StrkValu="100" Mult="100" StrkMult="1" NTPosLmt="0" PosLmt="25000000" MinPxIncr="0.01" Sym="SNV" Desc="STAN" CFI="OXASPS" StrkCcy="USD" AsgnMeth="R" SettlOnOpenFlag="N"><Evnt EventTyp="5" Dt="1997-04-01"/><Pty ID="XCBO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPHO" R="22"><Sub ID="1997-04-01" Typ="27"/></Pty><Pty ID="XPSE" R="22"><Sub ID="2004-07-08" Typ="27"/></Pty><Pty ID="OCC" R="21"/></Instrmt><Undly Sym="SNV" ID="87161C105" Src="1" Qty="100" SettlStat="1" AllocPct="100" CFI="EXXXXX" SettlTyp="4" SetMeth="CCC"></Undly></SecDef>

</Batch>
</FIXML>


If I have 2 SecDef XML String, it will keep on concat without a line break. I wonder how can I insert a line-break.
Please advise
Thanks
Wai

Postnext
Ivan PedruzziSubject: Transform to text using xslt
Author: Ivan Pedruzzi
Date: 24 Jul 2006 10:15 AM

Add the following just before the end of the template

<xsl:text>&#10;</xsl:text>


Ivan Pedruzzi
Stylus Studio Team

Posttop
W MokSubject: Transform to text using xslt
Author: W Mok
Date: 26 Jul 2006 10:11 AM
Ivan,

It works. Thanks a lot

Wai

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.