xsl-list
[Top] [All Lists]

RE: RE: how to differentiate between same nodes with diferent structure

2005-07-22 03:39:37
Yes! That's the solution! :D
Thanks!

Ana

-----Mensaje original-----
De: Angel Gavin [mailto:agavin(_at_)gmv(_dot_)es] 
Enviado el: viernes, 22 de julio de 2005 11:47
Para: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Asunto: RE: [xsl] how to differentiate between same nodes with diferent
structure

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(_at_)telecable(_dot_)es]
Sent: 22 July 2005 11:35
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



______________________
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.
______________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>