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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Duplicate Ouput on Repeating E... (2)
-> + How to canculate grand total. (3)
-> + Displaying two xml files toget... (2)
-> + Replace xml attribs vals with ... (2)
-> + check mark - font problem? (5)
-> + Xml to XML with XSLT (Remove) (10)
-> + Problem viewing xml as html wi... (4)
-> + Need to create lunk through XM... (2)
-> - Pagination with xslt (1)
-> - Transform to text using xslt (5)
-> ->Transform to text using x...
-> ->Transform to text using x...
-> ->Transform to text using x...
-> ->Transform to text using x...
-> + Rotating text using XSL FO (2)
-> + XSL -- Trim blanks from a vari... (3)
-> + dynamic matching (4)
-> + XSL:key for each condition - p... (5)
-> + XSL does not sort (5)
-> + CAN i CREATE INTERMEDIATE XML ... (2)
-> + Xml to html conversion (3)
-> + Using Xpath against Variables ... (9)
-> + XML-22004: (Fatal Error) Error... (10)
-> + Current page number (3)
-- Previous [1381-1400] [1401-1420] [1421-1440] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.