Jump to content

XML table- define search


nunochaves

Recommended Posts

hi, it's the first time i'm post a topic..... I'm new in xml, and i need some help with a xml table.... this is my xml code (not all, just a sample because the rest is equal to this):

<?xml version="1.0" encoding="utf-8" standalone="yes"?><!-- Generated by Softsilver Transformer 2.5 *** UNREGISTERED ***  (http://www.softsilver.com) --><?xml-stylesheet href="Farmácias1.xsl" type="text/xsl" ?><document>	<row>		<EMPRESA>Abreu,M Amélia Leme</EMPRESA>		<MORADA>R. Lodeiro Paços de Brandão</MORADA>		<LOCALIDADE>Paços de Brandão</LOCALIDADE>		<CÓDPOSTAL>4535-307 PAÇOS DE BRANDÃO</CÓDPOSTAL>		<CONCELHO>Santa Maria da Feira</CONCELHO>		<DISTRITO>Aveiro</DISTRITO>		<TEL>227446729</TEL>		<FAX/>		<EMAIL/>		<WEBSITE/>		<CATEGORIA>Farmácias</CATEGORIA>	</row>	<row>		<EMPRESA>Adelina M N Lopes Lúcio</EMPRESA>		<MORADA>Qt. Visconde Lt. 2 Britiande</MORADA>		<LOCALIDADE>Britiande</LOCALIDADE>		<CÓDPOSTAL>5100-344 BRITIANDE</CÓDPOSTAL>		<CONCELHO>Lamego</CONCELHO>		<DISTRITO>Viseu</DISTRITO>		<TEL>254697103</TEL>		<FAX>254699464</FAX>		<EMAIL/>		<WEBSITE/>		<CATEGORIA>Farmácias</CATEGORIA>	</row>	</document>

and this is my xslt code:

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="/">		<html>			<body>				<xsl:for-each select="document">					<table border="1" cellspacing="0">						<tr bgcolor="#FF9900">				<th><u>_____________________________EMPRESA_____________________________</u></th>						<th><u>_______________________MORADA_______________________</u></th>							<th><u>________LOCALIDADE________</u></th>							<th><u>_______________CÓDPOSTAL_______________</u></th>							<th><u>_____CONCELHO_____</u></th>							<th><u>______DISTRITO______</u></th>							<th><u>___TEL___</u></th>							<th><u>___FAX___</u></th>							<th><u>___________EMAIL___________</u></th>							<th><u>_______________WEBSITE_______________</u></th>							<th><u>CATEGORIA</u></th>						</tr>						<xsl:for-each select="row">							<xsl:sort select="EMPRESA"/>							<tr bgcolor="#FFFFCC">								<td>									<xsl:value-of select="EMPRESA"/>								</td>								<td>									<xsl:value-of select="MORADA"/>								</td>								<td>									<xsl:value-of select="LOCALIDADE"/>								</td>								<td>									<xsl:value-of select="CÓD_x0023__POSTAL"/>								</td>								<td>									<xsl:value-of select="CONCELHO"/>								</td>								<td>									<xsl:value-of select="DISTRITO"/>								</td>								<td>									<xsl:value-of select="TEL"/>								</td>								<td>									<xsl:value-of select="FAX"/>								</td>								<td>									<xsl:value-of select="EMAIL"/>								</td>								<td>									<xsl:value-of select="WEBSITE"/>								</td>								<td>									<xsl:value-of select="CATEGORIA"/>								</td>							</tr>						</xsl:for-each>					</table>				</xsl:for-each>			</body>		</html>	</xsl:template></xsl:stylesheet>

everything work just fine, but i don't know how to do what i want....i'm gonna put this table in a website, and that website will have a search space to people can find in table only want they're searching....i like to know if it's possible to define that search with some code in xml ou xsl based on just one column (LOCALIDADE).thanks everyone...ps:i hope i've post this topic on the rigth place in forum

Link to comment
Share on other sites

please, anyone can tell me if this is right....

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="/">		<html>			<body>				<xsl:for-each select="document">					<table border="1" cellspacing="0">						<tr bgcolor="#FF9900">							<th>								<u>_____________________________EMPRESA_____________________________</u>							</th>							<th>								<u>_______________________MORADA_______________________</u>							</th>							<th>								<u>________LOCALIDADE________</u>							</th>							<th>								<u>_______________CÓDPOSTAL_______________</u>							</th>							<th>								<u>_____CONCELHO_____</u>							</th>							<th>								<u>______DISTRITO______</u>							</th>							<th>								<u>___TEL___</u>							</th>							<th>								<u>___FAX___</u>							</th>							<th>								<u>___________EMAIL___________</u>							</th>							<th>								<u>_______________WEBSITE_______________</u>							</th>							<th>								<u>CATEGORIA</u>							</th>						</tr>						<xsl:for-each select="row">							<xsl:sort select="EMPRESA"/>							<xsl:for-each select="document/row[LOCALIDADE='']"/>							<tr bgcolor="#FFFFCC">								<td>									<xsl:value-of select="EMPRESA"/>								</td>								<td>									<xsl:value-of select="MORADA"/>								</td>								<td>									<xsl:value-of select="LOCALIDADE"/>								</td>								<td>									<xsl:value-of select="CÓD_x0023__POSTAL"/>								</td>								<td>									<xsl:value-of select="CONCELHO"/>								</td>								<td>									<xsl:value-of select="DISTRITO"/>								</td>								<td>									<xsl:value-of select="TEL"/>								</td>								<td>									<xsl:value-of select="FAX"/>								</td>								<td>									<xsl:value-of select="EMAIL"/>								</td>								<td>									<xsl:value-of select="WEBSITE"/>								</td>								<td>									<xsl:value-of select="CATEGORIA"/>								</td>							</tr>						</xsl:for-each>					</table>				</xsl:for-each>			</body>		</html>	</xsl:template>	<script language="JavaScript">function doSearch(){    var srcDoc=loadSource(item_document);    var processor=getProcessor(document_filter);    var LOCALIDADE = trim(document.getElementById('txtLOCALIDADE').value);    processor.addParameter("LOCALIDADE", LOCALIDADE);    var rsltDoc = transformData(srcDoc,processor);    document_table.innerHTML = rsltDoc.xml;}	</SCRIPT></xsl:stylesheet>

thanks

Link to comment
Share on other sites

XSLT is not very good at searching... and it's an XSLT fan that is telling you this. You may use it to find exact matches, but trying to make it "intelligent" would mean a huge performance hit, that is not even worth it.If you want to "filter" the table (that's different then searching), then it's best you have fixed values to filter for. For example, list all available values in the XML for column LOCALIDADE and allow the user to filter it's selection to only the rows that have that LOCALIDADE as value.... implementing that however is not exactly a walk in the park either.You need to have some S3L that will tweak parameters in the XSLT to do this. XSLT on it's own is not interactive, but rather static. It takes a third language to change something (at least one of it's parameters) to make it "feel" interactive.

Link to comment
Share on other sites

thanks for your help boen robot, and i'm sorry if my code look stupid :) i'm very new at thisso if i understand, i've to create a third language code to do what i want, right?which language you advise me to do this?sorry the question, but what is "S3L"?thanks for the help, i'm very grateful

Link to comment
Share on other sites

S3L - hover over the word in my previous post, or look at my signature :) . Server Side Scripting Language. It's my own abbreviation (not a publically accepted and used one), so I'm not surprised you're asking :) .Not to "create" a third language, but "use" an existing such language. Besides S3Ls, you could also use JavaScript, but that is generally harder to do (at least for me...).

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...