Subject: Re: [xsl] Interesting issue From: Nischal Muthana <nischal_muthana@xxxxxxxxx> Date: Mon, 25 Nov 2002 12:00:51 -0800 (PST) |
Thanks a lot Joerg, This worked like a charm. Appreciate your time and help. thanks Nischal --- Joerg Heinicke <joerg.heinicke@xxxxxx> wrote: > Hello Nischal, > > this is really an extreme demand. I see only this > string: > > <data>SudhakarJalli030719751809Bigbenddrmilpitasca95035Rajeevkasarabada032719751788lowerbenddrivesanjoseca94523</data> > > Where do you know from (or where should the XSLT > processor or JavaScript > know from), where to divide the strings in > substrings? There seems to be > no delimiter and no fixed number of characters. > > In every case the logic you implemented in JS can be > implemented in XSLT > with a recursive template: > > <xsl:template match="/Customers"> > <Customers> > <xsl:call-template name="customer"> > <xsl:with-param name="data" select="data"/> > </xsl:call-template> > </Customers> > </xsl:template> > > <xsl:template name="customer"> > <xsl:param name="data" select="''"/> > <xsl:if test="string(data)"> > <Customer> > <FirstName> > <xsl:value-of select="substring($data, 1, > 15)"/> > </FirstName> > <LastName> > <xsl:value-of select="substring($data, 16, > 1)"/> > </LastName> > <Street> > <xsl:value-of select="substring($data, 17, > 1)"/> > </Street> > <City> > <xsl:value-of select="substring($data, 18, > 1)"/> > </City> > ... > and so on > ... > </Customer> > <xsl:call-template name="customer"> > <xsl:with-param name="data" > select="substring($data, 20)"/> > </xsl:call-template> > </xsl:if> > </xsl:template> > > But as I said there is no logic for the string > length. Where do you want > to get it from? > > Regards, > > Joerg > > Nischal Muthana wrote: > > Hi All > > > > I am transforming xml to xml using an xsl with > Xalan > > XSLT processor. But I am getting the resulting xml > as > > string instead of > > > > nodelist. > > > > test.xsl > > <xsl:stylesheet > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > xmlns:lxslt="http://xml.apache.org/xslt" > > > > xmlns:result="http://www.example.com/results" > > extension-element-prefixes="result" version="1.0"> > > <xsl:output method="xml"/> > > <lxslt:component prefix="result" > > functions="GetCopyBookData"> > > <lxslt:script lang="javascript"> > > function GetData(Data) > > { > > var x1 = 0; > > var x2 = 0; > > var result; > > for(var i = 1;i < 3; i++) > > { > > var s = "<Customers><FirstName>"; > > x1 = x2; > > x2 = x1 + 15; > > s = s + Data.substring(x1,x2) + "</FirstName>"; > > s = s + "<LastName>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</LastName>"; > > s = s + "<StreetNum>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</StreetNum>"; > > s = s + "<Street>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</Street>"; > > s = s + "<City>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</City>"; > > s = s + "<State>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</State>"; > > s = s + "<Zip>"; > > x1 = x2; > > x2 = x1 + 1; > > s = s + Data.substring(x1,x2) + "</Zip>"; > > result = result + s; > > } > > return result; > > } > > </lxslt:script> > > </lxslt:component> > > <xsl:template match="/"> > > <xsl:variable name="Data" select="data"/> > > <xsl:value-of select="result:GetData($Data)"/> > > </xsl:template> > > > > test.xml > > <Customers> > > > <data>SudhakarJalli030719751809Bigbenddrmilpitasca95035Rajeevkasarabada032719751788lowerbenddrivesanjoseca94523</data> > > </Customers> > > > > > > Result.xml > > > > <Customers> > > <FirstName>Sudhakar</FirstName> > > <LastName>Jalli</LastName> > > <DOB>03071975</DOB> > > <StreetNum>1809</StreetNum> > > <Street>BigBendDr</Street> > > <City>Milpitas</City> > > <State>CA</State> > > <Zip>95035</Zip> > > </Customers> > > <FirstName>Rajeev</FirstName> > > <LastName>Kasarabada</LastName> > > <DOB>03271975</DOB> > > <StreetNum>1788</StreetNum> > > <Street>lowerbenddrive</Street> > > <City>sanjose</City> > > <State>CA</State> > > <Zip>94523</Zip> > > </Customers> > > > > Thanks for your time > > Nischal > > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus ? Powerful. Affordable. Sign up now. http://mailplus.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] numbers and XPath, Joerg Heinicke | Thread | RE: [xsl] how to deal with uncertai, Jarno . Elovirta |
Re: [xsl] Oracle XSLT Processor, Deepak Rao | Date | Re: [xsl] XSLTC Is The Only XSLT Co, Jeff Kenton |
Month |