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
Swetank ChandraSubject: XSLT Mapping - Issue
Author: Swetank Chandra
Date: 26 Jun 2009 01:34 AM
Source File
____________________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ED_MT xmlns:ns0="http://test.com">
<Rows>
<SEGNAM>T1</SEGNAM>
<SDATA>field1||field2||field3||field4||field5</SDATA>
</Rows>
<Rows>
<SEGNAM>T2</SEGNAM>
<SDATA>field1||field2||field3||field4||field5</SDATA>
</Rows>
<Rows>
<SEGNAM>T3</SEGNAM>
<SDATA>field1||field2||field3||field4||field5</SDATA>
</Rows>
</ns0:ED_MT>
_______________________________________________________________

OutPut file Desired
The Mapping should filter that only SEGNAM T1 & T3 needs to be mapped, further only field1 and field5 for T1 SEGNAM and field3 for T3 Segnam
Thus the output should only be as below. Thus the Split has to be done based on the sequence of the field which will vary for different SEGNAM
SEGNAM T1 --> Sequence (1,3) thus the mapping should read First Field(field1) and then the find the second occurence of Pipe and read the third field and concat into Target Structure Rows field as below.

Would appreciate if anyone can provide the XSLT snippet for the same

_______________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<ns0:ProdOrder_MT xmlns:ns0="http://test.com">
<Record>
<Recordset>
<Rows>field1||field5</Rows>
</Recordset>
<Recordset>
<Rows>field3</Rows></Recordset>
</ns0:ProdOrder_MT>
_______________________________________________________

Regards
Swetank

Postnext
(Deleted User) Subject: XSLT Mapping - Issue
Author: (Deleted User)
Date: 26 Jun 2009 06:40 AM
Hi Swetank,
which version of Stylus Studio are you suing, and which XSLT processor have you selected in the Scenario Dialog?

Thanks,
Alberto

Postnext
Swetank ChandraSubject: XSLT Mapping - Issue
Author: Swetank Chandra
Date: 28 Jun 2009 08:43 PM
Hi Alberto
I am using Stylus Studio 2009 Enterprise Suite and Saxon processor.

Kindly sugest how to solve the issue.

Best Regards
Swetank

Posttop
(Deleted User) Subject: XSLT Mapping - Issue
Author: (Deleted User)
Date: 29 Jun 2009 09:45 AM
Hi Swetank,
as you are using Saxon, you can use a few functionalities offered by XSLT 2.0, like in this example:

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="my_funcs" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:function name="my:extract" as="xs:string*">
<xsl:param name="str"/>
<xsl:param name="items" as="xs:integer*"/>

<xsl:variable name="list" select="tokenize($str,'\|\|')"/>
<xsl:for-each select="$items">
<xsl:value-of select="$list[current()]"/>
</xsl:for-each>
</xsl:function>

<xsl:template match="/">
<ns0:ProdOrder_MT xmlns:ns0="http://test.com">
<Record>
<xsl:for-each select="//Rows">
<xsl:choose>
<xsl:when test="SEGNAM='T1'">
<Recordset>
<Rows><xsl:value-of select="string-join(my:extract(SDATA, (1,3)),'||')"/></Rows>
</Recordset>
</xsl:when>
<xsl:when test="SEGNAM='T3'">
<Recordset>
<Rows><xsl:value-of select="string-join(my:extract(SDATA, (3)),'||')"/></Rows>
</Recordset>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</Record>
</ns0:ProdOrder_MT>
</xsl:template>

</xsl:stylesheet>

Hope this helps,
Alberto

 
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.