[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: problem for extracting information using xsl from

Subject: RE: problem for extracting information using xsl from one xml, please help me
From: "W Charlton" <XSLList@xxxxxxxxxx>
Date: Thu, 15 Nov 2007 12:54:56 -0000
RE:  problem for extracting information using xsl from
Miren,

De nada, try

 <?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:output method="html"/>
	<xsl:template match="/">
		<xsl:for-each
select="/sn_servicioproyecto/masterinformaciones/sn_masterinformacion">
			<xsl:if test="position() mod 3 = 1 or position()=1">
				<xsl:call-template name="Make3ColumnRow">
					<xsl:with-param
name="FirstItemPositionNo">
						<xsl:value-of
select="position()"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="Make3ColumnRow">
		<xsl:param name="FirstItemPositionNo"/>
		<xsl:variable name="vColumn2"
select="/sn_servicioproyecto/masterinformaciones/sn_masterinformacion[positi
on()=$FirstItemPositionNo + 1]"/>
		<xsl:variable name="vColumn3"
select="/sn_servicioproyecto/masterinformaciones/sn_masterinformacion[positi
on()=$FirstItemPositionNo + 2]"/>
		<table class="cabeceratabla" width="99%" border="2">
			<tr>
				<xsl:choose>
					<xsl:when
test="position()=$FirstItemPositionNo">
						<td width="33%">
							<img alt=""
src="/images/usuario/min_{ficherosexternos/ficheroexterno_fichero}"
border="1" width="75" hspace="2" vspace="2" align="left"/>
							<input
type="checkbox" name="titulorevista"
value="{composicioninformacion/sn_composicioninformacion[composicioninformac
ion_alias = 'titulo']/metadatosinformacion_texto}"
onclick="comprobarRevistas(this)">
								<xsl:if
test="composicioninformacion/sn_composicioninformacion[composicioninformacio
n_alias = 'estado']/metadatosinformacion_texto = 'false' ">

<xsl:attribute name="disabled">disabled</xsl:attribute>
								</xsl:if>
							</input>
							<xsl:value-of
select="composicioninformacion/sn_composicioninformacion[composicioninformac
ion_alias = 'titulo']/metadatosinformacion_texto"
disable-output-escaping="yes"/>
							<br/>
						</td>
					</xsl:when>
					<xsl:otherwise>
						<td width="33%"> </td>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="$vColumn2">
						<td width="33%">
							<img alt=""
src="/images/usuario/min_{$vColumn2/ficherosexternos/ficheroexterno_fichero}
" border="1" width="75" hspace="2" vspace="2" align="left"/>
							<input
type="checkbox" name="titulorevista"
value="{$vColumn2/composicioninformacion/sn_composicioninformacion[composici
oninformacion_alias = 'titulo']/metadatosinformacion_texto}"
onclick="comprobarRevistas(this)">
								<xsl:if
test="$vColumn2/composicioninformacion/sn_composicioninformacion[composicion
informacion_alias = 'estado']/metadatosinformacion_texto = 'false' ">

<xsl:attribute name="disabled">disabled</xsl:attribute>
								</xsl:if>
							</input>
							<xsl:value-of
select="$vColumn2/composicioninformacion/sn_composicioninformacion[composici
oninformacion_alias = 'titulo']/metadatosinformacion_texto"
disable-output-escaping="yes"/>
							<br/>
						</td>
					</xsl:when>
					<xsl:otherwise>
						<td width="33%"> </td>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="$vColumn3">
						<td width="33%">
							<img alt=""
src="/images/usuario/min_{$vColumn3/ficherosexternos/ficheroexterno_fichero}
" border="1" width="75" hspace="2" vspace="2" align="left"/>
							<input
type="checkbox" name="titulorevista"
value="{$vColumn3/composicioninformacion/sn_composicioninformacion[composici
oninformacion_alias = 'titulo']/metadatosinformacion_texto}"
onclick="comprobarRevistas(this)">
								<xsl:if
test="$vColumn3/composicioninformacion/sn_composicioninformacion[composicion
informacion_alias = 'estado']/metadatosinformacion_texto = 'false' ">

<xsl:attribute name="disabled">disabled</xsl:attribute>
								</xsl:if>
							</input>
							<xsl:value-of
select="$vColumn3/composicioninformacion/sn_composicioninformacion[composici
oninformacion_alias = 'titulo']/metadatosinformacion_texto"
disable-output-escaping="yes"/>
							<br/>
						</td>
					</xsl:when>
					<xsl:otherwise>
						<td width="33%"> </td>
					</xsl:otherwise>
				</xsl:choose>
			</tr>
			<tr>
				<td colspan="3" bgcolor="#7D97A2"
width="100%"/>
			</tr>
		</table>
	</xsl:template>
</xsl:stylesheet>

There were several problems.

When you were matching the metadatosinformacion_texto node you were only
getting the FIRST node which is OK if you only wanted the title.

If you add the condition [composicioninformacion_alias = 'estado'] on the
sn_composicioninformacion node you will then get the children of that node.

I'm not sure if the images will be correct because there were no
<ficherosexternos/> examples in your XML.

You might want to put a test on the images so you don't get a missing image.

<xsl:if test="$vColumn3/ficherosexternos/ficheroexterno_fichero">
<img alt=""
src="/images/usuario/min_{$vColumn3/ficherosexternos/ficheroexterno_fichero}
" border="1" width="75" hspace="2" vspace="2" align="left"/>
</xsl:if>

Buena suerte!

William Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net


-----Original Message-----
From: Miren [mailto:miren@xxxxxxxxxxxxx]
Sent: 2007 November 15 10:45
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  problem for extracting information using xsl from one
xml, please help me

Thanks for your answer. (Muchisimas gracias pro tu consejo).
But i cannot change the xml file, it is imposible.
Can you help me?

Thanks

> Miren,
>
> This is a facile task but the XML is horrible. Can you control the XML
> structure?
>
> Esto es un trabajo facil pero el XML es horrible. ?Puede usted controlar
> la
> estructura de XML?
>
> Something similar to:
>
> Algo similar a:
>
> <MasterInfomacion>
> 	<Titulo>1  Invierno 2002/03 NEGUA</Titulo>
> 	<Estado>false</Estado>
> 	<Precio>3</Precio>
> 	<TotalDePaginas>105</TotalDePaginas>
> </MasterInfomacion>
>
> For each node would be much better for programming and speed.
>
> Para cada nodo esti mucho mejor para programar y la velocidad.
>
> William Charlton
> The yMonda team
> yMonda Limited
> w: www.ymonda.net

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.