Jump to content

Translate Sql Query To Xsl Query


subuntug

Recommended Posts

Posted

Hello everybody;I have this xml file:<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE vols SYSTEM "vols.dtd" ><?xml-stylesheet type="text/xsl" href="requete2.xsl"?><vols> <vol numV="16" dateV="02/01/2009" hdV="9h00" durV="1h30" prixV="150 " numP="10" numCi="20" numA="1" /> <vol numV="17" dateV="03/01/2009" hdV="9h30" durV="2h00" prixV="200 " numP="11" numCi="21" numA="2" /> <vol numV="18" dateV="03/01/2009" hdV="15h00" durV="0h45" prixV="75 " numP="12" numCi="22" numA="1" /> <vol numV="19" dateV="04/01/2009" hdV="10h00" durV="1h30" prixV="150 " numP="11" numCi="20" numA="3" /></vols>I have an SQL query which is : SELECT * FROM VOLS WHERE numP> AND (numCi=20 OR numCi=21);My question is : How can I make this SQL query with XSL ?Thanks in advence for your help

Posted

Your SQL Statement is incompleteSELECT * FROM VOLS WHERE numP>???? AND (numCi=20 OR numCi=21);but to get you started <xsl:template match="/"> <xsl:for-each select="//vols/vol[@numP >'10'][@numCi = '20' or @numCi = '21']" > <xsl:value-of select="@durV"/> </xsl:for-each> </xsl:template>

Posted
Your SQL Statement is incompleteSELECT * FROM VOLS WHERE numP>???? AND (numCi=20 OR numCi=21);but to get you started <xsl:template match="/"> <xsl:for-each select="//vols/vol[@numP >'10'][@numCi = '20' or @numCi = '21']" > <xsl:value-of select="@durV"/> </xsl:for-each> </xsl:template>
Thanks a lot for your help. But I steel have a little problem with my query.I want to select all attribute from elements when the statement is matched. When I try this code:<xsl:template match="/"><xsl:for-each select="/vols/vol[@numP >'10'][@numCi = '20' or @numCi = '21']" > <ul> <li> <xsl:value-of select="@*"/> </li> </ul></xsl:for-each>This return just the first attribute from the lines matched with XSL query.However I used "@*" which means "all attribute" in value-of statement.Do you have any idea, how can I select all attribute from the lines matched ?Thank you in advance for your help and your kindness.
Posted
		<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="//vols/vol[@numP >10][@numCi = 20 or @numCi = 21]" >					<xsl:for-each select="@*">						<xsl:value-of select="name()"/>:						<xsl:value-of select="."/><br/>					</xsl:for-each>				</xsl:for-each>			</xsl:template>		</xsl:stylesheet>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...