|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
xsl::: for loop <xsl:for-each select="$myvar">
hi all
can anyone help me to use variable in for loop select statement.... varible consists of path like this <xsl aram name="DILink" select="'/DrugEvaluation/DosingInformation/DosageForms/x'"/><xsl:for-each select="$myvar"> here </xsl:for-each> if it is not achievable suggest me closest solution pls.. any suggestions would be appreciatable.. with regards niha |
|
#2
|
|||
|
|||
|
Shouldn't param row look like this:
Code:
<xsl:param name="DILink" select="/DrugEvaluation/DosingInformation/DosageForms/x"/> And then: Code:
<xsl:for-each select="$DILink"> ... </xsl:for-each>
__________________
Best regards Darren |
|
#3
|
|||
|
|||
|
thank u darren
thank u darren
with regards niha |
|
#4
|
|||
|
|||
|
param in for-each select
I have this code...not working
<xsl:param name="nom">"Brasil"</xsl:param> <xsl:template match="/"> <html> <body> ... ... ... <table bgcolor="FFCC99" border="3"> <xsl:value-of select='$nom'/> (This displays OK, picks up param......) <xsl:for-each select="business_list/business[specialty=$nom]"> (Not showing up...DOES NOT PICK up param......) <tr> <td width="60%"> <xsl:value-of select="$nom"/><br /> <xsl:value-of select="name"/><br /> ... ... ... WHAT DID I DO WRONG? Last edited by Rudyten : June 13th, 2003 at 02:18 PM. |
|
#5
|
|||
|
|||
|
This line should read us
<xslaram name="nom">Brasil</xslaram> I think..... Rudy |
|
#6
|
|||
|
|||
|
this might help u
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><xsl aram name="niha">Brasil</xsl aram> <xsl:template match="/"> <h1><xsl:value-of select="$niha"/></h1> <xsl:if test="$niha = 'Brasil'"> <h1>here </h1> </xsl:if> </xsl:template> </xsl:stylesheet> ----------------- rudy.. pls c above code hope this will help u. with regards niha |
|
#7
|
|||
|
|||
|
Thanksecholalia , my fault.....changed it...still not working
--- Thanks nihaarika2002....< your above code does work....But I can not get the Param to work in a "for-each" <xsl:for-each select="business_list/business[specialty=$nom]"> (Not showing up...DOES NOT PICK up param......) <tr> <td> <xsl:value-of select="city"/><br /> <xsl:value-of select="zip"/><br /> </td> </tr> ================================== My XML has five records.... and they are formated correctly. if I do this" <xsl:for-each select="business_list/business[specialty='Brasil']"> It works OK Last edited by Rudyten : June 13th, 2003 at 02:17 PM. |
|
#8
|
|||
|
|||
|
Nevermind echolalia ...IT worked ...THANKS ALOT
But now here is my next question: Is this possible? How can I get my parameter in URL. to use in my "for-each" <xsl:param name="nom"> <script language='javascript'>location.search.substring(1)</script> </xsl:param> Does not seem like it would work on client side |
|
#9
|
|||
|
|||
|
Sure it works, even on the client side. Only in Mozilla (and mozilla based browsers) and IE 6 what I know.
Here is an example for Mozilla and NS: Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Netscape/Mozilla - XML/XSL/JavaScript test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<script>
var myXML;
var processor = new XSLTProcessor();
var myXSL = document.implementation.createDocument("", "test", null);
myXSL.addEventListener("load", loadXML, false);
myXSL.load("xsl_file.xsl");
function loadXML() {
myXML = document.implementation.createDocument("", "test", null);
myXML.addEventListener("load", doTrans, false);
myXML.load("xml_file.xml");
}
function doTrans(){
if (!processor.importStylesheet){
/* NS section */
var out = document.implementation.createDocument("", "test", null);
/*
In NS you need to modify your parameters with DOM functions since NS isn't supporting setParameter() function like Mozilla do.
*/
myXSL.getElementsByTagName("param")[0].childNodes[0].nodeValue = "param_value";
var newDocument = processor.transformDocument(myXML, myXSL, out, null);
var result = out.lastChild;
document.getElementById("result").appendChild(result);
}
else{
/* Mozilla section */
processor.importStylesheet(myXSL);
/*
In Mozilla, you have 2 choice. Use same code as for NS or use setParameter() function.
*/
processor.setParameter(null, "param_name", "param_value");
var newDocument = processor.transformToFragment(myXML, document);
document.getElementById("result").appendChild(newDocument);
}
}
</script>
</head>
<body id="result" style="margin: 20px;">
<!-- transformation will be displayed here -->
</body>
</html>
Parameter needs to be defined like this in your stylesheet: Code:
<xsl:param name="param_name">dummy_value</xsl:param> You must have dummy_value in your parameter so NS can modify it with DOM. Otherwise it won't work. |
|
#10
|
|||
|
|||
|
Anybody has found the solution?? pleaseeeee
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl::: for loop <xsl:for-each select="$myvar"> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|