Re: [xsl] XPATH: get not repeated nodes

Subject: Re: [xsl] XPATH: get not repeated nodes
From: "aaa bbb" <vsguiseris@xxxxxxxxxxx>
Date: Thu, 26 Feb 2004 16:31:41 +0100
<xsl:key name="x" match="VEH" use="concat(../../@cod,'+',@tap)"/>
<xsl:param name="this" select="'1CA8ADH7P5..A0'"/>

then

select="//V14[@cod=$this]/V16/VEH[generate-id()=generate-id(key('x',concat($this,'+',@tap))[1])]"

will select the VEH corresponding to each unique value of @tab that
occurs below the V14 element with teh specified @cod attribute.


Thanks, David!!!


I was thinking to fill de 'selects' only with xpath and javascript, something like this:

 function cargarASalon(xPath) {
   limpia(form1.cmbASalon);
   insertOpt(form1.cmbASalon, "Seleccione", "0");

var oASalon = oDatos.selectNodes(xPath);
for(var j=0; oASalon.length > j; j++) {
insertOpt(form1.cmbASalon, oASalon.item(j).getAttribute("as"),
oASalon.item(j).getAttribute("as"));
}
}


But now I am tried with xsl, i suppose that only with xpath maybe it will be impossible.

Well, now i have another problem.

I add a new node <PARAMS> in the xml that I can create before the transformation (I do not know how to pass params to the xsl)

	<PARAMS>
		<V14>1CA8ADH7P5..A0</V14>
		<AS>30</AS>
		<COL>0</COL>
		<TAP>0</TAP>
	</PARAMS>

I have created the next xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>


<xsl:key name="a" match="V16" use="concat(../@cod,'+',@as)"/>
<xsl:key name="c" match="VEH" use="concat(../../@cod,'+',../@as,'+',@codcol)"/>
<xsl:key name="t" match="VEH" use="concat(../../@cod,'+',@tap)"/>
<xsl:param name="v14" select="//PARAMS/V14"/>
<xsl:param name="as" select="//PARAMS/AS"/>
<xsl:param name="color" select="/PARAMS/COL"/>


<xsl:template match="/DATOS">

<select name="cmbV14">
<option value="0">Seleccione</option>
<xsl:for-each select="//V14">
<OPTION>
<xsl:if test="@cod=$v14"><xsl:attribute name="selected"/></xsl:if>
<xsl:attribute name="value"><xsl:value-of select="@cod"/></xsl:attribute>
<xsl:value-of select="@lit"/>
</OPTION>
</xsl:for-each>
</select>


<select name="cmbASalon">
<option value="0">Seleccione</option>
<xsl:for-each select="//V14[@cod=$v14]/V16[generate-id()=generate-id(key('a',concat($v14,'+',@as))[1])]">
<OPTION>
<xsl:if test="@as=$as"><xsl:attribute name="selected"/></xsl:if>
<xsl:attribute name="value"><xsl:value-of select="@as"/></xsl:attribute>
<xsl:value-of select="@as"/>
</OPTION>
</xsl:for-each>
</select>


<xsl:if test="$as='0'">
<select name="cmbCol">
<option value="0">Seleccione</option>
<xsl:for-each select="//V14[@cod=$v14]/V16/VEH[generate-id()=generate-id(key('c',concat($v14,'+',@as,'+',@codcol))[1])]">
<OPTION>
<xsl:variable name="codcolor" select="@codcol"/>
<xsl:if test="@codcol=$color"><xsl:attribute name="selected"/></xsl:if>
<xsl:attribute name="value"><xsl:value-of select="@codcol"/></xsl:attribute>
<xsl:value-of select="//COLORES/COL[@cod=$codcolor]/@lit"/>
</OPTION>
</xsl:for-each>
</select>
</xsl:if>
<xsl:if test="$as!='0'">
<select name="cmbCol">
<option value="0">Seleccione</option>
<xsl:for-each select="//V14[@cod=$v14]/V16/VEH[generate-id()=generate-id(key('c',concat($v14,'+',$as,'+',@codcol))[1])]">
<OPTION>
<xsl:variable name="codcolor" select="@codcol"/>
<xsl:if test="@codcol=$color"><xsl:attribute name="selected"/></xsl:if>
<xsl:attribute name="value"><xsl:value-of select="@codcol"/></xsl:attribute>
<xsl:value-of select="//COLORES/COL[@cod=$codcolor]/@lit"/>
</OPTION>
</xsl:for-each>
</select>
</xsl:if>


<select name="cmbTap">
<option value="0">Seleccione</option>
<xsl:for-each select="//V14[@cod=$v14]/V16/VEH[generate-id()=generate-id(key('t',concat($v14,'+',@tap))[1])]">
<OPTION>
<xsl:attribute name="value"><xsl:value-of select="@tap"/></xsl:attribute>
<xsl:value-of select="@tap"/>
</OPTION>
</xsl:for-each>
</select>


</xsl:template>

</xsl:stylesheet>


You can see the <xsl:if>..</xsl:if>, with that I try to change generte-id(key(...))


-- this to use all 'as'
<xsl:for-each select="//V14[@cod=$v14]/V16/VEH[generate-id()=generate-id(key('c',concat($v14,'+',@as,'+',@codcol))[1])]">


-- this to use only the 'as' which comes with 'params'
<xsl:for-each select="//V14[@cod=$v14]/V16/VEH[generate-id()=generate-id(key('c',concat($v14,'+',$as,'+',@codcol))[1])]">



The idea is that the comboBoxes are linked, now i'm trying with 'colores' (i have the literals), but the idea is:
v14 -> as -> color -> tap, when i select one, the others must be to change with the good values.
(well, i know it, repeat myself, i told it yesterday)


It exists some wildcard to replace part of the key? It is necesary to repeat all the code? When I'll do the same thing with 'tap' i'll have several possible options (with 'as', without 'as', with 'color', without 'color'), how could I do to don't repeat the same code? or how use a variable with the good value or a wildcard? or cut the key? ...


Thank you for everything!!!



PD: Congratulations for the baby!!!


_________________________________________________________________
Reparaciones, servicios a domicilio, empresas, profesionales... Todo en la guía telefónica de QDQ. http://qdq.msn.es/msn.cfm



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread