Subject: Re: [xsl] Outputting from more than one source - The Mistery Solved From: "Gustavo Moreira" <moreirag@xxxxxxxxxx> Date: Sun, 23 Feb 2003 22:20:37 -0300 |
Folks, The problem is solved. I put Americo's code in my processor. And it worked. So I adapted his code to work with my real clients. And it didn't worked. Would it be the number or regs? - I thought. Then - please don't laught at me - I started to debug, trying with less regs, it still didn't work. Then - rembember, don't laugh! - I put all the tags identical, and it still didn't work. And the more I checked all the details the more I was convinced that it had to be something really stupid. So I noticed - laughing can be bad to you! - there was a F****** WHITE SPACE (FWS) in front of all the values of elements from clientes_ora.xml. Just like this example: <registro> <nome> BANCO CIDADE S/A.</nome> <endereco> AV. SETE DE SETEMBRO, 1021</endereco> <cidade> PORTO ALEGRE</cidade> </registro> This way it always brought first the clients from clientes_ora.xml. I'll check my Java code to see why this FWS doesn't appear in the records generated by SQLServer. I warned - but I imagine all of you laughing at me now... Or as we say in Brazil, "tirando um sarro da minha cara" Thanks for all the help, Gustavo Moreira mailto:gustavo@xxxxxxxxxx "And in the end the love you take is equal to the love you make" (Lennon-McCartney) ----- Original Message ----- From: "Américo Albuquerque" <aalbuquerque@xxxxxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, October 14, 2002 11:19 AM Subject: RE: [xsl] Outputting from more than one source > Hi Gustavo. > In your example you use <xsl:sort select="nome"/> but in your xml you > use <name>...</name> > You'll have to check if this is a typo or if it is as you have in your > code. Like this, the <reg> are not sorted because your source doesn't > have a child named 'nome'. > > I've tried your example with this stylesheet and it worked as it should > (I'm using MSXML3). > Hope that this helps you. > > <xsl:template match="/"> > <table> > <tr> > <td>Name | Adress | City</td> > </tr> > <xsl:apply-templates select="clients_ora/reg | > document('input2.xml')/clients_sqlsrv/reg"> > <xsl:sort select="name"/> > </xsl:apply-templates> > </table> > </xsl:template> > > <xsl:template match="reg"> > <tr> > <td><xsl:value-of select="name"/> | <xsl:value-of select="adress"/> | > <xsl:value-of select="city"/></td> > </tr> > </xsl:template> > > This is what I got: > Name | Adress | City > A Cicrano Almeida | 852 Monkey Street | Itajai > A Fulano de Tal | 1254 Adams Street | Porto Alegre > B Cicrano Almeida | 852 Monkey Street | Itajai > B Fulano de Tal | 1254 Adams Street | Porto Alegre > C Cicrano Almeida | 852 Monkey Street | Itajai > C Fulano de Tal | 1254 Adams Street | Porto Alegre > D Cicrano Almeida | 852 Monkey Street | Itajai > D Fulano de Tal | 1254 Adams Street | Porto Alegre > > The XMLs are: > input.xml: > <?xml version="1.0" encoding="ISO-8859-1" ?> > > <clients_ora> > <reg> > <name>A Fulano de Tal</name> > <adress>1254 Adams Street</adress> > <city>Porto Alegre</city> > </reg> > <reg> > <name>B Fulano de Tal</name> > <adress>1254 Adams Street</adress> > <city>Porto Alegre</city> > </reg> > <reg> > <name>C Fulano de Tal</name> > <adress>1254 Adams Street</adress> > <city>Porto Alegre</city> > </reg> > <reg> > <name>D Fulano de Tal</name> > <adress>1254 Adams Street</adress> > <city>Porto Alegre</city> > </reg> > </clients_ora> > > input2.xml: > <?xml version="1.0" encoding="ISO-8859-1" ?> > > <clients_sqlsrv> > <reg> > <name>A Cicrano Almeida</name> > <adress>852 Monkey Street</adress> > <city>Itajai</city> > </reg> > <reg> > <name>B Cicrano Almeida</name> > <adress>852 Monkey Street</adress> > <city>Itajai</city> > </reg> > <reg> > <name>C Cicrano Almeida</name> > <adress>852 Monkey Street</adress> > <city>Itajai</city> > </reg> > <reg> > <name>D Cicrano Almeida</name> > <adress>852 Monkey Street</adress> > <city>Itajai</city> > </reg> > </clients_sqlsrv> > > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Gustavo > Moreira > Sent: Monday, October 14, 2002 4:05 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] Outputting from more than one source > > > > I don't understand that both processors should have this bug. > Now they are three: Saxon also brought the same result. > I guess it is not a bug: it simply does not join the documents before > sorting. But I'm surprised with the fact that it is not possible. > > I'm starting to think about changing my Java code, as Liao suggested. > Anyway I'll still be searching for a solution for this. So, if you guys > have some another idea, please contact me. > > I put the last code I tried below, in case someone wants to give a last > shot. (Comments and omissions are between ...[ ]...) > > Thanks for all your help, > Gustavo Moreira > > --clientes.xsl----------------------------------- > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:template match="/"> > <xsl:apply-templates > select="document('clientes_ora.xml')/clientes_ora/registro | > > document('clientes_sqlsrv.xml')/clientes_sqlsrv/registro"> > <xsl:sort select="nome"/> > </xsl:apply-templates> > </xsl:template> > > <xsl:template match="*"> > <b><xsl:number value="position()"/>- > <xsl:value-of select="nome"/></b><br/> > <xsl:value-of select="endereco"/>- > <xsl:value-of select="cidade"/><br/><br/> > </xsl:template> > > </xsl:stylesheet> > > --Results: ------------------------------- > > 1- 3P CONSTRUÇÕES E INCORPORAÇÕES LTDA. > RUA DOMINGOS DE ALMEIDA, 3670 - 6 ANDAR- URUGUAIANA > > 2- 3R INFORMÁTICA LTDA > AV. PROTÁSIO ALVES, 3240 - LOJA 07 E 08- PORTO ALEGRE > > 3- A & L REPRESENTAÇÕES E SERVIÇOS LTDA. > RUA EVARISTO DA VEIGA, 151- PORTO ALEGRE > > 4- A ADVENTUS ELETRICISTAS LTDA > TRAVESSA SERAFIM TERRA, 207- PORTO ALEGRE > > 5- A FURNINHA HOTEIS E TURISMO LTDA > RUA JOAQUIM PORTO, 281- TORRES > > ... [plus 3911 clients - the next two are the last from > clientes_ora.xml]... ... [note that in 3919 it starts to bring the > records from clientes_sqlsrv.xml]... > > 3917- ZONTA UNIFORMES E PECAS LTDA > RUA PALMEIRINHAS, 330- CRICIÚMA > > 3918- ZORTEA CONSTRUCOES LTDA > RUA CEL. FARRAPOS, 1141 - Tlx 492479- CAMPOS NOVOS > > 3919 - A.ARAUJO ENGENHARIA E MONTAGENS > RUA MARIA URUTAITI, 441- ESTADO DE SÃO PAULO > > 3920 - A.C.DA CUNHA CONSTR.E INCORP.LTDA > RUA DOMINGOS DE ALMEIDA, 1541- URUGUAIANA > > 3921 - A.J. SILVA E CERCATO LTDA > AV. SALVADOR LEAO, 402- PORTO ALEGRE > > ...[plus the rest of the clients from clientes_sqlsrv.xml]... > > --------------------------------------------------------------------- > > > ----- Original Message ----- > From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > Sent: Sunday, October 13, 2002 5:51 PM > Subject: Re: [xsl] Outputting from more than one source > > > > I didn't really expect it to work, it was only a possibility. > > Sometimes ago MSXML had a bug with Result Tree Fragments: stored in a > > variable they became node sets. There was the possibility that the > > same works here. > > > > I don't understand that both processors should have this bug. But > > client processing is more or less unreliable - what if the client has > > no XML / XSLT browser? Is server processing possible? Or at least try > > your code with another processor like Saxon or Xalan. > > > > Regards, > > > > Joerg > > > > Gustavo Moreira wrote: > > > Joerg: It brings the same, even with this variable. > > > I'm using MSXML 4.0 (IE6) and Mozilla. > > > In both the result is the same. > > > Do you have another suggestion? > > > > > > Liao: I could change the Java code to produce only one document. But > > > > I don't want to change the specification of my project. Just for the > > > > record, this project is a parcial requisite for my > graduation. > > > Let's say I'll change my Jave code as a last option. > > > > > > > > > ----- Original Message ----- > > > From: "Joerg Heinicke" <joerg.heinicke@xxxxxx> > > > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > > > Sent: Sunday, October 13, 2002 7:39 AM > > > Subject: Re: [xsl] Outputting from more than one source > > > > > > > > > > > >>Hmm, it should work - at least it looks ok. What processor are you > > >>using? What happens if you do it in the following way: > > >> > > >><xsl:variable name="reg" select="/clients_ora/reg | > > >> document('other.xml')/clients_sqlsrv/reg | > > >> document('another.xml')/clients_db2/reg"/> > > >> > > >><xsl:apply-templates select="$reg"> > > >> <xsl:sort select="name"/> > > >></xsl:apply-templates> > > >> > > >>Regards, > > >> > > >>Joerg > > >> > > >>Gustavo Moreira wrote: > > >> > > >>>Yes, but what if there are three or more documents? > > >>> > > >>>This, for instance, would this work?: > > >>> > > >>>xsl:apply-templates select="/clients_ora/reg | > > >>> document('other.xml')/clients_sqlsrv/reg | > > >>> document('another.xml')/clients_db2/reg"> > > >>> <xsl:sort select="name"/> > > >>> </xsl:apply-templates> > > >>> > > >>>I am using this: > > >>> > > >>> <xsl:apply-templates > > >>> select="document('clients_sqlsrv.xml')//clients_sqlsrv/reg > | > > >>> document('clients_ora.xml')//clients_ora/reg"> > > >>> <xsl:sort select="name"/> > > >>> </xsl:apply-templates> > > >>> > > >>>...and it doesn't work because it brings first all the clients from > > > >>>the > > >> > > > 1st > > > > > >>>file (ordered), then it follows with all the clients from the 2nd > > >>>file (ordered). What I want is all clients from all files ordered, > > >>>no matter what file > > >> > > > they > > > > > >>>come from. > > >>> > > >>> > > >>>Gustavo Moreira > > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Outputting from more than, Américo Albuquerque | Thread | Re: [xsl] Outputting from more than, Mike Ferrando |
RE: [xsl] Problem With Different Co, Schwartz, Rechell R, | Date | |
Month |