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
Wai MokSubject: transfer xml into xslt
Author: Wai Mok
Date: 12 May 2006 04:53 PM
Originally Posted: 12 May 2006 04:39 PM
I have an input xml with different tags. I would like to select the tag I wanted and parse to the text output file.

Here is the input xml files
<FIXML xmlns="http://www.fixprotocol.org/FIXML-4-4" r="20030618" s="20040109" v="4.4" xr="FIA" xv="1">
<Batch>
<SecListUpd BizDt="2006-04-24" RptID="8705349" UpdActn="M">
<Pty ID="XASE" R="22">
<Sub ID="2001-06-20" Typ="27"></Sub>
</Pty>
</SecListUpd>

<SecDefUpd BizDt="2006-04-24" Ccy="USD" RptID="8026163" UpdActn="M">
<Pty ID="XASE" R="22">
<Sub ID="2001-06-20" Typ="27"></Sub>
</Pty>
</SecDefUpd>

<SecDef BizDt="2006-04-24" Ccy="USD" RptID="23743">
<Pty ID="XASE" R="22">
<Sub ID="2001-06-20" Typ="27"></Sub>
</Pty>
</SecDef>

<SecList BizDt="2006-04-24" RptID="8469055">
<Instrmt CFI="OCECPN" ID="EQ" MMY="200605" MatDt="2006-05-12" Src="J" StrkPx="1480" StrkQt="1480.00" Sym="CBP">
<Evnt Dt="2006-02-11" EventTyp="5"></Evnt>
</Instrmt>
</SecList>

</Batch>
</FIXML>

If I only want to parse the tag = SecDefUpd or SecDef, I wonder what I need to change with my xslt.

The following is my xslt:


<?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:template match="/">
<xsl:apply-templates select="a:FIXML/a:Batch/child::*"/>
</xsl:template>

<xsl:template match="*">
<xsl:for-each select="descendant-or-self::*">
<xsl:for-each select="attribute::*">
<xsl:value-of select="."/>
<xsl:text>|</xsl:text>
</xsl:for-each>
</xsl:for-each><xsl:text>
</xsl:text> </xsl:template>
</xsl:stylesheet>

Thanks
Wai

Postnext
Minollo I.Subject: transfer xml into xslt
Author: Minollo I.
Date: 12 May 2006 05:31 PM
I guess you can just change...

<xsl:apply-templates select="a:FIXML/a:Batch/child::*"/>

...into...

<xsl:apply-templates select="a:FIXML/a:Batch/*[local-name()='SecDefUpd' or local-name()='SecDef']"/>

?

Posttop
Wai MokSubject: transfer xml into xslt
Author: Wai Mok
Date: 15 May 2006 09:53 AM
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.