Subject: RE: [xsl] how to differentiate between same nodes with diferent structure From: "Angel Gavin" <agavin@xxxxxx> Date: Fri, 22 Jul 2005 11:47:25 +0200 |
Hi Ana, Just use <xsl:apply-templates/> whereever you want to apply the transformation and define two additional templates (to cover both situations) as follows: <xsl:template match="Metric/Values/Value"> <!-- Template body for case 1 here --> </xsl:template> <xsl:template match="Metric/Value"> <!-- Template body for case 2 here --> </xsl:template> The XSLT transformer will apply the right template. I hope this helps, Saludos / Regards, Angel > -----Original Message----- > From: Ana Yndurain [mailto:yndu@xxxxxxxxxxxx] > Sent: 22 July 2005 11:35 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] how to differentiate between same nodes with diferent > structure > > > Hi! > > In the same XML I have nodes of two different kinds: > > 1) The structure is Metric/Values/Value > > <Metric id = "NSM" description ="Number of Static Methods"> > <Values per = "type" total = "20" avg = "0,278" stddev = "0,961" > max = "7"> > <Value name="aa" source ="a.java" package ="es.m.p.bu.dao" value ="0"/> > <Value name="bb" source ="b.java" package ="es.m.p.ma.psp" value ="0"/> > <Value name="cc" source ="c.java" package ="es.m.p.ma.tr" value ="0"/> > <Value name="dd" source ="d.java" package ="es.m.p.ma.tr" value ="0"/> > </Values> > </Metric> > > 2) The structure is Metric/Value > <Metric id = "TLOC" description ="Total Lines of Code" max ="-1"> > <Value value="5039"/> > </Metric> > > And I want to do different things with them (in case one I want to show a > list, and in case two only the value). > I try to use a > <xsl:choose> > <xsl:when test="">show my list</xsl:when> > <xsl:otherwise>show de value</xsl:otherwise> > </xsl:choose> > > Statement, but I don't know how can I test if my node is of kind > one or two. > I've read that you can test if a group of nodes is empty, but I don't know > how. > Consider that I'm using the namespace m to accede to the nodes > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:m="http://metrics.sourceforge.net/2003/Metrics-First-Flat"> > > > Thanks a lot! > Ana > ______________________ Este mensaje, y en su caso, cualquier fichero anexo al mismo, puede contener informacion clasificada por su emisor como confidencial en el marco de su Sistema de Gestion de Seguridad de la Informacion siendo para uso exclusivo del destinatario, quedando prohibida su divulgacion copia o distribucion a terceros sin la autorizacion expresa del remitente. Si Vd. ha recibido este mensaje erroneamente, se ruega lo notifique al remitente y proceda a su borrado. Gracias por su colaboracion. ______________________ This message including any attachments may contain confidential information, according to our Information Security Management System, and intended solely for a specific individual to whom they are addressed. Any unauthorised copy, disclosure or distribution of this message is strictly forbidden. If you have received this transmission in error, please notify the sender immediately and delete it. ______________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] how to differentiate between , Ana Yndurain | Thread | RE: RE: [xsl] how to differentiate , Ana Yndurain |
[xsl] how to differentiate between , Ana Yndurain | Date | Re: [xsl] how don't show the conten, George Cristian Bina |
Month |