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)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] 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.