|
top
|
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
|
|
|