Subject: RE: [xsl] Data Integration at runtime using XSL From: <Ambika.Das@xxxxxxxxxxxxxxxxxx> Date: Tue, 19 Sep 2006 15:10:55 +0530 |
Hi David, Just to add one more point. The given solution is not working for XSLTC. The class files are not getting generated. So we are looking for a like a different approach. Thanks & Regards, Ambika Prasad Das -----Original Message----- From: Ambika Das-IC Sent: Tuesday, September 19, 2006 2:38 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Data Integration at runtime using XSL Hi David, I want the output in CSV format. The final output is as follows. XML used is: <?xml version="1.0" encoding="UTF-8" ?> <myelem> <childelem> <elemid id='NAME'>ABC</elemid> <elemid id='AGE'>20</elemid> </childelem> <childelem> <elemid id='NAME'>DEF</elemid> <elemid id='AGE'>23</elemid> </childelem> <childelem> <elemid id='NAME'>GHI</elemid> <elemid id='AGE'>15</elemid> </childelem> </myelem> XSL Used is: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:variable name="varEmpId">1020|2001|3010</xsl:variable> <xsl:template match="/"> <xsl:text>Emp Id,Name,Age </xsl:text> <xsl:for-each select="myelem/childelem"> <xsl:variable name="varString"> <xsl:choose> <xsl:when test="position()='1'"> <xsl:value-of select="$varEmpId"/> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="contains($varString, '|')"> <xsl:value-of select="substring-after($varString, '|')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$varString"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="varIndEmpId"> <xsl:choose> <xsl:when test="contains($varString, '|')"> <xsl:value-of select="substring-before($varString, '|')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$varString"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="$varIndEmpId"/> <xsl:text>,</xsl:text> <xsl:value-of select="elemid[@id='NAME']"/> <xsl:text>,</xsl:text> <xsl:value-of select="elemid[@id='AGE']"/> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet> Output Required is: Emp Id,Name,Age 1020,ABC,20 2001,DEF,23 3010,GHI,15 Thanks & Regards, Ambika Prasad Das -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Thursday, September 07, 2006 6:13 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Data Integration at runtime using XSL Or, in XSLT2: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:variable name="str" select="'abc|def'"/> <xsl:variable name="seq" select="tokenize($str,'\|')"/> <xsl:template match="x"> <x> <xsl:apply-templates select="main-element"/> </x> </xsl:template> <xsl:template match="main-element"> <xsl:variable name="p" select="position()"/> <header> <xsl:value-of select="$seq[min(($p,last()))]"/> </header> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> $ saxon8 sigh.xml sigh2.xsl <?xml version="1.0" encoding="UTF-8"?> <x> <header>abc</header> <main-element> <fid id="DATA_STATUS">0</fid> </main-element> <header>def</header> <main-element> <fid id="DATA_STATUS">1</fid> </main-element> <header>def</header> <main-element> <fid id="DATA_STATUS">2</fid> </main-element> </x> DISCLAIMER: This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted,corrupted,lost,destroyed,arrive late or incomplete or contain viruses.The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Data Integration at runti, Abel Braaksma | Thread | Re: [xsl] Data Integration at runti, David Carlisle |
Re: [xsl] Data Integration at runti, Abel Braaksma | Date | Re: [xsl] Data Integration at runti, David Carlisle |
Month |