XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 12th, 2003, 09:16 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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



<xslaram 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

Reply With Quote
  #2  
Old March 12th, 2003, 10:29 AM
DarrenJ DarrenJ is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 42 DarrenJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 21 sec
Reputation Power: 6
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

Reply With Quote
  #3  
Old March 13th, 2003, 03:07 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
thank u darren

thank u darren

with regards
niha

Reply With Quote
  #4  
Old June 12th, 2003, 09:03 PM
Rudyten Rudyten is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 15 Rudyten User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 7 sec
Reputation Power: 0
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.

Reply With Quote
  #5  
Old June 12th, 2003, 09:05 PM
Rudyten Rudyten is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 15 Rudyten User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 7 sec
Reputation Power: 0
This line should read us
<xslaram name="nom">Brasil</xslaram>


I think.....


Rudy

Reply With Quote
  #6  
Old June 13th, 2003, 09:13 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
this might help u

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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"/>
<xslaram name="niha">Brasil</xslaram>
<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

Reply With Quote
  #7  
Old June 13th, 2003, 02:12 PM
Rudyten Rudyten is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 15 Rudyten User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 7 sec
Reputation Power: 0
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.

Reply With Quote
  #8  
Old June 13th, 2003, 08:21 PM
Rudyten Rudyten is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 15 Rudyten User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 7 sec
Reputation Power: 0
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

Reply With Quote
  #9  
Old June 14th, 2003, 05:27 AM
DarrenJ DarrenJ is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 42 DarrenJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 21 sec
Reputation Power: 6
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.

Reply With Quote
  #10  
Old September 1st, 2004, 04:53 AM
Panzermensch Panzermensch is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 Panzermensch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Anybody has found the solution?? pleaseeeee

Quote:
Originally Posted by Rudyten
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > xsl::: for loop <xsl:for-each select="$myvar">


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT